/* ==========================================================================
   Pampas — design system clair & épuré (front client)
   ========================================================================== */

:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-muted: #f1f2f6;
    --text: #1c2130;
    --text-muted: #6b7280;
    --border: #e6e8ee;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef0fd;
    --danger: #e11d48;
    --danger-soft: #fdeef1;
    --success: #16a34a;
    --success-soft: #edf9f0;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 2px 8px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--text);
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

::selection { background: var(--primary-soft); color: var(--primary-hover); }

/* ---------- Surfaces ---------- */

.surface-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ---------- Boutons ---------- */

.btn {
    border-radius: var(--radius-sm);
    font-weight: 550;
    padding-inline: 1rem;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #be123c; border-color: #be123c; }

.btn-outline-danger { color: var(--danger); border-color: #f3c6d1; }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); }

.btn-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
}

/* ---------- Formulaires ---------- */

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    padding: .6rem .85rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.input-icon {
    position: relative;
}
.input-icon .bi {
    position: absolute;
    left: .9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.input-icon .form-control {
    padding-left: 2.6rem;
}

/* ---------- Page d'authentification ---------- */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(circle at 15% 10%, #eef0fd 0%, transparent 45%),
        radial-gradient(circle at 85% 90%, #f1f2f6 0%, transparent 45%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 2.25rem 2rem;
}

.auth-badge {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin: 0 auto 1rem;
}

.auth-title {
    text-align: center;
    margin-bottom: .25rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: .9rem;
    margin-bottom: 1.5rem;
}

.captcha-box {
    background: var(--surface-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: .6rem .85rem;
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: .75rem;
}

/* ---------- Alertes ---------- */

.alert {
    border: none;
    border-radius: var(--radius-sm);
    font-size: .9rem;
}
.alert-danger { background: var(--danger-soft); color: #9f1239; }
.alert-success { background: var(--success-soft); color: #166534; }

/* ---------- Barre supérieure (galerie) ---------- */

.app-topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-topbar .dossier-name {
    text-transform: capitalize;
}

/* ---------- Galerie ---------- */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.photo-tile {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    aspect-ratio: 1 / 1;
    transition: box-shadow .15s ease, transform .15s ease;
}
.photo-tile:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.photo-tile img,
.photo-tile .video-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Fond neutre pendant qu'une vignette en chargement paresseux n'a pas encore sa src. */
.lazy-img {
    background: var(--surface-muted);
}

.video-cover {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #1c2130, #363c52);
    color: #fff;
    font-size: 2rem;
}

.photo-tile .tile-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,.55) 100%);
    opacity: 0;
    transition: opacity .15s ease;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: .6rem .7rem;
    /* L'overlay couvre toute la tuile (inset:0) même quand il est invisible (opacity:0) :
       sans ceci, il interceptait tous les clics et empêchait d'ouvrir la lightbox. */
    pointer-events: none;
}
.photo-tile:hover .tile-overlay { opacity: 1; }

.tile-filename {
    color: #fff;
    font-size: .78rem;
    max-width: 75%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile-download {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.92);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* Seul élément interactif de l'overlay : redonne la main aux clics sur le bouton. */
    pointer-events: auto;
}
.tile-download:hover { background: #fff; color: var(--primary); }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state .bi {
    font-size: 2.2rem;
    color: var(--border);
    display: block;
    margin-bottom: .75rem;
}

/* Override lightbox2 pour matcher le thème */
#lightboxOverlay { background-color: #10131c; }
.lb-outerContainer, .lb-dataContainer {
    border-radius: var(--radius);
}
.lb-data .lb-caption { font-weight: 550; }

/* ---------- Catégories ---------- */

.category-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.category-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: .85rem;
    font-weight: 550;
    padding: .4rem .9rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.category-pill:hover { border-color: var(--primary); color: var(--primary-hover); }
.category-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.category-pill .badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 .35rem;
    border-radius: 999px;
    background: rgba(0,0,0,.06);
    font-size: .7rem;
    font-weight: 650;
}
.category-pill.active .badge-count { background: rgba(255,255,255,.25); }

.gallery-section { margin-bottom: 2rem; }
.gallery-section:last-child { margin-bottom: 0; }

.gallery-section-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 650;
    font-size: 1.05rem;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}
.gallery-section-header .bi { color: var(--primary); }
