/* =====================================================================
   RDV MAJUNGA - Feuille de style de l'administration
   ---------------------------------------------------------------------
   Interface de gestion : volontairement sobre, dense et lisible,
   pensee pour un usage quotidien sur ordinateur comme sur tablette.

     1.  Variables et base
     2.  Structure (menu lateral + contenu)
     3.  En-tete de page
     4.  Cartes et panneaux
     5.  Chiffres du tableau de bord
     6.  Tableaux
     7.  Formulaires
     8.  Boutons et etiquettes
     9.  Photos
    10.  Connexion
    11.  Responsive
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. VARIABLES ET BASE
   ------------------------------------------------------------------ */
:root {
    --ocean-900: #06323a;
    --ocean-800: #0a4550;
    --ocean-700: #0d5d6b;
    --ocean-600: #117285;
    --ocean-100: #e2f1f4;

    --sun-600: #c96f1c;
    --sun-500: #e0872c;
    --sun-100: #fdf0e0;

    --palm-700: #1c6b4d;
    --palm-100: #e4f2ea;

    --ink: #142a31;
    --ink-soft: #3f5a63;
    --muted: #7b8f97;

    --bg: #f2f5f6;
    --white: #ffffff;
    --line: #e2e8ea;
    --line-strong: #cfd9dc;

    --danger: #b4362f;
    --danger-100: #fbe9e7;

    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 252px;

    --shadow-sm: 0 1px 2px rgba(6, 50, 58, .05), 0 2px 6px rgba(6, 50, 58, .05);
    --shadow-md: 0 6px 20px rgba(6, 50, 58, .1);
    --transition: 180ms ease;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink-soft);
    background: var(--bg);
}

h1, h2, h3, h4 { color: var(--ocean-900); margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--ocean-700); text-decoration: none; }
a:hover { color: var(--sun-600); }

img { max-width: 100%; display: block; }

:focus-visible { outline: 3px solid var(--sun-500); outline-offset: 2px; border-radius: 4px; }

.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.28em; }
.icon-sm { width: 1em; height: 1em; }
.icon-lg { width: 1.7em; height: 1.7em; }

.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------------
   2. STRUCTURE
   ------------------------------------------------------------------ */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: linear-gradient(180deg, var(--ocean-800), var(--ocean-900));
    color: rgba(255, 255, 255, .72);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    transition: transform var(--transition);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    color: #fff;
}
.sidebar__brand .mark {
    width: 42px;
    height: 42px;
    flex: none;
    object-fit: contain;
    padding: 4px;
    border-radius: 11px;
    background: #fff;
}
.sidebar__brand strong { display: block; font-size: .98rem; color: #fff; }
.sidebar__brand small {
    font-size: .7rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .55);
}

.sidebar nav { padding: 16px 12px; overflow-y: auto; flex: 1; }
.sidebar__label {
    padding: 14px 10px 6px;
    font-size: .68rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .38);
}
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, .76);
    font-size: .92rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.sidebar nav a.active { background: var(--ocean-600); color: #fff; font-weight: 600; }
.sidebar nav a .count {
    margin-left: auto;
    background: var(--sun-500);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 999px;
}
.sidebar__footer {
    padding: 14px 16px 18px;
    border-top: 1px solid rgba(255, 255, 255, .1);
    font-size: .85rem;
}
.sidebar__footer a { color: rgba(255, 255, 255, .7); display: flex; align-items: center; gap: 9px; padding: 6px 0; }
.sidebar__footer a:hover { color: #fff; }

.admin-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    padding: 0 26px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar__user { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.topbar__avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--ocean-100);
    color: var(--ocean-800);
    font-weight: 700;
    font-size: .82rem;
}
.topbar__user strong { display: block; color: var(--ocean-900); font-size: .9rem; line-height: 1.2; }
.topbar__user span { color: var(--muted); font-size: .78rem; }

.sidebar-toggle {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    background: var(--white);
    border-radius: var(--radius-sm);
    color: var(--ink);
    cursor: pointer;
}

.admin-content { padding: 26px; flex: 1; }
.admin-content > *:last-child { margin-bottom: 0; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 50, 58, .5);
    z-index: 55;
}
.sidebar-backdrop.is-open { display: block; }

/* ---------------------------------------------------------------------
   3. EN-TETE DE PAGE
   ------------------------------------------------------------------ */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-head h1 { margin-bottom: 4px; }
