/* After-Hours Agent — Global Styles (Editorial Theme) */

:root {
  /* Primary — editorial green */
  --primary: #0ab844;
  --primary-light: #22c55e;
  --primary-dark: #059033;
  --primary-50: rgba(10,184,68,0.06);
  --primary-100: rgba(10,184,68,0.12);

  /* Backgrounds — warm cream */
  --bg: #F7F5F0;
  --bg-card: #ffffff;
  --bg-sidebar: #111813;
  --bg-sidebar-hover: #1a2b1f;

  /* Text — editorial dark */
  --text: #111813;
  --text-secondary: #3d4a40;
  --text-muted: #7a8a7e;
  --text-inverse: #F7F5F0;

  /* Borders */
  --border: #d4d0c8;
  --border-light: #e8e5dd;

  /* Status */
  --success: #0ab844;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --error: #dc2626;
  --error-light: #fee2e2;

  /* Radius — sharp editorial, no rounding */
  --radius-sm: 0px;
  --radius: 0px;
  --radius-lg: 0px;
  --radius-xl: 0px;

  /* Shadows — minimal, editorial */
  --shadow-sm: none;
  --shadow: 0 1px 2px rgba(17,24,19,0.06);
  --shadow-md: 0 2px 4px rgba(17,24,19,0.08);
  --shadow-lg: 0 4px 12px rgba(17,24,19,0.1);

  /* Fonts */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Newsreader', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Menlo', monospace;
  --transition: 150ms ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; }
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--primary); }
img { max-width: 100%; display: block; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* Typography */
h1 { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.03em; }
h2 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; letter-spacing: -0.01em; }
h4 { font-size: 1rem; font-weight: 600; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

/* Containers */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 800px; margin: 0 auto; padding: 0 24px; }

/* Cards — editorial: bordered, no rounding */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px;
}

/* Buttons — editorial: sharp, bold */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  line-height: 1.4;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary {
  background: white;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: var(--text-muted); }
.btn-danger {
  background: white;
  color: var(--error);
  border-color: var(--error);
}
.btn-danger:hover { background: var(--error-light); }
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-lg { padding: 14px 28px; font-size: 0.875rem; }

/* Form Elements — editorial: clean borders */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  color: var(--text);
}
.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text);
  background: white;
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-100);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }

/* Badges — editorial: pill shapes kept for status */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.6;
}
.badge-blue { background: var(--primary-50); color: var(--primary-dark); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--error-light); color: var(--error); }
.badge-gray { background: var(--border-light); color: var(--text-secondary); }

/* Tables — editorial: clean rules */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  text-align: left;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--text);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
tr:hover td { background: rgba(10,184,68,0.03); }

/* KPI Cards — editorial: data-driven style */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.kpi-card {
  background: var(--bg-card);
  padding: 20px 24px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.kpi-card:last-child { border-right: none; }
.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 4px 0;
  letter-spacing: -0.02em;
}
.kpi-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.kpi-change {
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 4px;
}
.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--error); }

/* Admin Layout — editorial dark sidebar */
.admin-layout {
  display: flex;
  min-height: 100vh;
}
.admin-sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  padding: 24px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.admin-sidebar .logo {
  padding: 0 20px 24px;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(247,245,240,0.5);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: all var(--transition);
}
.admin-sidebar nav a:hover {
  background: var(--bg-sidebar-hover);
  color: white;
  text-decoration: none;
}
.admin-sidebar nav a.active {
  background: var(--bg-sidebar-hover);
  color: var(--primary);
  border-left: 2px solid var(--primary);
}
.admin-main {
  flex: 1;
  padding: 32px;
  max-width: calc(100% - 240px);
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

/* Password Gate — editorial: minimal */
.password-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.password-form {
  background: white;
  padding: 48px;
  border: 2px solid var(--text);
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 6px 6px 0px 0px var(--text);
}
.password-form h2 {
  font-family: var(--font-display);
  margin-bottom: 8px;
}
.password-form p { color: var(--text-muted); margin-bottom: 24px; font-size: 0.875rem; }
.password-form .form-input { margin-bottom: 16px; }

/* Toast — editorial: dark, sharp */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-sidebar);
  color: white;
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 300ms ease;
  z-index: 1000;
}
.toast.visible { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }

/* Modal — editorial: sharp borders */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17,24,19,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.modal-overlay.visible { opacity: 1; pointer-events: auto; }
.modal {
  background: white;
  border: 1px solid var(--text);
  padding: 32px;
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}

/* Tabs — editorial: underline style */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--text);
  margin-bottom: 24px;
}
.tab {
  padding: 10px 20px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 16px; opacity: 0.4; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }

/* Status dots */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.green { background: var(--success); }
.status-dot.yellow { background: var(--warning); }
.status-dot.red { background: var(--error); }
.status-dot.gray { background: var(--text-muted); }

/* Utility */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.hidden { display: none !important; }

/* Auth-aware visibility — prevents login flash on page navigation */
html.aha-authed #password-gate { display: none !important; }
html:not(.aha-authed) #dashboard { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
  .admin-sidebar { display: none; }
  .admin-main { max-width: 100%; padding: 20px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
