/*
 * AlbumEEIL v2 — Design System
 *
 * Variables --theme-* attendues (injectées dans <head> par theme_render_css_vars()) :
 *   --theme-bg-primary     --theme-bg-secondary    --theme-bg-input       --theme-bg-elevated
 *   --theme-border         --theme-border-hover
 *   --theme-text-primary   --theme-text-secondary  --theme-text-muted
 *   --theme-accent         --theme-accent-hover     --theme-accent-text    --theme-accent-soft
 *   --theme-link
 *   --theme-success        --theme-success-soft
 *   --theme-warning        --theme-warning-soft
 *   --theme-danger         --theme-danger-soft
 */

/* ================================================================
   1. Reset minimal
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, h5, h6, p { margin: 0; padding: 0; }
button { cursor: pointer; font-family: inherit; }
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
input, select, textarea { font-family: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--theme-border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--theme-border-hover); }

/* ================================================================
   2. Typographie de base
   ================================================================ */

body {
    font-family: 'Public Sans', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--theme-text-primary);
    background: var(--theme-bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "ss01", "cv11";
}

.mono {
    font-family: 'JetBrains Mono', 'Fira Mono', monospace;
}

/* ================================================================
   3. Animations
   ================================================================ */

@keyframes ae-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.ae-fade { animation: ae-fade-in 0.25s ease-out both; }

@keyframes ae-spin { to { transform: rotate(360deg); } }
.ae-spin { animation: ae-spin 0.8s linear infinite; }

@keyframes ae-scale-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.ae-modal { animation: ae-scale-in 0.18s ease-out both; }

/* ================================================================
   4. Design tokens
   ================================================================ */

/* --- .ae-card --- */

.ae-card {
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    transition: border-color 0.15s;
}

.ae-card:hover {
    border-color: var(--theme-border-hover);
}

/* --- .ae-btn --- */

.ae-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ae-btn-primary {
    background: var(--theme-accent);
    color: var(--theme-accent-text);
}
.ae-btn-primary:hover {
    background: var(--theme-accent-hover);
}

.ae-btn-secondary {
    background: transparent;
    color: var(--theme-text-primary);
    border-color: var(--theme-border);
}
.ae-btn-secondary:hover {
    background: var(--theme-bg-elevated);
    border-color: var(--theme-border-hover);
    color: var(--theme-text-primary);
}

.ae-btn-ghost {
    background: transparent;
    color: var(--theme-text-secondary);
    border-color: transparent;
}
.ae-btn-ghost:hover {
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
}

.ae-btn-danger {
    background: transparent;
    color: var(--theme-danger);
    border-color: var(--theme-border);
}
.ae-btn-danger:hover {
    background: var(--theme-danger-soft);
    border-color: var(--theme-danger);
}

/* --- .ae-input --- */

.ae-input {
    width: 100%;
    background: var(--theme-bg-input);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    padding: 11px 14px;
    color: var(--theme-text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.ae-input:focus {
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 3px var(--theme-accent-soft);
}
.ae-input::placeholder {
    color: var(--theme-text-muted);
}

/* --- .ae-label --- */

.ae-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--theme-text-secondary);
    margin-bottom: 6px;
}

/* --- .ae-link --- */

.ae-link {
    color: var(--theme-link);
    text-decoration: none;
    cursor: pointer;
}
.ae-link:hover {
    text-decoration: underline;
}

/* --- .ae-switch --- */

.ae-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.ae-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.ae-switch-track {
    width: 42px;
    height: 24px;
    background: var(--theme-bg-input);
    border: 1px solid var(--theme-border);
    border-radius: 999px;
    position: relative;
    transition: background 0.18s, border-color 0.18s;
    flex-shrink: 0;
}
.ae-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--theme-text-secondary);
    border-radius: 999px;
    transition: transform 0.18s, background 0.18s;
}
.ae-switch input:checked + .ae-switch-track {
    background: var(--theme-accent);
    border-color: var(--theme-accent);
}
.ae-switch input:checked + .ae-switch-track .ae-switch-thumb {
    transform: translateX(18px);
    background: #fff;
}
.ae-switch input:focus-visible + .ae-switch-track {
    box-shadow: 0 0 0 3px var(--theme-accent-soft);
}
.ae-switch[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ================================================================
   5. Layout principal
   ================================================================ */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--theme-bg-secondary);
    border-right: 1px solid var(--theme-border);
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 200;
    transition: transform 0.25s ease;
}

.sidebar__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    flex-shrink: 0;
}

.sidebar__logo {
    width: 32px;
    height: 32px;
    border-radius: 7px;
    background: linear-gradient(135deg, #2a6cb8, #1d4f8c);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.sidebar__brand {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar__brand-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--theme-text-primary);
    line-height: 1.2;
}

.sidebar__brand-cohort {
    font-size: 11px;
    color: var(--theme-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar__nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__nav-section {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--theme-text-muted);
    padding: 8px 8px 6px;
    margin-top: 4px;
}

.sidebar__nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 7px;
    color: var(--theme-text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    position: relative;
    transition: background 0.12s, color 0.12s;
}

.sidebar__nav-item:hover {
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
}

.sidebar__nav-item.is-active {
    background: var(--theme-accent-soft);
    color: var(--theme-text-primary);
    font-weight: 600;
}

.sidebar__nav-item.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: var(--theme-accent);
    border-radius: 2px;
}

.sidebar__nav-item.is-active .sidebar__nav-icon {
    color: var(--theme-link);
}

.sidebar__nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.sidebar__footer {
    flex-shrink: 0;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--theme-border);
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.sidebar__user-info {
    flex: 1;
    min-width: 0;
}

.sidebar__user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--theme-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar__user-email {
    font-size: 11px;
    color: var(--theme-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Avatar --- */

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #dbe2ef;
    flex-shrink: 0;
    user-select: none;
}

/* --- Role badge --- */

.role-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 8px;
    border-radius: 999px;
}

.role-badge--student {
    background: var(--theme-bg-elevated);
    color: var(--theme-text-secondary);
}

/* committee and admin badge colors are derived from the accent palette */
.role-badge--committee {
    background: rgba(104, 137, 196, 0.16);
    color: #88a4d4;
}

.role-badge--admin {
    background: var(--theme-accent-soft);
    color: #5d8fcf;
}

/* --- Topbar --- */

.topbar {
    position: sticky;
    top: 0;
    background: var(--theme-bg-primary);
    border-bottom: 1px solid var(--theme-border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 100;
    flex-shrink: 0;
}

.topbar__hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--theme-text-secondary);
    padding: 0;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}

