:root {
	--fc-primary-color: #673DE6;
	--fc-body-bg: #f7f7f9;
	--fc-container-bg: #FFFFFF;
	--fc-text-dark: #231E39;
	--fc-text-light: #6A6A6A;
	--fc-border-color: #E7E7E7;
	--fc-font-family: 'Poppins', sans-serif;
	--fc-border-radius: 8px;
	--fc-box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.05);
}

body.frontcat-gallery-modal-mode {
    padding: 0;
    margin: 0;
    font-family: var(--fc-font-family);
	background-color: transparent;
	overflow: hidden; 
}

body.frontcat-gallery-page .frontcat-gallery-wrap {
    height: calc(100vh - 60px);
    margin: -20px -20px 0 -20px;
}

body.frontcat-gallery-page .wrap {
    max-width: 100%;
}

#frontcat-gallery-modal-content {
    all: initial;
    display: block;
    width: 100%;
    height: 100%;
    background: white;
    overflow: hidden;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
}

#frontcat-gallery-modal-content * {
    box-sizing: border-box;
}

#frontcat-gallery-modal-content .frontcat-gallery-wrap {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #FFFFFF;
    font-family: 'Poppins', sans-serif;
}

#frontcat-gallery-modal-content .frontcat-gallery-wrap button,
#frontcat-gallery-modal-content .frontcat-gallery-wrap input,
#frontcat-gallery-modal-content .frontcat-gallery-wrap select,
#frontcat-gallery-modal-content .frontcat-gallery-wrap h2,
#frontcat-gallery-modal-content .frontcat-gallery-wrap a {
    font-family: 'Poppins', sans-serif;
}

#frontcat-gallery-modal-content .frontcat-gallery-wrap {
	--fc-primary-color: #673DE6;
    --fc-container-bg: #FFFFFF;
    --fc-text-dark: #231E39;
    --fc-text-light: #6A6A6A;
    --fc-border-color: #E7E7E7;
    --fc-border-radius: 8px;
    --fc-box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.05);
}

body.frontcat-gallery-modal-mode .frontcat-gallery-wrap button,
body.frontcat-gallery-modal-mode .frontcat-gallery-wrap input,
body.frontcat-gallery-modal-mode .frontcat-gallery-wrap select,
body.frontcat-gallery-modal-mode .frontcat-gallery-wrap h2,
body.frontcat-gallery-modal-mode .frontcat-gallery-wrap a {
    font-family: var(--fc-font-family);
}

.frontcat-gallery-wrap {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--fc-border-radius);
    overflow: hidden; 
}

#frontcat-gallery-close {
    position: absolute;
    top: 10px;
    right: 15px;
    z-index: 90;
    background-color: rgba(0,0,0,0.4);
    color: white;
}
#frontcat-gallery-close:hover {
    background-color: rgba(0,0,0,0.6);
    color: white;
}

.frontcat-gallery-layout {
    display: flex;
    gap: 24px;
    align-items: stretch;
    flex-grow: 1;
    min-height: 0;
    padding: 20px;
}

.gallery-sidebar {
    flex: 0 0 280px;
    background-color: var(--fc-container-bg);
    border: 1px solid var(--fc-border-color);
    border-radius: var(--fc-border-radius);
    display: flex;
    flex-direction: column;
	box-shadow: var(--fc-box-shadow);
}
.gallery-sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--fc-border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.gallery-sidebar-header h2 {
    font-size: 16px;
    margin: 0;
	color: var(--fc-text-dark);
}
.gallery-sidebar-content {
    padding: 10px;
    overflow-y: auto;
    flex-grow: 1;
}
.gallery-sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--fc-border-color);
}
.gallery-sidebar-footer #new-folder-name {
    width: -webkit-fill-available;
    margin-bottom: 10px;
	padding: 10px;
    border: 1px solid var(--fc-border-color);
    border-radius: var(--fc-border-radius);
	background-color: var(--fc-container-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.gallery-sidebar-footer #new-folder-name:focus {
    border-color: var(--fc-primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fc-primary-color) 20%, transparent);
    outline: none;
}

.gallery-sidebar-footer .button {
    width: 100%;
}

.button, .button-secondary {
    background-color: var(--fc-primary-color);
    color: #fff;
    border: none !important;
    padding: 8px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
	text-decoration: none !important;
	display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
	text-align: center;
    white-space: nowrap;
    margin: 0 !important;
    line-height: 1.5 !important;
    text-transform: uppercase;
    min-height: auto !important;
    height: auto !important;
}
.button svg, .button-secondary svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex-shrink: 0;
}
.button:hover {
    background-color: color-mix(in srgb, var(--fc-primary-color) 90%, black);
}
.button.is-destructive {
	background-color: #d63638;
    color: #fff;
}
.button.is-destructive:hover {
	background-color: #b02a2c;
}
.button-secondary {
    background-color: #f0f0f1;
    color: #1e1e1e;
    border: 1px solid #dcdcde;
}
.button-secondary:hover {
    background-color: #e7e7e8;
    border-color: #caccd0;
}
.button-icon-only {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--fc-text-light);
}
.button-icon-only:hover {
    background-color: #f0f0f1;
    color: var(--fc-text-dark);
}
.button-icon-only svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}


