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

: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); }

/* ---------- 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-success { background: var(--success); border-color: var(--success); }
.btn-success:hover { background: #15803d; border-color: #15803d; }

.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); color: #fff; }

.btn-outline-secondary { color: var(--text-muted); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--surface-muted); color: var(--text); border-color: var(--border); }

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

.btn-sm { border-radius: var(--radius-sm); }

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

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    padding: .55rem .8rem;
}
.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: .85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.input-icon .form-control { padding-left: 2.5rem; }

/* ---------- 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; }

/* ---------- 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 (admin) ---------- */

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

.app-topbar .brand {
    font-weight: 650;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.app-topbar .brand .bi { color: var(--primary); }

/* ---------- Cards dossier (dashboard) ---------- */

.folder-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s ease, transform .15s ease;
    height: 100%;
}
.folder-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.folder-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .8rem;
    color: var(--text-muted);
    background: var(--surface-muted);
    border-radius: 999px;
    padding: .2rem .6rem;
}

/* ---------- Tableau / listes modernes ---------- */

.table-clean { border-collapse: separate; border-spacing: 0; }
.table-clean thead th {
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding-bottom: .6rem;
}
.table-clean tbody td {
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    padding: .85rem 1rem;
}
.table-clean tbody tr td:first-child { border-left: 1px solid var(--border); border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.table-clean tbody tr td:last-child { border-right: 1px solid var(--border); border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.table-clean tbody tr { transition: background .1s ease; }
.table-clean tbody tr:hover td { background: var(--surface-muted); }

/* ---------- Liste des accès clients ---------- */

.user-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .55rem .85rem;
}
.user-chip .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 650;
    margin-right: .5rem;
}

/* ---------- Zone d'upload (drag & drop) ---------- */

.drop-zone {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-hover);
}
.drop-zone .bi { font-size: 1.8rem; display: block; margin-bottom: .5rem; }
.drop-zone input[type="file"] { display: none; }

.file-pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .75rem;
}
.file-pill {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .25rem .7rem;
    font-size: .78rem;
    color: var(--text);
}

/* ---------- Grille photos (admin) ---------- */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 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;
}
.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);
}
.category-photo-item img.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: 1.8rem;
}
.photo-tile .tile-footer {
    position: absolute;
    inset: auto 0 0 0;
    background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.6));
    padding: .5rem .6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
}
.tile-footer .tile-filename {
    color: #fff;
    font-size: .74rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tile-footer form { flex-shrink: 0; }
.tile-footer .btn-icon {
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,.9);
    color: var(--danger);
}
.tile-footer .btn-icon:hover { background: var(--danger); color: #fff; }

/* ---------- Sections / onglets ---------- */

.section-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
}
.section-title .bi { color: var(--primary); }

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

/* ---------- Modales ---------- */

.modal-content { border-radius: var(--radius-lg); border: none; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }

/* ---------- Catégories : colonne latérale ---------- */

.category-sidebar {
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}

.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 .4rem;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 650;
}

.category-filter-list {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.category-filter-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: .85rem;
    font-weight: 550;
    padding: .45rem .6rem;
    border-radius: var(--radius-sm);
    text-align: left;
    cursor: pointer;
    transition: background .12s ease;
}
.category-filter-btn:hover { background: var(--surface-muted); }
.category-filter-btn.active { background: var(--primary-soft); color: var(--primary-hover); }
.category-filter-btn.active .badge-count { background: #fff; color: var(--primary-hover); }

.category-tree { border-top: 1px solid var(--border); margin-top: .5rem; padding-top: .5rem; }

.category-group { margin-bottom: .3rem; }

.category-group-header {
    display: flex;
    align-items: center;
    gap: .25rem;
    border-radius: var(--radius-sm);
}
.category-group-header:hover { background: var(--surface-muted); }

.category-collapse-toggle {
    border: none;
    background: transparent;
    color: var(--text-muted);
    width: 22px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .15s ease;
    flex-shrink: 0;
}
.category-group.collapsed .category-collapse-toggle { transform: rotate(-90deg); }

.category-name-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: .85rem;
    font-weight: 600;
    padding: .35rem .2rem;
    text-align: left;
    cursor: pointer;
    min-width: 0;
}
.category-name-btn .category-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.category-group-header form { flex-shrink: 0; }
.category-order-actions {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.category-order-actions .btn-icon-sm {
    width: 20px;
    height: 15px;
    font-size: .65rem;
}
.category-group-header .btn-icon-sm {
    width: 26px;
    height: 26px;
    background: transparent;
    opacity: 0;
    transition: opacity .12s ease;
}
.category-group-header:hover .btn-icon-sm { opacity: 1; }
.category-group-header .btn-icon-sm:hover { background: var(--surface-muted); }
.category-group-header .btn-icon-sm.text-danger:hover { background: var(--danger-soft); }
.category-group-header .btn-icon-sm:disabled {
    opacity: .2 !important;
    cursor: default;
    pointer-events: none;
}

.category-photo-list {
    list-style: none;
    margin: 0 0 .4rem 0;
    padding: 0 0 0 1.6rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    border-radius: var(--radius-sm);
    transition: background .12s ease, outline .12s ease;
}
.category-group.collapsed .category-photo-list { display: none; }

.category-photo-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .2rem .35rem;
    border-radius: 8px;
    font-size: .76rem;
    color: var(--text-muted);
}
.category-photo-item img,
.category-photo-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.category-photo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: .75rem;
}
.category-photo-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.category-photo-empty {
    font-size: .76rem;
    font-style: italic;
    color: var(--text-muted);
    padding: .2rem .35rem;
}

.category-photo-list.drop-target-active {
    background: var(--primary-soft);
    outline: 1.5px dashed var(--primary);
}

/* ---------- Catégories : grille sectionnée + sélection ---------- */

.bulk-assign-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    background: var(--primary-soft);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: .6rem .8rem;
    margin-bottom: 1rem;
    position: sticky;
    top: 80px;
    z-index: 5;
}

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

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

.photo-tile.selected {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.tile-select {
    position: absolute;
    top: .4rem;
    left: .4rem;
    z-index: 2;
    cursor: pointer;
}
.tile-select .tile-checkbox {
    position: absolute;
    opacity: 0;
    width: 22px;
    height: 22px;
    margin: 0;
    cursor: pointer;
}
.tile-select-mark {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(255,255,255,.85);
    border: 1.5px solid rgba(0,0,0,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.tile-select .tile-checkbox:checked ~ .tile-select-mark {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.photo-tile[draggable="true"] { cursor: grab; }
.photo-tile[draggable="true"]:active { cursor: grabbing; }
