/* ==========================================================================
   Xabarchi admin panel — design tokens
   ========================================================================== */
:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-soft: #0f131a;
  --panel: #151a22;
  --panel-2: #1b212b;
  --border: #262d3a;
  --border-soft: #1e2430;
  --text: #eef1f6;
  --text-dim: #c3cad6;
  --muted: #8b95a7;

  --accent: #4f8cff;
  --accent-hover: #6b9fff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --accent-text: #e8f0ff;

  --success: #2fd07a;
  --success-soft: rgba(47, 208, 122, 0.14);
  --danger: #ff5d6c;
  --danger-soft: rgba(255, 93, 108, 0.14);
  --warning: #f6ad3d;
  --warning-soft: rgba(246, 173, 61, 0.14);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f5f9;
    --bg-soft: #eef1f6;
    --panel: #ffffff;
    --panel-2: #f7f9fc;
    --border: #dfe4ec;
    --border-soft: #e8ebf1;
    --text: #171b21;
    --text-dim: #384152;
    --muted: #6b7483;

    --accent: #3568e0;
    --accent-hover: #2a56c2;
    --accent-soft: rgba(53, 104, 224, 0.1);
    --accent-text: #1c3a8a;

    --success: #16a05f;
    --success-soft: rgba(22, 160, 95, 0.12);
    --danger: #d8394a;
    --danger-soft: rgba(216, 57, 74, 0.1);
    --warning: #b9760a;
    --warning-soft: rgba(185, 118, 10, 0.12);

    --shadow-sm: 0 1px 2px rgba(20, 25, 35, 0.06);
    --shadow-md: 0 8px 24px rgba(20, 25, 35, 0.08);
    --shadow-lg: 0 16px 40px rgba(20, 25, 35, 0.12);
  }
}

/* ==========================================================================
   Reset & base
   ========================================================================== */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 15% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 1.6rem; margin: 0 0 1.25rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.9rem; color: var(--text-dim); }
h3 { font-size: 1rem; margin: 0 0 0.6rem; }

a { color: var(--accent); }

p { color: var(--text-dim); }

::selection { background: var(--accent-soft); color: var(--text); }

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================================================
   Top navigation
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: rgba(21, 26, 34, 0.82);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

@media (prefers-color-scheme: light) {
  .topbar { background: rgba(255, 255, 255, 0.85); }
}

.topbar .brand {
  font-weight: 750;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.topbar nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar nav::-webkit-scrollbar { display: none; }

.topbar nav a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 550;
  white-space: nowrap;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.topbar nav a:hover {
  color: var(--text);
  background: var(--panel-2);
}

.topbar nav a.active {
  color: var(--accent-text);
  background: var(--accent-soft);
}

.topbar .logout {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.topbar .logout:hover { color: var(--danger); border-color: var(--danger); }

.spacer { flex: 1; }

/* ==========================================================================
   Layout
   ========================================================================== */
.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ==========================================================================
   Stat cards
   ========================================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: linear-gradient(160deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-soft);
}
.stat-card.highlight {
  border-color: var(--warning);
  background: linear-gradient(160deg, var(--warning-soft) 0%, var(--panel) 60%);
}
.stat-value {
  font-size: 1.9rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.3rem;
  font-weight: 550;
}

/* ==========================================================================
   Generic card (forms, settings, broadcast)
   ========================================================================== */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  max-width: 480px;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--panel);
}

.table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: transparent;
}
.table th, .table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  font-size: 0.9rem;
  white-space: nowrap;
}
.table td:last-child, .table th:last-child { white-space: normal; }
.table thead th {
  color: var(--muted);
  font-weight: 650;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--panel-2);
  position: sticky;
  top: 0;
}
.table tbody tr { transition: background-color 0.12s ease; }
.table tbody tr:hover { background: var(--panel-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table td a { text-decoration: none; font-weight: 600; }
.table td a:hover { text-decoration: underline; }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 650;
  text-transform: capitalize;
  background: var(--border);
  color: var(--text-dim);
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-approved { background: var(--success-soft); color: var(--success); }
.badge-pending { background: var(--warning-soft); color: var(--warning); }
.badge-rejected { background: var(--danger-soft); color: var(--danger); }

/* ==========================================================================
   Forms
   ========================================================================== */
label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

input, select, textarea {
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 120px; }

input[type="file"] {
  padding: 0.5rem;
  color: var(--muted);
}
input[type="file"]::file-selector-button {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  margin-right: 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
input[type="file"]::file-selector-button:hover { background: var(--border); }

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  align-items: center;
}
.filter-form input { width: auto; flex: 1 1 220px; }
.filter-form select { width: auto; flex: 0 1 160px; }
.filter-form button { flex: 0 0 auto; }

.settings-form, .card form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.settings-form { max-width: 460px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
button, .filter-form button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 650;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  margin-top: 0.4rem;
}
button:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
button:active { transform: translateY(1px); }

button.success { background: var(--success); }
button.success:hover { background: #26bd6d; }
button.danger { background: var(--danger); }
button.danger:hover { background: #f2444f; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.actions button, .actions form { margin-top: 0; }

/* ==========================================================================
   Login page
   ========================================================================== */
.login-box {
  max-width: 380px;
  margin: 4.5rem auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  box-shadow: var(--shadow-lg);
}
.login-box h1 {
  font-size: 1.25rem;
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-box form { display: flex; flex-direction: column; gap: 0.4rem; }
.login-box button { margin-top: 1rem; justify-content: center; }

/* ==========================================================================
   Detail cards
   ========================================================================== */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.detail-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.detail-card h3 {
  margin-top: 0;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 0.75rem;
}
.detail-card p { margin: 0.4rem 0; }

/* ==========================================================================
   Alerts & misc
   ========================================================================== */
.alert {
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-weight: 550;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.alert.success { background: var(--success-soft); color: var(--success); border-color: rgba(47, 208, 122, 0.3); }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: rgba(255, 93, 108, 0.3); }

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.75rem; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 550;
  margin-bottom: 1rem;
  transition: color 0.15s ease;
}
.back-link:hover { color: var(--text); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 720px) {
  .container { padding: 1.25rem 1rem 3rem; }
  .topbar { padding: 0.7rem 1rem; gap: 0.85rem; }
  h1 { font-size: 1.35rem; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .card, .login-box { padding: 1.25rem; max-width: 100%; }
  .filter-form { flex-direction: column; align-items: stretch; }
  .filter-form input, .filter-form select { flex: 1 1 auto; }
}
