:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --accent: #bb86fc;
    --gap: 16px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Header */
header {
    padding: 40px 20px;
    text-align: center;
    background: linear-gradient(180deg, rgba(18, 18, 18, 1) 0%, rgba(18, 18, 18, 0) 100%);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
}

h1 {
    margin: 0;
    font-weight: 600;
    font-size: 2.5rem;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: 300;
}

.config-panel {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

input {
    background: #2c2c2c;
    border: 1px solid #333;
    padding: 10px 16px;
    border-radius: 8px;
    color: white;
    font-family: inherit;
    width: 250px;
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--accent);
}

button {
    background: var(--accent);
    color: black;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #1e1e1e;
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    /* Adjust if needed depending on header height */
    z-index: 9;
    flex-wrap: wrap;
    gap: 10px;
}

.header-content {
    /* Make header smaller or scroll away if desired, for now keep default */
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.95rem;
}

.crumb {
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.crumb:hover {
    color: var(--accent);
    text-decoration: underline;
}

.crumb::after {
    content: '/';
    margin-left: 8px;
    color: #444;
}

.crumb:last-child {
    color: var(--text-primary);
    cursor: default;
    pointer-events: none;
    text-decoration: none;
}

.crumb:last-child::after {
    content: '';
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
}

#sortSelect,
#filterInput {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #2c2c2c;
    color: white;
    font-family: inherit;
    outline: none;
}

#filterInput {
    width: 200px;
}

/* Gallery Items - Folders */
.folder-item {
    background: #2a2a2a;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    border: 1px solid #333;
}

.folder-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.folder-name {
    font-weight: 500;
    font-size: 1rem;
    color: var(--text-primary);
}

/* Update Gallery Grid for mixed content */
/* Masonry is okay, but folders look better if they span or sit nicely. 
   For simplicity, we treat them as items. */

.gallery {
    column-count: 4;
    column-gap: var(--gap);
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: var(--gap);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: zoom-in;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-color: var(--card-bg);
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.3s;
}

.gallery-item img.loaded {
    opacity: 1;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.95);
    justify-content: center;
    align-items: center;
    flex-direction: column;
    animation: fadeIn 0.3s;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90vh;
    border-radius: 4px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s;
}

.close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    z-index: 101;
}

.close:hover,
.close:focus {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}

#caption {
    margin-top: 15px;
    color: #ccc;
    font-size: 1.1rem;
}

/* Utility */
.hidden {
    display: none !important;
}

.error {
    color: #ff6b6b;
    text-align: center;
    padding: 20px;
}

.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--accent);
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media screen and (max-width: 1024px) {
    .gallery {
        column-count: 3;
    }
}

@media screen and (max-width: 768px) {
    .gallery {
        column-count: 2;
    }
}

@media screen and (max-width: 480px) {
    .gallery {
        column-count: 1;
    }

    h1 {
        font-size: 2rem;
    }

    .config-panel {
        padding: 0 20px;
    }

    input {
        width: 100%;
    }
}

/* Settings Button */
.settings-btn {
    background: none;
    border: 1px solid #333;
    color: var(--text-secondary);
    font-size: 1.5rem;
    padding: 8px 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.3s;
}

.settings-btn:hover {
    background: #333;
    color: white;
    transform: rotate(90deg);
}

/* Admin Panel Modal */
.admin-panel {
    background: #1e1e1e;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    border: 1px solid #333;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s;
}

.admin-desc {
    color: #888;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    box-sizing: border-box;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.primary-btn {
    background: var(--accent);
    color: black;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
}

.secondary-btn {
    background: transparent;
    border: 1px solid #444;
    color: #ccc;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    flex: 1;
}

.danger-btn {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-size: 0.9rem;
}

.primary-btn:hover {
    opacity: 0.9;
}

.secondary-btn:hover {
    background: #2a2a2a;
}

.danger-btn:hover {
    background: rgba(255, 107, 107, 0.2);
}