/* ═══════════════════════════════════════════════════════════════
   Alexander AI Dashboard — Global Styles
   Phase 3: Modernized
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ──────────────────────────────────── */
:root {
  /* Dark theme (default) */
  --bg: #030712;
  --bg2: #0a0f1a;
  --surface: #111827;
  --surface2: #1a1a35;
  --surface3: #1f2937;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.12);
  --text: #f9fafb;
  --text2: #e8e8f0;
  --muted: #9ca3af;
  --muted2: #6b7280;

  /* Accent palette */
  --accent: #6366f1;
  --accent2: #8b5cf6;
  --accent3: #a78bfa;
  --accent-bg: rgba(99,102,241,0.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.1);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.1);
  --amber: #f59e0b;
  --amber-bg: rgba(245,158,11,0.1);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,0.1);
  --purple: #a855f7;
  --purple-bg: rgba(168,85,247,0.1);
  --cyan: #06b6d4;
  --cyan-bg: rgba(6,182,212,0.1);

  /* Gradients */
  --grad: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
  --grad-blue: linear-gradient(135deg, #3b82f6, #6366f1);
  --grad-green: linear-gradient(135deg, #22c55e, #06b6d4);
  --grad-warm: linear-gradient(135deg, #f59e0b, #ef4444);

  /* Spacing */
  --r: 10px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(99,102,241,0.15);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 150ms var(--ease);
  --t-normal: 250ms var(--ease);
  --t-slow: 400ms var(--ease);
}

/* Light theme */
[data-theme="light"] {
  --bg: #f8fafc;
  --bg2: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --surface3: #e2e8f0;
  --border: rgba(0,0,0,0.08);
  --border2: rgba(0,0,0,0.12);
  --text: #0f172a;
  --text2: #1e293b;
  --muted: #64748b;
  --muted2: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent2); }

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Navigation ─────────────────────────────────────────────── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(17, 24, 39, 0.85);
}

[data-theme="light"] .nav {
  background: rgba(255, 255, 255, 0.85);
}

.nav-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--blue);
  text-decoration: none;
  font-family: 'Space Grotesk', sans-serif;
}
.nav-logo span { color: var(--text); }

.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-links a {
  color: #00d4ff;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--t-fast);
  text-shadow: 0 0 8px rgba(0,212,255,0.5);
}
.nav-links a:hover,
.nav-links a.active {
  background: var(--surface2);
  color: #00d4ff;
  text-shadow: 0 0 12px rgba(0,212,255,0.7);
}

.nav-right { display: flex; align-items: center; gap: 12px; }

/* Hamburger */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: #00d4ff;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r);
  transition: background var(--t-fast);
  text-shadow: 0 0 8px rgba(0,212,255,0.5);
}
.hamburger:hover {
  background: var(--surface2);
  text-shadow: 0 0 12px rgba(0,212,255,0.7);
}

@media (max-width: 768px) {
  .hamburger { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px 16px 16px;
    z-index: 99;
    box-shadow: var(--shadow-lg);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 16px; font-size: 15px; border-radius: var(--r); }
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.card:hover {
  border-color: var(--border2);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  border: none;
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--grad);
  color: white;
}
.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 8px 24px rgba(99,102,241,0.35);
  color: white;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--surface3);
  color: var(--text);
}

.btn-danger {
  background: var(--red);
  color: white;
}
.btn-danger:hover {
  background: #dc2626;
  color: white;
}

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="tel"],
input[type="search"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 16px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

textarea { resize: vertical; min-height: 100px; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-cyan { background: var(--cyan-bg); color: var(--cyan); }

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  text-align: center;
  transition: border-color var(--t-fast);
}
.stat-card:hover { border-color: var(--border2); }
.stat-num { font-size: 28px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ── Flash Messages / Toasts ────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}
.flash {
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s var(--ease);
  box-shadow: var(--shadow-md);
  cursor: pointer;
}
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.flash-info { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }
.flash-warning { background: var(--amber-bg); color: var(--amber); border: 1px solid rgba(245,158,11,0.2); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ── Greeting Bar ───────────────────────────────────────────── */
.greeting-bar {
  background: linear-gradient(135deg, var(--surface), var(--surface2));
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}
.greeting-bar .greet-name { color: var(--accent); }
.greeting-bar .greet-time { color: var(--blue); font-size: 13px; margin-left: 8px; }

/* ── Sections ───────────────────────────────────────────────── */
.section { margin-bottom: 32px; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.section-title { font-size: 18px; font-weight: 700; }
.section-sub { font-size: 13px; color: var(--muted); }

/* ── Grid Layouts ───────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr; }
}

/* ── Agent Status Dots ──────────────────────────────────────── */
.agent-status { display: flex; gap: 8px; }
.agent-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.agent-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.agent-dot.offline { background: var(--muted); }

/* ── Theme Toggle ───────────────────────────────────────────── */
.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all var(--t-fast);
}
.theme-toggle:hover {
  background: var(--surface3);
  transform: rotate(15deg);
}

/* ── Loading Spinner ────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ──────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 24px; }
.text-2xl { font-size: 32px; }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none; }

/* ── Mobile Touch & Viewport ─────────────────────────────────── */
@media (max-width: 768px) {
  body { overflow-x: hidden; }
  .container { padding: 0 16px; }
  .section-header { flex-direction: column; align-items: flex-start; }
  table { display: block; overflow-x: auto; }
  input, select, textarea { font-size: 16px !important; }
  .btn { min-height: 44px; }
  .nav-links a, .tab { min-height: 44px; display: flex; align-items: center; }
  a, button { -webkit-tap-highlight-color: transparent; }
  html { -webkit-text-size-adjust: 100%; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-num { font-size: 22px; }
}

/* ── Print ──────────────────────────────────────────────────── */
@media print {
  .nav, .hamburger, .theme-toggle, .flash-container { display: none !important; }
  body { background: white; color: black; }
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Selection ──────────────────────────────────────────────── */
::selection { background: rgba(99,102,241,0.3); color: var(--text); }

/* ── Focus Visible ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