.page-head p { color: var(--muted); font-size: .92rem; margin: 0; }
.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Messages */
.alert {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    margin-bottom: 20px;
    font-size: .92rem;
}
.alert-success { background: var(--palm-100); border-color: #bcdfcd; color: #14503a; }
.alert-error   { background: var(--danger-100); border-color: #f0c4c0; color: #8a2b25; }
.alert-info    { background: var(--ocean-100); border-color: #bfdfe6; color: var(--ocean-800); }

/* ---------------------------------------------------------------------
   4. CARTES ET PANNEAUX
   ------------------------------------------------------------------ */
.panel {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 22px;
    overflow: hidden;
}
.panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    background: #fafcfc;
}
.panel__head h2 { margin: 0; font-size: 1.02rem; }
.panel__body { padding: 20px; }
.panel__body > *:last-child { margin-bottom: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; align-items: start; }
.split-70-30 { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }

.empty-state {
    text-align: center;
    padding: 46px 20px;
    color: var(--muted);
}
.empty-state .icon { width: 44px; height: 44px; color: var(--line-strong); margin-bottom: 12px; }

/* ---------------------------------------------------------------------
   5. CHIFFRES DU TABLEAU DE BORD
   ------------------------------------------------------------------ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card__icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--ocean-100);
    color: var(--ocean-700);
    flex: none;
}
.stat-card__icon.is-warning { background: var(--sun-100); color: var(--sun-600); }
.stat-card__icon.is-success { background: var(--palm-100); color: var(--palm-700); }
.stat-card__icon.is-danger  { background: var(--danger-100); color: var(--danger); }
.stat-card strong {
    display: block;
    font-size: 1.65rem;
    line-height: 1.1;
    color: var(--ocean-900);
}
.stat-card span { font-size: .82rem; color: var(--muted); }

/* ---------------------------------------------------------------------
   6. TABLEAUX
   ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
table.data th,
table.data td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data thead th {
    background: #fafcfc;
    color: var(--ocean-900);
    font-size: .74rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-weight: 700;
    white-space: nowrap;
}
table.data tbody tr:hover { background: #fafcfc; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td strong { color: var(--ocean-900); }
table.data .thumb {
    width: 56px;
    height: 42px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
}
table.data .ref,
.ref {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .84rem;
    color: var(--ocean-800);
    font-weight: 600;
    white-space: nowrap;
}
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.pagination {
    display: flex;
    gap: 6px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    align-items: center;
    flex-wrap: wrap;
}
.pagination a,
.pagination span {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-size: .87rem;
    color: var(--ink-soft);
}
.pagination a:hover { border-color: var(--ocean-600); color: var(--ocean-700); }
.pagination .is-current { background: var(--ocean-700); border-color: var(--ocean-700); color: #fff; font-weight: 600; }
.pagination .info { border: 0; background: none; color: var(--muted); margin-left: auto; }

/* ---------------------------------------------------------------------
   7. FORMULAIRES
   ------------------------------------------------------------------ */
.field { margin-bottom: 16px; }
.field label,
.form-label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--ocean-900);
    margin-bottom: 6px;
}
.field .hint { display: block; font-size: .79rem; color: var(--muted); margin-top: 5px; }
.required { color: var(--danger); }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="url"],
input[type="search"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    font: inherit;
    font-size: .92rem;
    color: var(--ink);
    background: var(--white);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
input[type="file"] { padding: 8px; background: #fafcfc; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--ocean-600);
    box-shadow: 0 0 0 3px rgba(17, 114, 133, .13);
}
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--danger); background: #fffafa; }
.field-error { display: block; color: var(--danger); font-size: .8rem; margin-top: 5px; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.form-row .full, .form-row-3 .full { grid-column: 1 / -1; }

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
}
.checkbox-line {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: .88rem;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.checkbox-line:hover { border-color: var(--ocean-600); }
.checkbox-line input { width: 17px; height: 17px; accent-color: var(--ocean-700); flex: none; margin: 0; }
.checkbox-line input:checked + span { color: var(--ocean-900); font-weight: 600; }

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 18px;
    margin-top: 4px;
    border-top: 1px solid var(--line);
}

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.toolbar .field { margin-bottom: 0; min-width: 160px; }
.toolbar .field.grow { flex: 1; min-width: 220px; }