.gallery-folder-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.gallery-folder-list li {
    display: flex;
    align-items: center;
    position: relative;
}

.gallery-folder-list li a {
    flex-grow: 1;
    display: block;
    padding: 10px 15px;
    text-decoration: none;
    color: var(--fc-text-dark);
    border-radius: 6px;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
	font-weight: 500;
}
.gallery-folder-list li a:hover {
    background-color: #f0f0f0;
}
.gallery-folder-list li a.active {
    background-color: color-mix(in srgb, var(--fc-primary-color) 10%, transparent);
    color: var(--fc-primary-color);
    font-weight: 600;
}

.gallery-folder-list .delete-folder-button {
    display: none;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background-color: transparent;
    color: #d63638;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
}

.gallery-folder-list li:hover .delete-folder-button {
    display: inline-flex;
}

.gallery-folder-list li.no-delete:hover .delete-folder-button {
    display: none;
}

.gallery-folder-list .delete-folder-button:hover {
    background-color: #fbeaea;
}

.gallery-folder-list .delete-folder-button svg {
    width: 16px;
    height: 16px;
}

.gallery-main {
    flex: 1;
    min-width: 0;
    background-color: var(--fc-container-bg);
    border: 1px solid var(--fc-border-color);
    border-radius: var(--fc-border-radius);
    display: flex;
    flex-direction: column;
	box-shadow: var(--fc-box-shadow);
}
.gallery-main-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--fc-border-color);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.header-row-1 {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
}
.header-row-2 {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}
.gallery-main-header h2 {
    font-size: 16px;
    margin: 0;
    flex-shrink: 0;
	color: var(--fc-text-dark);
}
.gallery-select-actions {
    display: flex;
    gap: 15px;
    font-size: 13px;
    margin-right: auto;
}
.gallery-select-actions a {
    text-decoration: none;
    color: var(--fc-primary-color);
	font-weight: 500;
}
.gallery-select-actions a:hover {
    text-decoration: underline;
}
.gallery-main-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}
.gallery-main-actions select {
	padding: 8px 12px;
    border: 1px solid var(--fc-border-color);
    border-radius: var(--fc-border-radius);
}
.gallery-main-content {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}
.gallery-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}
.gallery-image-item, .gallery-video-item {
    position: relative;
    border: 2px solid transparent;
    padding: 4px;
    border-radius: 6px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.gallery-video-item {
    background-color: #f0f0f1;
}
.gallery-image-item.selected, .gallery-video-item.selected {
    border-color: var(--fc-primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fc-primary-color) 40%, transparent);
}
.gallery-image-item img, .gallery-video-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 4px;
    border: 1px solid var(--fc-border-color);
}
.gallery-video-item img {
    object-fit: contain;
    padding: 20px;
}
.gallery-video-item.is-fallback-icon img {
    object-fit: contain;
    padding: 25%;
    box-sizing: border-box;
}
.gallery-video-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8,5.14V19.14L19,12.14L8,5.14Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px;
    pointer-events: none;
}
.gallery-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: 16px;
    color: var(--fc-text-light);
}
#create-folder-status {
    font-size: 12px;
    margin-top: 8px;
    text-align: center;
}

#toggle-sidebar-button {
    display: none;
}
#close-sidebar-button {
    display: none;
}
.gallery-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 99;
}


@media (max-width: 768px) {
    .frontcat-gallery-layout {
        flex-direction: column;
        padding: 0;
        gap: 0;
        position: relative;
    }
    #frontcat-gallery-close {
        top: 5px;
        right: 5px;
    }
    .gallery-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        border-radius: 0;
		border-right: 1px solid var(--fc-border-color);
        box-shadow: 0 0 20px rgba(0,0,0,0.2);
    }
    .gallery-sidebar.is-visible {
        transform: translateX(0);
    }
    .gallery-sidebar.is-visible ~ .gallery-overlay {
        display: block;
    }
    .gallery-main {
        width: 100%;
        border-radius: 0;
        border: none;
		box-shadow: none;
		height: 100%;
    }
    #toggle-sidebar-button {
        display: inline-flex;
    }
    #close-sidebar-button {
        display: inline-flex;
    }
    .gallery-main-header h2 {
        font-size: 14px;
    }
    .gallery-select-actions {
        display: none;
    }
    .header-row-2 {
        justify-content: space-between;
    }
    .gallery-main-actions, #frontcat-upload-container {
        flex-basis: auto;
        justify-content: flex-end;
    }
    .gallery-image-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    .gallery-main-actions .button span {
        display: none;
    }
    #use-image-button span {
        display: inline-block;
    }
    .gallery-main-actions .button, .gallery-main-actions .button-secondary {
        padding: 8px 12px;
    }
    #use-image-button svg {
        display: none;
    }
    .gallery-main-actions {
        flex-grow: 1;
        justify-content: flex-end;
    }
    #frontcat-upload-container {
       display: none;
    }
    .gallery-folder-list .delete-folder-button {
        display: inline-flex;
        position: static;
        transform: none;
        margin-left: 8px;
        flex-shrink: 0;
    }
    .gallery-folder-list li:hover .delete-folder-button {
        display: inline-flex;
    }
}