/* public/admin/admin.css — Blackline Admin Console
   Dark enterprise dashboard aesthetic.
   Scoped to admin pages only — does not affect public site.
   Tokens:
     Amber  #f59e0b  — Yellow Cat Systems accent / active / warning
     Cyan   #22d3ee  — Blackline / detailing water accent
     Red    #ef4444  — error / cancelled
     Green  #22c55e  — completed / success
     Purple #a78bfa  — scheduled
*/

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ──────────────────────────────────────────── */
:root {
  --bg-base:        #0f1117;
  --bg-surface:     #181c27;
  --bg-card:        #1e2333;
  --bg-hover:       #252b3b;
  --bg-input:       #141720;
  --bg-sidebar:     #13161f;

  --border:         #2a3045;
  --border-focus:   #f59e0b;

  --text-primary:   #e2e8f0;
  --text-secondary: #8892a4;
  --text-muted:     #4b5568;

  --amber:          #f59e0b;
  --amber-dim:      #78450a;
  --cyan:           #22d3ee;
  --cyan-dim:       #0a4a52;
  --green:          #22c55e;
  --green-dim:      #14532d;
  --red:            #ef4444;
  --red-dim:        #7f1d1d;
  --purple:         #a78bfa;
  --purple-dim:     #3b1f6e;

  --font-ui:   'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', 'Courier New', monospace;

  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;

  --sidebar-w: 220px;
  --header-h:  52px;
}

/* ── Base ───────────────────────────────────────────────────── */
html, body {
  height: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 13px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  transition: background 0.15s, opacity 0.15s;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

input, select, textarea {
  font-family: var(--font-ui);
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--border-focus); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--bg-card); }

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

/* ── Page states ────────────────────────────────────────────── */
#page-login,
#page-dashboard {
  display: none;
  height: 100%;
}
#page-login.active,
#page-dashboard.active {
  display: flex;
}

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════ */
#page-login {
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px 36px;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.03em;
}
.login-brand .brand-sub {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 3px;
}

.login-card h1 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 22px;
  color: var(--text-primary);
}

.login-field { margin-bottom: 18px; }

.btn-login {
  width: 100%;
  padding: 9px;
  background: var(--amber);
  color: #000;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  border-radius: var(--radius-sm);
  margin-top: 6px;
}
.btn-login:hover:not(:disabled) { background: #fbbf24; }

.login-error {
  margin-top: 14px;
  padding: 9px 12px;
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 12px;
  display: none;
}
.login-error.visible { display: block; }

/* ══════════════════════════════════════════════════════════════
   DASHBOARD SHELL — sidebar + header + main
══════════════════════════════════════════════════════════════ */
#page-dashboard {
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.03em;
}
.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-section {
  padding: 16px 10px 6px;
}
.sidebar-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--bg-hover); color: var(--amber); font-weight: 600; }
.nav-item.disabled { opacity: 0.35; cursor: not-allowed; }
.nav-item.disabled:hover { background: none; color: var(--text-secondary); }

.nav-icon {
  width: 16px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.btn-logout {
  width: 100%;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 7px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-logout:hover { background: var(--red-dim); border-color: var(--red); color: #fca5a5; }

/* ── Main content area ──────────────────────────────────────── */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top header ─────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  min-height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.topbar-spacer { flex: 1; }
.topbar-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Scrollable content ─────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
}
.stat-value.amber { color: var(--amber); }
.stat-value.cyan  { color: var(--cyan);  }
.stat-value.green { color: var(--green); }
.stat-value.muted { color: var(--text-primary); }

/* ── Main panel layout ──────────────────────────────────────── */
.panel-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 1024px) {
  .panel-grid { grid-template-columns: 1fr; }
}

/* ── Card shell ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.card-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.card-header-spacer { flex: 1; }

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 20px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.filter-btn:hover { border-color: var(--amber); color: var(--amber); }
.filter-btn.active {
  background: var(--amber-dim);
  border-color: var(--amber);
  color: var(--amber);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 9px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.btn-icon:hover { border-color: var(--cyan); color: var(--cyan); }

/* ── Bookings table ─────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
thead th {
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr.selected { background: var(--bg-hover); outline: 1px solid var(--amber) inset; }
td {
  padding: 10px 12px;
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
}
td.wrap { white-space: normal; max-width: 180px; }
.td-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.td-customer { font-weight: 600; }
.td-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Status badge ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-new       { background: var(--amber-dim);  border-color: var(--amber);  color: var(--amber);  }
.badge-contacted { background: var(--cyan-dim);   border-color: var(--cyan);   color: var(--cyan);   }
.badge-scheduled { background: var(--purple-dim); border-color: var(--purple); color: var(--purple); }
.badge-completed { background: var(--green-dim);  border-color: var(--green);  color: var(--green);  }
.badge-cancelled { background: var(--red-dim);    border-color: var(--red);    color: var(--red);    }

/* ── Empty / loading / error states ────────────────────────── */
.state-row td {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  cursor: default;
}
.state-row:hover { background: none !important; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Detail panel ───────────────────────────────────────────── */
.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.detail-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.detail-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }

.detail-section-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}
.detail-row:last-child { margin-bottom: 0; }
.detail-key {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.detail-val {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}
.detail-val.mono { font-family: var(--font-mono); font-size: 12px; }
.detail-val.empty { color: var(--text-muted); font-style: italic; }

.detail-divider {
  border: none;
  border-top: 1px solid var(--border);
}

/* Edit section */
.edit-field { margin-bottom: 12px; }
.edit-field:last-child { margin-bottom: 0; }

.btn-save {
  background: var(--amber);
  color: #000;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.btn-save:hover:not(:disabled) { background: #fbbf24; }

.save-status {
  font-size: 11px;
  margin-top: 8px;
  min-height: 16px;
}
.save-status.ok  { color: var(--green); }
.save-status.err { color: var(--red);   }

/* ── Global alert banner ────────────────────────────────────── */
.global-error {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red-dim);
  border: 1px solid var(--red);
  color: #fca5a5;
  font-size: 12px;
  padding: 9px 18px;
  border-radius: var(--radius);
  z-index: 100;
  display: none;
}
.global-error.visible { display: block; }

/* ── Responsive sidebar collapse ────────────────────────────── */
@media (max-width: 768px) {
  #page-dashboard { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-width: unset;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px;
    gap: 4px;
  }
  .sidebar-brand { border-bottom: none; padding: 4px 8px; }
  .sidebar-brand .brand-sub { display: none; }
  .sidebar-section { padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar-section-label { display: none; }
  .sidebar-footer { margin-top: 0; padding: 0; border-top: none; }
  .nav-item { width: auto; padding: 5px 10px; }
  .btn-logout { width: auto; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}