/* ---------------------------------------------------------------------
   8. BOUTONS ET ETIQUETTES
   ------------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 17px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition), box-shadow var(--transition);
    white-space: nowrap;
}
.btn-primary { background: var(--ocean-700); color: #fff; }
.btn-primary:hover { background: var(--ocean-800); color: #fff; }
.btn-sun { background: var(--sun-500); color: #fff; }
.btn-sun:hover { background: var(--sun-600); color: #fff; }
.btn-success { background: var(--palm-700); color: #fff; }
.btn-success:hover { background: #14513a; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #93281f; color: #fff; }
.btn-ghost { background: var(--white); border-color: var(--line-strong); color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--ocean-600); color: var(--ocean-700); }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-icon { padding: 7px; width: 34px; height: 34px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    background: var(--ocean-100);
    color: var(--ocean-800);
    white-space: nowrap;
}
.badge-success { background: var(--palm-100); color: var(--palm-700); }
.badge-warning { background: var(--sun-100); color: var(--sun-600); }
.badge-danger  { background: var(--danger-100); color: var(--danger); }
.badge-muted   { background: #eceff0; color: var(--muted); }
.badge-info    { background: var(--ocean-100); color: var(--ocean-700); }

/* ---------------------------------------------------------------------
   9. PHOTOS
   ------------------------------------------------------------------ */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
}
.photo-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--white);
    display: flex;
    flex-direction: column;
}
.photo-card__media { aspect-ratio: 4 / 3; background: #eceff0; position: relative; }
.photo-card__media img { width: 100%; height: 100%; object-fit: cover; }
.photo-card__flag {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--sun-500);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
}
.photo-card__body { padding: 12px 13px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.photo-card__body strong { font-size: .88rem; color: var(--ocean-900); }
.photo-card__body small { color: var(--muted); font-size: .78rem; }
.photo-card__actions { margin-top: auto; display: flex; gap: 6px; }

.preview-thumb {
    width: 100%;
    max-width: 260px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    margin-bottom: 10px;
}

/* ---------------------------------------------------------------------
   10. CONNEXION
   ------------------------------------------------------------------ */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 20%, rgba(17, 114, 133, .22), transparent 45%),
        radial-gradient(circle at 85% 75%, rgba(224, 135, 44, .2), transparent 45%),
        linear-gradient(160deg, var(--ocean-800), var(--ocean-900));
}
.login-card {
    width: 100%;
    max-width: 410px;
    background: var(--white);
    border-radius: 18px;
    padding: 34px 32px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, .3);
}
.login-card__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.login-card__brand .mark {
    width: 52px;
    height: 52px;
    flex: none;
    object-fit: contain;
    padding: 4px;
    border-radius: 13px;
    background: var(--ocean-100);
}
.login-card__brand strong { display: block; color: var(--ocean-900); font-size: 1.05rem; }
.login-card__brand small { color: var(--muted); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.login-card h1 { font-size: 1.28rem; margin-bottom: 6px; }
.login-card > p { color: var(--muted); font-size: .9rem; }
.login-footer {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: .85rem;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.login-hint {
    margin-top: 18px;
    padding: 12px 14px;
    background: var(--ocean-100);
    border-radius: var(--radius-sm);
    font-size: .83rem;
    color: var(--ocean-800);
}

/* ---------------------------------------------------------------------
   11. RESPONSIVE
   ------------------------------------------------------------------ */
/* ---------------------------------------------------------------------
   11 bis. ENTREES ANIMEES
   Discretes : l'administration est un outil de travail, elle doit
   rester rapide a lire. Aucune animation ne depasse une demi-seconde.
   ------------------------------------------------------------------ */
@keyframes adminIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

.page-head,
.stat-card,
.panel { animation: adminIn 420ms cubic-bezier(.22, .78, .3, 1) both; }

.stat-grid .stat-card:nth-child(1) { animation-delay: 40ms; }
.stat-grid .stat-card:nth-child(2) { animation-delay: 90ms; }
.stat-grid .stat-card:nth-child(3) { animation-delay: 140ms; }
.stat-grid .stat-card:nth-child(4) { animation-delay: 190ms; }

.admin-content > .panel:nth-of-type(2) { animation-delay: 90ms; }
.admin-content > .panel:nth-of-type(3) { animation-delay: 140ms; }

/* Reflet sur les boutons pleins, comme sur le site public */
.btn-primary, .btn-sun, .btn-success, .btn-danger { position: relative; overflow: hidden; }
.btn-primary::after, .btn-sun::after, .btn-success::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 -140%;
    width: 55%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .3), transparent);
    transform: skewX(-18deg);
    transition: left 620ms cubic-bezier(.22, .78, .3, 1);
}
.btn-primary:hover::after, .btn-sun:hover::after, .btn-success:hover::after { left: 140%; }

/* Le menu lateral souligne la page courante */
.sidebar nav a { position: relative; }
.sidebar nav a.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--sun-500);
}

/* Les lignes de tableau se teintent au survol */
table.data tbody tr { transition: background 160ms ease; }

@media (prefers-reduced-motion: reduce) {
    .page-head, .stat-card, .panel { animation: none; }
    .btn-primary::after, .btn-sun::after, .btn-success::after { display: none; }
}

@media (max-width: 1180px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .split-70-30 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-md); }
    .admin-main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .admin-content { padding: 18px 14px; }
    .topbar { padding: 0 14px; }
    .stat-grid { grid-template-columns: 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .page-head { align-items: flex-start; }
}
