/**
 * ClipDeck — Styles pour l'administration & l'authentification.
 * Partagé par login.php, register.php, admin.php.
 */
:root {
  --bg: #08080d; --bg2: #0c0c13; --surface: #12121a; --surface2: #1a1a24;
  --border: #23232e; --border2: #32323f;
  --text: #f2f2f6; --muted: #9d9dab; --dim: #5f5f6c;
  --purple: #9147ff; --purple2: #772ce8; --purple-light: #bf94ff;
  --purple-glow: rgba(145, 71, 255, 0.35); --purple-dark: rgba(145, 71, 255, 0.13);
  --grad: linear-gradient(135deg, #a970ff 0%, #772ce8 100%);
  --green: #57e08f; --red: #ff6b6b; --gold: #ffd166; --hot: #ff8a3d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); }

body {
  background:
    radial-gradient(1000px 500px at 75% -10%, rgba(119, 44, 232, 0.13), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(145, 71, 255, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--purple-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Pages de connexion / inscription --- */
.auth-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem; }
.auth-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; width: 380px; max-width: 95vw; box-shadow: 0 10px 50px rgba(0,0,0,0.5); }
.auth-box h1 { font-size: 22px; font-weight: 800; margin: 0 0 .25rem; display: flex; align-items: center; gap: 8px; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-box p.sub { color: var(--muted); font-size: 13px; margin: 0 0 1.5rem; }
.auth-box label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.auth-box input { width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px; color: var(--text); font-size: 16px; outline: none; margin-bottom: 1rem; transition: border-color 0.15s, box-shadow 0.15s; }
.auth-box input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-dark); }
.auth-box button { width: 100%; background: var(--grad); color: #fff; border: none; border-radius: 8px; padding: 12px; font-size: 14px; font-weight: 700; cursor: pointer; transition: filter 0.15s, transform 0.15s; box-shadow: 0 4px 18px var(--purple-glow); }
.auth-box button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.auth-box .msg { font-size: 13px; margin-bottom: 1rem; padding: 10px 12px; border-radius: 8px; border: 1px solid; }
.auth-box .msg.err { color: var(--red); background: rgba(255,107,107,0.08); border-color: rgba(255,107,107,0.2); }
.auth-box .msg.ok { color: var(--green); background: rgba(87,224,143,0.08); border-color: rgba(87,224,143,0.2); }
.auth-box .foot-link { display: block; text-align: center; font-size: 13px; margin-top: 1rem; color: var(--muted); }
.auth-box .foot-link:hover { color: var(--purple-light); }

/* --- Page Admin --- */
.top { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface2); position: sticky; top: 0; z-index: 10; min-height: 52px; }
.brand { font-weight: 800; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.brand svg { color: var(--purple); filter: drop-shadow(0 0 6px var(--purple-glow)); -webkit-text-fill-color: var(--purple); }
.top .sp { flex: 1; }
.who { font-size: 13px; color: var(--muted); }
.pill { font-family: ui-monospace, Menlo, monospace; font-size: 11px; background: var(--purple-dark); color: var(--purple-light); padding: 2px 8px; border-radius: 10px; text-transform: uppercase; }
.btn { background: var(--grad); color: #fff; border: none; border-radius: 6px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; transition: filter 0.15s; }
.btn:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--purple); background: var(--purple-dark); text-decoration: none; }
.btn-danger { background: transparent; border: 1px solid rgba(255,107,107,0.2); color: var(--red); padding: 5px 10px; font-size: 12px; border-radius: 5px; cursor: pointer; }
.btn-danger:hover { background: rgba(255,107,107,0.08); border-color: var(--red); text-decoration: none; }
.wrap { max-width: 960px; margin: 0 auto; padding: 28px 24px 60px; }
.wrap.wide { max-width: 1180px; }

h2 { font-size: 20px; margin-bottom: 4px; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 22px; }
.card h3 { font-size: 15px; margin-bottom: 14px; }
.grid { display: grid; gap: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.fld { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 150px; }
.fld label { font-size: 11px; color: var(--muted); }
input, select { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; color: var(--text); font-size: 13px; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
input:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-dark); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--surface2); }

.role { font-family: ui-monospace, Menlo, monospace; font-size: 11px; padding: 1px 7px; border-radius: 8px; }
.role.admin { background: rgba(255,194,75,0.1); color: #ffc24b; }
.role.clipper { background: rgba(75,208,194,0.1); color: #4bd0c2; }
.role.superadmin { background: var(--purple-dark); color: var(--purple-light); }
.flash { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 18px; }
.flash.ok { background: rgba(87,224,143,0.08); color: var(--green); border: 1px solid rgba(87,224,143,0.2); }
.flash.ko { background: rgba(255,107,107,0.08); color: var(--red); border: 1px solid rgba(255,107,107,0.2); }
.inline { display: inline; }
.empty { color: var(--dim); font-size: 13px; padding: 12px 0; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 12px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.kpi .v { font-size: 26px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; line-height: 1.1; }
.kpi .l { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.alt .v { background: linear-gradient(135deg, var(--hot), #ff5252); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* Charts */
.charts-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media(max-width:900px){.charts-2{grid-template-columns:1fr;}}
.chart { width: 100%; height: auto; display: block; }
.chart .cx { fill: var(--dim); font-size: 10px; }
.chart .cy { fill: var(--text); font-size: 12px; }
.chart .cv { fill: var(--purple-light); font-size: 11px; font-weight: 700; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sub-h { font-size: 12px; color: var(--dim); font-weight: 400; margin-left: 6px; }

/* --- Section header (org title, back link) --- */
.section-header { margin-bottom: 4px; }
.section-header h2 { margin-bottom: 2px; }
.section-header .muted { margin-bottom: 0; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; transition: color 0.15s; }
.back-link:hover { color: var(--purple-light); text-decoration: none; }

/* --- Tabs --- */
.tabs-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 52px; /* matches .top min-height */
  z-index: 9;
  scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.tab-btn:hover { background: var(--surface); }
.tab-btn.active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px var(--purple-glow);
}
.tab-content {
  display: none;
  animation: fadeIn 0.25s ease;
}
.tab-content.active {
  display: block;
}
.tab-content > .card:first-child,
.tab-content > .kpis:first-child,
.tab-content > h2:first-child { margin-top: 0; }
.tab-content > h2 { margin-top: 4px; }
.tab-content > .muted { margin-bottom: 16px; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Modal --- */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 360px;
  max-width: 90vw;
  transform: translateY(10px);
  transition: transform 0.2s;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal h3 { margin-bottom: 12px; font-size: 16px; }
.modal .row { justify-content: flex-end; margin-top: 16px; }

@media(max-width:700px){
  html { -webkit-text-size-adjust: 100%; }
  body { padding-bottom: env(safe-area-inset-bottom); }
  .auth-page { min-height: 100dvh; padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom)); }
  .auth-box { padding: 1.5rem 1.15rem; width: 100%; }
  .top { padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); gap: 8px; flex-wrap: wrap; min-height: auto; }
  .top .who { display: none; }
  .tabs-nav { position: sticky; top: 0; padding: 10px 14px; gap: 6px; }
  .tab-btn { padding: 10px 14px; font-size: 13px; min-height: 40px; }
  .wrap { padding: 16px 12px 50px; }
  .card { padding: 14px; }
  .row { flex-direction: column; align-items: stretch; gap: 12px; }
  .modal .row { flex-direction: row; }
  .fld { min-width: 0; }
  input,select { font-size: 16px; padding: 10px; } /* évite le zoom auto iOS */
  .btn { padding: 12px 14px; min-height: 44px; }
  .tablewrap { border: 1px solid var(--border); border-radius: 8px; }
  table { font-size: 12.5px; min-width: 600px; }
  th, td { padding: 10px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .v { font-size: 22px; }
  .modal { width: 100%; max-width: none; margin: 0 12px; padding: 18px; }
}