/* ── Reset ── */
* { box-sizing: border-box; }

/* ── Design tokens ── */
:root {
  --bg:          #0e0e12;
  --bg-2:        #16161c;
  --bg-3:        #1e1e28;
  --border:      #2a2a38;
  --text:        #eeeef2;
  --muted:       #7c7c96;
  --faint:       #3a3a52;
  --accent:      #6366f1;
  --accent-dim:  rgba(99,102,241,0.12);
  --accent-glow: rgba(99,102,241,0.25);
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600; font-size: 13px;
  padding: 9px 18px; border-radius: 8px;
  border: none; cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.btn-primary:active { opacity: 0.8; }

.btn-ghost {
  background: transparent; color: var(--muted);
  font-size: 13px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--faint); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 5px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em;
}
.badge            { background: rgba(99,102,241,0.12); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.2); }
.badge-Travail    { background: rgba(59,130,246,0.12);  color: #93c5fd;  border: 1px solid rgba(59,130,246,0.2); }
.badge-Code       { background: rgba(16,185,129,0.12);  color: #6ee7b7;  border: 1px solid rgba(16,185,129,0.2); }
.badge-Loisirs    { background: rgba(245,158,11,0.12);  color: #fcd34d;  border: 1px solid rgba(245,158,11,0.2); }
.badge-Marketing  { background: rgba(251,146,60,0.12);  color: #fdba74;  border: 1px solid rgba(251,146,60,0.2); }
.badge-Écriture   { background: rgba(236,72,153,0.12);  color: #f9a8d4;  border: 1px solid rgba(236,72,153,0.2); }
.badge-Design     { background: rgba(168,85,247,0.12);  color: #d8b4fe;  border: 1px solid rgba(168,85,247,0.2); }
.badge-SEO        { background: rgba(20,184,166,0.12);  color: #5eead4;  border: 1px solid rgba(20,184,166,0.2); }
.badge-active     { background: rgba(34,197,94,0.12);   color: #4ade80;  border: 1px solid rgba(34,197,94,0.2); }
.badge-banned     { background: rgba(239,68,68,0.12);   color: #f87171;  border: 1px solid rgba(239,68,68,0.2); }
.badge-inactive   { background: rgba(100,116,139,0.1);  color: var(--muted); border: 1px solid var(--border); }
.badge-mod        { background: var(--accent-dim); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.2); }
.badge-featured   { background: rgba(250,204,21,0.12);  color: #fbbf24;  border: 1px solid rgba(250,204,21,0.2); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  z-index: 70; display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97) }
  to   { opacity: 1; transform: scale(1) }
}

/* ── Loading spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { animation: spin 1s linear infinite; }


/* ── Reset ── */
    * { box-sizing: border-box; }

    body {
      font-family: 'Inter', sans-serif;
      background: var(--bg);
      color: var(--text);
      overflow: hidden;
    }

    ::-webkit-scrollbar-thumb:hover { background: var(--muted); }

    /* ── Login Screen ── */
    #login-screen { background: var(--bg); }

    /* ── Sidebar ── */
    #sidebar {
      background: var(--bg-2);
      border-right: 1px solid var(--border);
    }

    /* ── Mobile Sidebar ── */
    @media (max-width: 767px) {
      #sidebar {
        position: fixed; top: 0; left: 0;
        height: 100vh; z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 240px !important;
      }
      #sidebar.sidebar-open { transform: translateX(0); }
      #admin-sidebar-overlay {
        display: none; position: fixed; inset: 0;
        background: rgba(0,0,0,0.7); z-index: 49;
      }
      #admin-sidebar-overlay.open { display: block; }
      #mobile-topbar { display: flex !important; }
      body { overflow: auto !important; }
      #app-shell { overflow: auto !important; }
    }
    @media (min-width: 768px) {
      #mobile-topbar { display: none !important; }
      #admin-sidebar-overlay { display: none !important; }
    }

    /* ── Nav items ── */
    .nav-item {
      transition: background 0.15s, color 0.15s;
      border-radius: 8px;
      position: relative;
    }
    .nav-item:hover { background: var(--bg-3); }
    .nav-item.active {
      background: var(--accent-dim);
      color: #a5b4fc;
    }
    .nav-item.active::before {
      content: '';
      position: absolute; left: 0; top: 50%;
      transform: translateY(-50%);
      width: 2px; height: 55%;
      background: var(--accent);
      border-radius: 0 2px 2px 0;
    }

    /* ── Cards ── */
    .glass-card {
      background: var(--bg-2);
      border: 1px solid var(--border);
      border-radius: 12px;
      transition: border-color 0.2s;
    }
    .glass-card:hover { border-color: var(--faint); }

    .kpi-card {
      background: var(--bg-2);
      border: 1px solid var(--border);
      border-radius: 12px;
      transition: border-color 0.2s;
      position: relative; overflow: hidden;
    }
    .kpi-card:hover { border-color: rgba(99,102,241,0.35); }

    /* ── Tables ── */
    .data-table { border-collapse: separate; border-spacing: 0; width: 100%; }
    .data-table th {
      background: var(--bg-3);
      font-size: 11px; font-weight: 600;
      letter-spacing: 0.08em; text-transform: uppercase;
      color: var(--muted); padding: 10px 16px;
      border-bottom: 1px solid var(--border);
    }
    .data-table th:first-child { border-radius: 10px 0 0 0; }
    .data-table th:last-child  { border-radius: 0 10px 0 0; }
    .data-table td {
      padding: 12px 16px;
      border-bottom: 1px solid var(--border);
      vertical-align: middle; font-size: 13.5px;
    }
    .data-table tr:last-child td { border-bottom: none; }
    .data-table tbody tr { transition: background 0.15s; }
    .data-table tbody tr:hover { background: var(--accent-dim); }
    .data-table tbody tr:last-child td:first-child { border-radius: 0 0 0 10px; }
    .data-table tbody tr:last-child td:last-child  { border-radius: 0 0 10px 0; }

    .badge-Code       { background: rgba(16,185,129,0.12);  color: #6ee7b7;  border: 1px solid rgba(16,185,129,0.2); }
    .badge-Loisirs    { background: rgba(245,158,11,0.12);  color: #fcd34d;  border: 1px solid rgba(245,158,11,0.2); }
    .badge-Écriture   { background: rgba(236,72,153,0.12);  color: #f9a8d4;  border: 1px solid rgba(236,72,153,0.2); }
    .badge-Marketing  { background: rgba(251,146,60,0.12);  color: #fdba74;  border: 1px solid rgba(251,146,60,0.2); }
    .badge-Design     { background: rgba(168,85,247,0.12);  color: #d8b4fe;  border: 1px solid rgba(168,85,247,0.2); }
    .badge-SEO        { background: rgba(20,184,166,0.12);  color: #5eead4;  border: 1px solid rgba(20,184,166,0.2); }
    .badge-active     { background: rgba(34,197,94,0.12);   color: #4ade80;  border: 1px solid rgba(34,197,94,0.2); }
    .badge-banned     { background: rgba(239,68,68,0.12);   color: #f87171;  border: 1px solid rgba(239,68,68,0.2); }
    .badge-inactive   { background: rgba(100,116,139,0.1);  color: var(--muted); border: 1px solid var(--border); }
    .badge-mod        { background: var(--accent-dim); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.2); }
    .badge-featured   { background: rgba(250,204,21,0.12);  color: #fbbf24;  border: 1px solid rgba(250,204,21,0.2); }

    .btn-icon {
      width: 30px; height: 30px; border-radius: 7px;
      display: inline-flex; align-items: center; justify-content: center;
      transition: background 0.15s, color 0.15s; cursor: pointer;
      border: none; background: transparent; color: var(--muted);
    }
    .btn-icon:hover { background: var(--bg-3); color: var(--text); }
    .btn-icon.danger:hover  { background: rgba(239,68,68,0.12);  color: #f87171; }
    .btn-icon.success:hover { background: rgba(34,197,94,0.12);  color: #4ade80; }

    /* ── Inputs ── */
    .input-field {
      background: var(--bg-3); border: 1px solid var(--border);
      color: var(--text); border-radius: 8px;
      padding: 9px 14px; font-size: 13.5px;
      transition: border-color 0.15s, box-shadow 0.15s;
      outline: none; font-family: 'Inter', sans-serif; width: 100%;
    }
    .input-field:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-dim);
    }
    .input-field::placeholder { color: var(--faint); }
    select.input-field option { background: var(--bg-2); color: var(--text); }

    /* ── Edit Panel ── */
    #edit-panel {
      position: fixed; top: 0; right: -520px; width: 480px; height: 100vh;
      background: var(--bg-2); border-left: 1px solid var(--border);
      z-index: 60; transition: right 0.3s ease;
      display: flex; flex-direction: column; overflow-y: auto;
    }
    #edit-panel.open { right: 0; }
    #edit-panel-backdrop {
      position: fixed; inset: 0; background: rgba(0,0,0,0.6);
      z-index: 59; display: none;
    }
    #edit-panel-backdrop.open { display: block; }

    /* ── Toggle Switch ── */
    .toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
    .toggle-switch input { opacity: 0; width: 0; height: 0; }
    .toggle-slider {
      position: absolute; cursor: pointer; inset: 0;
      background: var(--bg-3); border-radius: 24px;
      transition: 0.25s; border: 1px solid var(--border);
    }
    .toggle-slider:before {
      content: ""; position: absolute;
      height: 16px; width: 16px; left: 3px; bottom: 3px;
      background: var(--muted); border-radius: 50%; transition: 0.25s;
    }
    .toggle-switch input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
    .toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); background: var(--accent); }

    /* ── Views ── */
    .view { display: none; }
    .view.active { display: block; }

    /* ── Animations ── */
    @keyframes fade-in { from { opacity:0; transform:translateY(8px) } to { opacity:1; transform:none } }
    .fade-in { animation: fade-in 0.3s ease both; }
    .fade-in-delay-1 { animation-delay: 0.05s; }
    .fade-in-delay-2 { animation-delay: 0.1s; }
    .fade-in-delay-3 { animation-delay: 0.15s; }
    .fade-in-delay-4 { animation-delay: 0.2s; }

    /* ── Drag & Drop categories ── */
    .drag-item { cursor: grab; transition: all 0.2s; }
    .drag-item:active { cursor: grabbing; opacity: 0.7; }
    .drag-item.drag-over { border-color: rgba(99,102,241,0.4) !important; background: var(--accent-dim) !important; }

    /* ── Tooltip ── */
    [data-tooltip] { position: relative; }
    [data-tooltip]::after {
      content: attr(data-tooltip);
      position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
      background: var(--bg-3); color: var(--text); font-size: 11px;
      padding: 4px 8px; border-radius: 6px; white-space: nowrap;
      opacity: 0; pointer-events: none; transition: opacity 0.2s;
      border: 1px solid var(--border); z-index: 100;
    }
    [data-tooltip]:hover::after { opacity: 1; }

    /* ── Heatmap ── */
    .heatmap-cell {
      width: 14px; height: 14px; border-radius: 3px;
      background: var(--bg-3); transition: transform 0.15s;
    }
    .heatmap-cell:hover { transform: scale(1.3); }

    /* ── Stat bar ── */
    .stat-bar-fill {
      height: 100%; border-radius: 4px;
      background: var(--accent);
      transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
    }

    /* ── Search ── */
    .search-wrapper { position: relative; }
    .search-wrapper .search-icon {
      position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
      color: var(--faint); pointer-events: none;
    }
    .search-wrapper input { padding-left: 36px; }

    /* ── Toast ── */
    #toast {
      position: fixed; bottom: 24px; right: 24px;
      background: var(--bg-2); border: 1px solid rgba(99,102,241,0.3);
      border-radius: 10px; padding: 12px 20px;
      display: flex; align-items: center; gap: 10px;
      font-size: 13px; color: var(--text);
      transform: translateY(80px); opacity: 0;
      transition: all 0.3s ease; z-index: 999;
    }
    #toast.show { transform: translateY(0); opacity: 1; }

    /* ── Login card ── */
    .login-glow { box-shadow: 0 0 0 1px var(--border), 0 20px 50px rgba(0,0,0,0.4); }

    /* ── Scrollable main content ── */
    #main-content { height: 100vh; overflow-y: auto; }