/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
    --color-bg: #fdf6f7;
    --color-surface: #ffffff;
    --color-primary: #c27a8a;
    --color-primary-hover: #a8606f;
    --color-primary-light: #f0d4da;
    --color-text: #3a3a3a;
    --color-text-light: #8a7f80;
    --color-border: #e8d5d8;
    --color-error: #c0392b;
    --color-overlay: rgba(0, 0, 0, 0.7);
    --radius: 10px;
    --shadow: 0 2px 16px rgba(194, 122, 138, 0.12);
    --font-display: "Great Vibes", cursive;
    --font-body: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-outline {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }

.btn-active {
    background: var(--color-primary);
    color: #fff;
}

.btn-danger {
    background: #c0392b;
    color: #fff;
}
.btn-danger:hover { background: #a93226; }

.btn-action { cursor: pointer; }

.btn svg { flex-shrink: 0; }

/* ── Login ────────────────────────────────────────────────────────────── */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px;
    background: linear-gradient(160deg, #f5e1e5 0%, #fdf6f7 50%, #f0d4da 100%);
}

.login-card {
    background: var(--color-surface);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 40px 32px;
    text-align: center;
    width: 100%;
    max-width: 380px;
}

.login-photo {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--color-primary-light);
    box-shadow: 0 4px 20px rgba(194, 122, 138, 0.2);
}

.login-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.login-names {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 400;
    color: var(--color-primary);
    margin-bottom: 8px;
    line-height: 1.2;
}

.login-subtitle {
    color: var(--color-text-light);
    margin-bottom: 28px;
    font-size: 0.9rem;
    line-height: 1.5;
    font-weight: 300;
}

.login-card input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 1rem;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-card input[type="password"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(194, 122, 138, 0.15);
}

.login-card button {
    width: 100%;
    padding: 14px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.login-card button:hover { background: var(--color-primary-hover); }
.login-card button:active { transform: scale(0.98); }

.error {
    color: var(--color-error);
    font-size: 0.85rem;
    margin-bottom: 12px;
}

/* ── Hero header ──────────────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, #e8b4bc 0%, #d4949f 100%);
    padding: 32px 20px 28px;
    text-align: center;
}

.hero-content {
    max-width: 500px;
    margin: 0 auto;
}

.hero-photo {
    width: 110px;
    height: 110px;
    margin: 0 auto 16px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

.hero-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-names {
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 400;
    color: #fff;
    margin-bottom: 10px;
    line-height: 1.1;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.hero-subtitle {
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.92rem;
    font-weight: 300;
    line-height: 1.6;
    max-width: 380px;
    margin: 0 auto;
}

/* ── Toolbar ──────────────────────────────────────────────────────────── */
.toolbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.folder-nav {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

/* On small screens, stack toolbar vertically */
@media (max-width: 520px) {
    .toolbar {
        padding: 8px 12px;
    }
    .toolbar-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .toolbar-left {
        justify-content: center;
    }
    .toolbar-right {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    .toolbar-right .btn-action {
        width: 100%;
        justify-content: center;
    }
    .folder-nav {
        justify-content: center;
    }
}

/* ── Upload progress ──────────────────────────────────────────────────── */
.upload-progress {
    padding: 10px 20px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    width: 0%;
    transition: width 0.3s;
    border-radius: 3px;
}

#upload-status {
    font-size: 0.82rem;
    color: var(--color-text-light);
    white-space: nowrap;
}

/* ── Photo grid ───────────────────────────────────────────────────────── */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
}

@media (min-width: 480px) {
    .photo-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 8px;
    }
}

@media (min-width: 768px) {
    .photo-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        padding: 12px;
    }
}

@media (min-width: 1024px) {
    .photo-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
        padding: 16px;
    }
}

@media (min-width: 1400px) {
    .photo-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

.photo-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: var(--color-border);
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s;
}

.photo-card:hover img {
    transform: scale(1.04);
}

/* Selection checkbox */
.photo-card .select-check {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2;
    color: #fff;
    font-size: 14px;
}

.photo-card:hover .select-check,
.photo-card.selected .select-check {
    opacity: 1;
}

.photo-card.selected .select-check {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.photo-card.selected::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 3px solid var(--color-primary);
    border-radius: 6px;
    pointer-events: none;
}

/* ── Lightbox ─────────────────────────────────────────────────────────── */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: var(--color-overlay);
}

.lightbox-img-container {
    position: relative;
    z-index: 1001;
    max-width: 92vw;
    max-height: 92vh;
}

.lightbox-img-container img {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 1002;
    line-height: 1;
    padding: 8px 14px;
    border-radius: var(--radius);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    font-size: 2.2rem;
    padding: 14px 18px;
    cursor: pointer;
    z-index: 1002;
    border-radius: var(--radius);
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.lightbox-prev { left: 6px; }
.lightbox-next { right: 6px; }
.lightbox-nav:hover { background: rgba(0, 0, 0, 0.65); }

/* Mobile: make lightbox nav buttons easier to tap */
@media (max-width: 600px) {
    .lightbox-nav {
        width: 52px;
        height: 52px;
        padding: 0;
        font-size: 1.8rem;
        top: auto;
        bottom: 24px;
        transform: none;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .lightbox-prev { left: 24px; }
    .lightbox-next { right: 24px; }
    .lightbox-close {
        top: 10px;
        right: 10px;
        padding: 10px 14px;
    }
}

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--color-overlay);
}

.modal-content {
    position: relative;
    background: var(--color-surface);
    padding: 28px 24px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 360px;
    z-index: 501;
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.95rem;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.modal-content input[type="text"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(194, 122, 138, 0.15);
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Loading / empty ──────────────────────────────────────────────────── */
.loading {
    display: flex;
    justify-content: center;
    padding: 32px;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--color-text-light);
    font-size: 1rem;
    font-weight: 300;
}