.topbar__hamburger:hover {
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
}

.topbar__breadcrumb {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--theme-text-secondary);
    min-width: 0;
    overflow: hidden;
}

.cohort-selector-trigger {
    padding: 6px 10px;
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    background: var(--theme-bg-input);
    font-size: 12px;
    color: var(--theme-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color 0.15s;
}

.cohort-selector-trigger:hover {
    border-color: var(--theme-border-hover);
}

.cohort-option {
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--theme-text-primary);
    transition: background 0.12s;
}

.cohort-option:hover {
    background: var(--theme-bg-elevated);
}

.cohort-option.is-viewing {
    background: var(--theme-accent-soft);
    font-weight: 600;
}

.cohort-option.is-viewing:hover {
    background: var(--theme-accent-soft);
}

/* --- App body / main --- */

.app-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
}

.main-content {
    flex: 1;
    padding: 28px 32px 48px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* --- Drawer backdrop (mobile) --- */

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 11, 20, 0.7);
    backdrop-filter: blur(4px);
    z-index: 150;
}

/* ================================================================
   6. Responsive ≤900px
   ================================================================ */

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        transform: translateX(-100%);
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.4);
    }

    .topbar__hamburger {
        display: inline-flex;
    }

    .main-content {
        padding: 20px 16px 32px;
    }
}

/* ================================================================
   7. Composants — photo-card
   ================================================================ */

.photo-card {
    transition: border-color 0.15s, transform 0.15s;
    cursor: pointer;
}

.photo-card:hover {
    border-color: var(--theme-border-hover);
    transform: translateY(-2px);
}

.photo-card__img-wrap {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--theme-bg-input);
    overflow: hidden;
}

.photo-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-card__img-fallback {
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    color: var(--theme-text-muted);
}

/* ================================================================
   8. Composants — grille de photos (student dashboard)
   ================================================================ */

.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

@media (max-width: 640px) {
    .photos-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }
}

/* ================================================================
   9. Composants — modal overlay
   ================================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 11, 20, 0.72);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-box {
    position: relative;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 16px;
    width: 100%;
    max-width: 1080px;
    max-height: calc(100vh - 48px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--theme-border);
    flex-shrink: 0;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

@media (max-width: 768px) {
    .modal-body-grid {
        flex-direction: column !important;
    }
}

/* ================================================================
   10. Composants — photo card committee (sélection)
   ================================================================ */

.photo-card--selected {
    border-color: var(--theme-accent) !important;
    box-shadow: 0 0 0 2px var(--theme-accent-soft);
}

.photo-card__checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: rgba(8, 11, 20, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    backdrop-filter: blur(2px);
}

.photo-card__checkbox:hover {
    border-color: white;
    background: rgba(8, 11, 20, 0.7);
}

.photo-card__checkbox.is-checked {
    background: var(--theme-accent);
    border-color: var(--theme-accent);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ================================================================
   11. Confirm dialog
   ================================================================ */

.ae-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(8, 11, 20, 0.72);
    backdrop-filter: blur(4px);
}

.ae-confirm-card {
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 14px;
    max-width: 440px;
    width: 100%;
    padding: 24px;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
    animation: ae-scale-in 0.18s ease-out both;
}

.ae-confirm-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin: 0 0 8px;
    color: var(--theme-text-primary);
}

.ae-confirm-message {
    font-size: 14px;
    color: var(--theme-text-secondary);
    margin: 0 0 24px;
    line-height: 1.5;
}

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

/* ================================================================
   12. Toasts + bouton danger solide
   ================================================================ */

/* z-index 9000 : au-dessus des modals de page (500) mais sous confirm (9999) */
.ae-toast-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
    pointer-events: none;
}

.ae-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-left-width: 3px;
    box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.5);
    color: var(--theme-text-primary);
    pointer-events: auto;
}

.ae-toast-success { border-left-color: var(--theme-success); }
.ae-toast-error   { border-left-color: var(--theme-danger); }
.ae-toast-info    { border-left-color: var(--theme-accent); }

.ae-toast-message { flex: 1; font-size: 13px; line-height: 1.45; }

.ae-toast-close {
    padding: 2px 6px;
    background: transparent;
    border: none;
    color: var(--theme-text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.ae-toast-close:hover { color: var(--theme-text-primary); }

@keyframes ae-toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.ae-toast-enter { animation: ae-toast-in 0.22s ease-out both; }
.ae-toast-leave { animation: ae-toast-in 0.18s ease-in reverse both; }

.ae-btn-danger-solid {
    background: var(--theme-danger);
    color: #fff;
    border: 1px solid var(--theme-danger);
}

.ae-btn-danger-solid:hover {
    background: #d04437;
    border-color: #d04437;
}
