/* ---------- L5 Admin ---------- */

:root {
  --bg: #f7f5f2;
  --panel: #ffffff;
  --ink: #111113;
  --ink-2: #3a3b3e;
  --ink-3: #6b6c70;
  --line: #e8e6e0;
  --accent: #e31e24;
  --accent-2: #c41820;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(17,17,19,.05);
  --shadow: 0 8px 24px -8px rgba(17,17,19,.14);
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: 'Space Grotesk', var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.admin {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--ink-3); }

/* ---------- Sidebar ---------- */
.side {
  background: #141416; color: #dcdde0;
  padding: 24px 16px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.side__brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 700; color: #fff;
  font-size: 18px; margin-bottom: 32px;
}
.side__mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: #fff; color: var(--accent);
  font-weight: 800; font-size: 13px;
}
.side__logo { width: 36px; height: 36px; display: block; object-fit: contain; }
.login__logo { width: 40px; height: 40px; display: block; object-fit: contain; }
.side__nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side__nav a {
  padding: 10px 12px; border-radius: 8px; color: #dcdde0;
  font-size: 14px; font-weight: 500;
}
.side__nav a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.side__nav a.is-active { background: var(--accent); color: var(--accent-ink); }
.side__logout button {
  width: 100%; padding: 10px 12px; background: transparent;
  color: #c8c9cd; border: 1px solid rgba(255,255,255,.15); border-radius: 8px;
  font: inherit; cursor: pointer;
}
.side__logout button:hover { background: rgba(255,255,255,.05); color: #fff; }

@media (max-width: 800px) {
  body.admin { grid-template-columns: 1fr; }
  .side { position: relative; height: auto; }
}

/* ---------- Main ---------- */
.main { padding: 24px 32px 64px; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.topbar h1 {
  font-family: var(--display); font-size: 26px; font-weight: 700;
  margin: 0; letter-spacing: -0.02em;
}
.topbar__link { color: var(--ink-3); font-size: 14px; }
.back { display: inline-block; color: var(--ink-3); margin-bottom: 16px; font-size: 14px; }

.banner {
  padding: 12px 16px; border-radius: 10px; font-weight: 500; font-size: 14px;
  margin-bottom: 16px;
}
.banner--success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.banner--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ---------- Stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow-sm);
}
.stat__label { color: var(--ink-3); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat__value { font-family: var(--display); font-size: 32px; font-weight: 700; }

/* ---------- Panels + tables ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel h2 {
  font-family: var(--display); font-size: 16px; font-weight: 600;
  margin: 0 0 12px; letter-spacing: -0.01em;
}
.panel__head h2 { margin: 0; }
.empty { color: var(--ink-3); text-align: center; padding: 24px; margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
table th, table td {
  padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line);
}
table th { color: var(--ink-3); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: #fafbfc; }

.tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; text-transform: capitalize;
}
.tag--pending { background: #fef3c7; color: #92400e; }
.tag--reviewing { background: #dbeafe; color: #1e40af; }
.tag--approved { background: #d1fae5; color: #065f46; }
.tag--rejected { background: #fee2e2; color: #991b1b; }

/* ---------- Driver detail ---------- */
.status-panel { padding: 24px; }
.status-panel__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.status-panel__current { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.tag--lg { font-size: 13px; padding: 5px 12px; }

.status-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 18px;
}
@media (max-width: 900px) { .status-grid { grid-template-columns: repeat(2, 1fr); } }

.status-tile { margin: 0; display: block; }
.status-tile button {
  width: 100%;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 16px 18px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font: inherit; text-align: left; cursor: pointer;
  transition: transform .08s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.status-tile button:hover:not(:disabled) {
  border-color: var(--ink-3);
  box-shadow: 0 6px 16px -8px rgba(17,17,19,.18);
  transform: translateY(-1px);
}
.status-tile button:disabled { cursor: default; opacity: 1; }

.status-tile__icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
  background: #f2f4ed; color: var(--ink-2);
  margin-bottom: 6px;
}
.status-tile__label {
  font-weight: 600; font-size: 15px; color: var(--ink); line-height: 1.2;
}
.status-tile__sub {
  font-size: 12px; color: var(--ink-3);
}

/* Per-status accents */
.status-tile--reviewing button:hover:not(:disabled) { border-color: #1e40af; }
.status-tile--reviewing .status-tile__icon { background: #dbeafe; color: #1e40af; }

.status-tile--approved button:hover:not(:disabled) { border-color: var(--success); background: #f5fbf7; }
.status-tile--approved .status-tile__icon { background: #d1fae5; color: #065f46; }

.status-tile--rejected button:hover:not(:disabled) { border-color: var(--danger); }
.status-tile--rejected .status-tile__icon { background: #fee2e2; color: #991b1b; }

/* Current state (disabled): show as filled with a check */
.status-tile.is-current button {
  border-color: transparent;
  background: linear-gradient(180deg, #f7f5f2 0%, #efece7 100%);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.status-tile.is-current .status-tile__icon {
  background: var(--ink); color: #fff;
}
.status-tile.is-current .status-tile__sub { color: var(--ink); font-weight: 600; }

/* iOS-style switch */
.switch {
  display: inline-flex; align-items: center; gap: 12px;
  cursor: pointer; user-select: none;
  font-size: 14px; color: var(--ink-2); font-weight: 500;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  position: relative; width: 42px; height: 24px; border-radius: 999px;
  background: #d4dbcc; transition: background .18s ease;
  flex-shrink: 0;
}
.switch__thumb {
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .18s ease;
}
.switch input:checked + .switch__track { background: var(--accent-ink); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px rgba(227,30,36,.25); }

/* Small button variant */
.btn--sm { padding: 7px 12px; font-size: 13px; border-radius: 7px; }
.btn--lg { padding: 13px 20px; font-size: 15px; border-radius: 10px; }

/* ---------- Newsletter detail ---------- */
.nl-detail {
  display: grid; grid-template-columns: 320px 1fr; gap: 20px;
}
@media (max-width: 1050px) { .nl-detail { grid-template-columns: 1fr; } }
.nl-detail__side { display: flex; flex-direction: column; }
.nl-detail__main { min-width: 0; }

.nl-status { display: flex; align-items: center; gap: 12px; }
.nl-status__pill {
  padding: 6px 14px; border-radius: 999px;
  font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.nl-status--draft .nl-status__pill { background: #fef3c7; color: #92400e; }
.nl-status--sent .nl-status__pill { background: #d1fae5; color: #065f46; }
.nl-status__meta { color: var(--ink-3); font-size: 13px; }

.nl-actions { display: flex; flex-direction: column; gap: 12px; }
.nl-actions .btn--lg { padding: 14px 20px; font-size: 15px; }

.nl-test label { display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 6px; font-weight: 500; }
.nl-test__row { display: flex; gap: 8px; }
.nl-test__row input {
  flex: 1; min-width: 0;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13px; background: #fff;
}
.nl-test__row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(227,30,36,.15); }
.nl-test__row .btn { flex-shrink: 0; }

.nl-preview { padding: 0; overflow: hidden; }
.nl-preview__head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  background: #fafbf7;
}
.nl-preview__label {
  font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-bottom: 4px;
}
.nl-preview__subject { font-size: 14px; color: var(--ink); }
.nl-preview__frame {
  background: #f2f4ed;
  padding: 0;
  min-height: 620px;
}
.nl-preview__frame iframe {
  width: 100%; height: 720px; border: none; display: block;
  background: transparent;
}

/* ---------- Newsletter list ---------- */
.nl-list th, .nl-list td { padding: 14px 12px; }
.nl-list__subject {
  font-weight: 600; color: var(--ink); font-size: 15px;
  text-decoration: none;
}
.nl-list__subject:hover { color: var(--accent-ink); text-decoration: underline; }
.nl-list tbody tr:hover td { background: #fafbf7; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.timeline li:last-child { border-bottom: none; }
.timeline__dot {
  width: 10px; height: 10px; border-radius: 50%; margin-top: 8px; flex-shrink: 0;
  background: var(--ink-3);
}
.timeline__dot--submitted { background: var(--ink-3); }
.timeline__dot--status_change { background: var(--accent); }
.timeline__dot--email_sent { background: var(--success); }
.timeline__dot--email_failed { background: var(--danger); }
.timeline__dot--note_updated { background: #8b5cf6; }
.timeline__title { font-size: 14px; }
.timeline__meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* Quill overrides so the editor blends in */
.ql-toolbar.ql-snow { border-radius: 8px 8px 0 0; border-color: var(--line) !important; background: #fafbfc; }
.ql-container.ql-snow { border-radius: 0 0 8px 8px; border-color: var(--line) !important; font-family: var(--font); font-size: 14px; }
.ql-editor { min-height: 120px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar input[type="search"], .toolbar select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff;
}
.toolbar input[type="search"] { min-width: 260px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 14px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  text-decoration: none; transition: background .15s ease, transform .05s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-2); }
.btn--dark { background: var(--ink); color: #fff; }
.btn--dark:hover { background: #26272a; }
.btn--ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--bg); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #b91c1c; }
.btn--danger.btn--outline { background: transparent; color: var(--danger); border-color: #fecaca; }
.btn--danger.btn--outline:hover { background: #fef2f2; }
.btn--block { display: flex; width: 100%; }

.link {
  background: none; border: none; padding: 0; color: var(--accent);
  cursor: pointer; font: inherit; font-size: 14px; font-weight: 500;
}
.link:hover { text-decoration: underline; }
.link--danger { color: var(--danger); }

/* ---------- Detail (kv) ---------- */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--ink-3); font-size: 13px; }
.kv dd { margin: 0; font-size: 14px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions form { margin: 0; }

/* ---------- Forms ---------- */
.form label {
  display: block; margin-top: 14px; margin-bottom: 6px;
  font-weight: 600; font-size: 13px;
}
.form input[type="text"], .form input[type="email"], .form input[type="password"],
.form input[type="number"], .form textarea, .form select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit;
  background: #fff;
}
.form textarea { resize: vertical; font-family: 'SF Mono', ui-monospace, Menlo, monospace; font-size: 13px; }
.form input:focus, .form textarea:focus, .form select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(227,30,36,.15);
}
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-weight: 500; font-size: 14px; cursor: pointer; }
.check input { width: auto; margin: 0; }

/* ---------- Login ---------- */
.login {
  grid-column: 1 / -1;
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #141416 0%, #26272a 100%);
  padding: 24px;
}
body.admin:has(.login) { grid-template-columns: 1fr; }
.login__card {
  background: #fff; border-radius: 16px; padding: 40px;
  width: 100%; max-width: 400px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5);
}
.login__brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 700; margin-bottom: 24px;
}
.login h1 { font-family: var(--display); font-size: 24px; margin: 0 0 6px; }
.login label { display: block; margin-top: 14px; margin-bottom: 6px; font-weight: 600; font-size: 13px; }
.login input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.login input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(227,30,36,.15); }
.login button { margin-top: 20px; }
.login .fine { text-align: center; margin-top: 20px; font-size: 13px; }
