/* ============================================================
   ADMIN.CSS  —  apparence de l'interface admin KooMinNy
   ============================================================ */

/* ---- 1. VARIABLES (mêmes couleurs de marque) ---- */
:root{
  --marine-1:#070C1C; --marine-2:#0A1B3D;
  --blue:#0088F0; --blue-2:#1A7FF0; --accent:#3DA6FF;
  --card:#FFFFFF; --ink:#0E1726; --muted:#64748B; --line:#EAEFF7;
  --app:#EEF3FA;
  --danger:#DC2626; --ok:#15803D; --warn:#B45309;
  --radius:18px;
}

*{ box-sizing:border-box; margin:0; padding:0; }
html,body{ min-height:100%; }
body{
  font-family:'Inter', system-ui, -apple-system, sans-serif;
  color:var(--ink);
  background:radial-gradient(120% 75% at 50% 0%, #11305f 0%, var(--marine-2) 44%, var(--marine-1) 100%);
  -webkit-font-smoothing:antialiased;
}


/* ============================================================
   VUE 1 — CONNEXION
   ============================================================ */
.login-wrap{ min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:24px 20px; }
.login-card{ width:100%; max-width:380px; background:var(--card); border-radius:var(--radius); padding:30px 26px 28px; box-shadow:0 26px 60px -22px rgba(0,28,80,.6); }
.brand{ display:flex; align-items:center; justify-content:center; gap:9px; margin-bottom:18px; }
.brand-logo{ height:26px; width:auto; }
.wordmark{ font-family:'Space Grotesk',sans-serif; font-size:18px; color:var(--blue); }
.wordmark b{ color:var(--ink); font-weight:700; }
.title{ font-family:'Space Grotesk',sans-serif; font-size:22px; text-align:center; }
.subtitle{ text-align:center; color:var(--muted); font-size:14px; margin-top:4px; margin-bottom:20px; }
.form{ display:flex; flex-direction:column; gap:14px; }

/* Champs de saisie (réutilisés AUSSI dans le tableau de bord) */
.field{ display:flex; flex-direction:column; gap:6px; }
.lbl{ font-size:12px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; }
.field input{
  height:46px; padding:0 14px;
  border:1px solid var(--line); border-radius:12px;
  font-size:15px; font-family:inherit; color:var(--ink);
  outline:none; transition:border-color .15s ease, box-shadow .15s ease;
}
.field input:focus{ border-color:var(--blue); box-shadow:0 0 0 3px rgba(0,136,240,.15); }

.error{ color:var(--danger); font-size:13px; font-weight:500; text-align:center; }

/* Bouton principal (réutilisé partout) */
.cta{
  height:50px; border:0; border-radius:13px; cursor:pointer;
  font-family:'Space Grotesk',sans-serif; font-size:16px; font-weight:600; color:#fff;
  background:linear-gradient(135deg,var(--blue),var(--blue-2));
  box-shadow:0 14px 26px -12px rgba(0,136,240,.7);
  transition:transform .12s ease, opacity .12s ease;
}
.cta:hover{ transform:translateY(-1px); }
.cta:active{ transform:translateY(1px); }
.cta:disabled{ opacity:.6; cursor:default; transform:none; }

.foot{ margin-top:18px; text-align:center; }
.wordmark.sm{ font-size:13px; }
.foot .wordmark{ color:#9fb4d4; }
.foot .wordmark b{ color:#fff; }


/* ============================================================
   VUE 2 — TABLEAU DE BORD
   ============================================================ */
.admin{ min-height:100vh; background:var(--app); }

.topbar{
  background:#fff; border-bottom:1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 20px; position:sticky; top:0; z-index:5;
}
.topbar .wordmark{ font-size:17px; }
.tag{ font-family:'Inter',sans-serif; font-size:11px; font-weight:600; color:var(--blue); background:#EAF3FF; padding:2px 8px; border-radius:999px; vertical-align:middle; margin-left:4px; }
.topbar-right{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.who{ font-size:13px; color:var(--muted); }

/* Menu de navigation (Clients / Statistiques) dans la barre du haut */
.nav{ display:flex; gap:4px; background:#F1F5FB; padding:4px; border-radius:11px; }
.nav-btn{
  border:0; background:transparent; cursor:pointer;
  font-family:'Inter',sans-serif; font-size:13px; font-weight:600; color:var(--muted);
  padding:7px 13px; border-radius:8px; transition:background .12s ease, color .12s ease;
}
.nav-btn.active{ background:#fff; color:var(--blue); box-shadow:0 1px 2px rgba(0,0,0,.06); }

/* Bouton secondaire "fantôme" (contour) */
.btn-ghost{
  border:1px solid var(--line); background:#fff; color:var(--ink);
  font-family:'Inter',sans-serif; font-size:13px; font-weight:600;
  padding:8px 14px; border-radius:10px; cursor:pointer; transition:background .12s ease;
}
.btn-ghost:hover{ background:#F4F7FC; }

.admin-main{ max-width:1140px; margin:0 auto; padding:26px 20px; }

/* Écran "Clients" en deux colonnes : formulaire (gauche) + liste (droite) */
.two-col{ display:grid; grid-template-columns:1.4fr 1fr; gap:20px; align-items:start; }
@media (max-width:980px){ .two-col{ grid-template-columns:1fr; } }

/* Panneaux blancs */
.panel{ background:#fff; border:1px solid var(--line); border-radius:var(--radius); padding:22px; margin-bottom:20px; }
.panel-title{ font-family:'Space Grotesk',sans-serif; font-size:18px; }
.panel-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }

/* Formulaire de création : grille 2 colonnes */
.grid{ display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-top:14px; }
.form-section{ grid-column:1 / -1; font-size:12px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; margin-top:8px; padding-top:14px; border-top:1px solid var(--line); }
.photo-field{ grid-column:1 / -1; flex-direction:row; align-items:center; gap:16px; }
.photo-preview{
  width:64px; height:64px; flex:none; border-radius:50%;
  background:#F0F6FF; background-size:cover; background-position:center;
  border:1px dashed #C7D6EC; color:#9DB2CE;
  display:flex; align-items:center; justify-content:center; font-size:11px; text-align:center;
}
.photo-preview.has{ border-style:solid; border-color:var(--line); color:transparent; }
.photo-input{ flex:1; display:flex; flex-direction:column; gap:6px; }
.photo-input input[type=file]{ font-size:13px; color:var(--muted); }
.hint-sm{ font-size:12px; color:var(--muted); }
.form-foot{ grid-column:1 / -1; display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap; }
.form-foot .cta{ min-width:180px; padding:0 22px; }

/* Messages succès / erreur */
.msg{ font-size:14px; font-weight:500; }
.msg.ok{ color:var(--ok); }
.msg.err{ color:var(--danger); }

/* Liste des clients */
.list{ display:flex; flex-direction:column; }
.empty{ color:var(--muted); font-size:14px; padding:10px 2px; }
.client-row{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; padding:14px 4px; border-top:1px solid var(--line); }
.client-row:first-child{ border-top:0; }
.ava-sm{
  width:42px; height:42px; flex:none; border-radius:50%;
  background:linear-gradient(135deg,var(--blue),var(--blue-2)); color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-family:'Space Grotesk',sans-serif; font-weight:600; font-size:15px;
}
.client-info{ flex:1 1 140px; min-width:0; }
.client-name{ font-weight:600; font-size:15px; }
.client-sub{ display:flex; align-items:center; gap:8px; margin-top:3px; }
.code{ font-family:ui-monospace,Menlo,Consolas,monospace; font-size:12px; color:var(--muted); background:#F4F7FC; padding:2px 7px; border-radius:6px; }
.badge{ font-size:11px; font-weight:600; padding:2px 9px; border-radius:999px; }
.badge.on{ color:var(--ok); background:#E7F8EE; }
.badge.off{ color:var(--warn); background:#FEF4E6; }
.row-actions{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-left:auto; }
.link-btn{ font-size:13px; font-weight:600; color:var(--blue-2); text-decoration:none; padding:8px 12px; border:1px solid var(--line); border-radius:10px; }
.link-btn:hover{ background:#F4F7FC; }

/* Petit écran : formulaire en 1 colonne */
@media (max-width:560px){
  .grid{ grid-template-columns:1fr; }
  .form-foot .cta{ width:100%; }
}

/* ---- Statistiques : grands chiffres (KPI) + graphiques ---- */
.kpi-grid{ display:grid; grid-template-columns:repeat(auto-fit, minmax(150px,1fr)); gap:14px; margin-bottom:20px; }
.kpi{ background:#fff; border:1px solid var(--line); border-radius:16px; padding:18px 20px; }
.kpi-num{ font-family:'Space Grotesk',sans-serif; font-size:30px; font-weight:700; line-height:1; color:var(--ink); }
.kpi-lbl{ font-size:13px; color:var(--muted); margin-top:6px; }
.charts-grid{ display:grid; grid-template-columns:1fr 1fr; gap:20px; }
@media (max-width:760px){ .charts-grid{ grid-template-columns:1fr; } }
.chart-box{ position:relative; height:280px; margin-top:8px; }

/* ---- Fenêtre modale "Modifier un client" ---- */
.overlay{
  position:fixed; inset:0; z-index:50;
  background:rgba(8,18,38,.55);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.modal{
  background:#fff; border-radius:var(--radius); width:100%; max-width:680px;
  max-height:90vh; display:flex; flex-direction:column; overflow:hidden;
  box-shadow:0 30px 70px -20px rgba(0,20,60,.5);
}
.modal-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding:18px 22px; border-bottom:1px solid var(--line); }
.modal-x{ border:0; background:transparent; font-size:18px; color:var(--muted); cursor:pointer; line-height:1; padding:4px 8px; }
.modal-body{ padding:20px 22px; overflow-y:auto; }
.modal-foot{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 22px; border-top:1px solid var(--line); }
.modal-foot-right{ display:flex; gap:10px; }
.modal-foot .cta{ min-width:150px; padding:0 22px; }

/* Bouton danger (Supprimer) */
.btn-danger{
  border:1px solid #F3C6C6; background:#fff; color:var(--danger);
  font-family:'Inter',sans-serif; font-size:13px; font-weight:600;
  padding:11px 16px; border-radius:10px; cursor:pointer; transition:background .12s ease;
}
.btn-danger:hover{ background:#FEF2F2; }

/* Petit lien "Retirer la photo" */
.link-mini{ border:0; background:transparent; color:var(--blue-2); font-size:12px; font-weight:600; cursor:pointer; padding:0; text-align:left; }
.link-mini:hover{ text-decoration:underline; }

/* Bouton "Modifier" dans la liste (réutilisé aussi par "Copier l'URL") */
.btn-mini{
  border:1px solid var(--line); background:#fff; color:var(--ink);
  font-family:'Inter',sans-serif; font-size:13px; font-weight:600;
  padding:8px 12px; border-radius:10px; cursor:pointer;
}
.btn-mini:hover{ background:#F4F7FC; }

/* Badge "●Carte" cliquable (vert = UID enregistré, orange = pas encore) */
.badge-btn{
  border:0; cursor:pointer; font-family:'Inter',sans-serif;
  font-size:11px; font-weight:600; padding:7px 11px; border-radius:999px;
  transition:filter .12s ease, transform .12s ease;
}
.badge-btn:hover{ filter:brightness(.95); }
.badge-btn:active{ transform:translateY(1px); }
.badge-btn.on{  color:var(--ok);   background:#E7F8EE; }
.badge-btn.off{ color:var(--warn); background:#FEF4E6; }

/* Petite modale "Carte NFC" (UID) : plus étroite que la modale Modifier */
.modal-sm{ max-width:420px; }
/* Message de succès de la fenêtre Carte (✓ au-dessus, centré) */
.uid-ok{ text-align:center; }
.uid-ok-emoji{ display:block; font-size:30px; line-height:1; margin-bottom:4px; }

/* Bouton de thème 🌙/☀️ dans la barre du haut */
.theme-btn{ padding:8px 10px; font-size:15px; line-height:1; }

/* Outil : cacher un élément (le JS bascule cette classe) */
.hidden{ display:none !important; }

/* ============================================================
   MODE SOMBRE (admin) — activé par la classe .dark sur <html>
   On redéfinit les variables + on couvre les surfaces "en dur".
   ============================================================ */
html.dark{
  --app:#0B1324;     /* fond général */
  --card:#131F38;    /* panneaux, barre, fenêtres */
  --ink:#E8EEF7;     /* texte principal */
  --muted:#9AACC6;   /* texte secondaire */
  --line:#243349;    /* lignes et bordures */
}
html.dark .topbar{ background:var(--card); border-bottom-color:var(--line); }
html.dark .tag{ background:rgba(0,136,240,.18); }
html.dark .nav{ background:#0E1A30; }
html.dark .nav-btn.active{ background:var(--card); box-shadow:none; }
html.dark .btn-ghost{ background:var(--card); }
html.dark .btn-ghost:hover{ background:#1B2A47; }
html.dark .btn-mini{ background:var(--card); }
html.dark .btn-mini:hover,
html.dark .link-btn:hover{ background:#1B2A47; }
html.dark .panel{ background:var(--card); }
html.dark .kpi{ background:var(--card); }
html.dark .login-card{ background:var(--card); }
html.dark .modal{ background:var(--card); }
html.dark .code{ background:#0E1A30; }
html.dark .field input:not([type=file]){ background:#0E1A30; color:var(--ink); }
html.dark .field input::placeholder{ color:#6B7C97; }
html.dark .photo-preview{ background:#0E1A30; border-color:#2A3A55; color:#7E90AC; }
html.dark .badge.on,  html.dark .badge-btn.on{  background:rgba(34,197,94,.16);  color:#4ADE80; }
html.dark .badge.off, html.dark .badge-btn.off{ background:rgba(245,158,11,.16); color:#FBBF24; }
html.dark .msg.ok{ color:#4ADE80; }
html.dark .msg.err{ color:#F87171; }
html.dark .btn-danger{ background:var(--card); border-color:#5B2A2A; }
html.dark .btn-danger:hover{ background:#3A1E1E; }