/* FoundrOS Theme System - Light/Dark Mode */
/* Default: Dark mode */
:root {
  --bg-primary: #09090b;
  --bg-secondary: #18181b;
  --bg-card: #1c1c1f;
  --bg-input: #09090b;
  --bg-hover: #27272a;
  --border: #27272a;
  --border-hover: #3f3f46;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #c084fc;
  --accent-hover: #d4a0ff;
  --accent-glow: rgba(192, 132, 252, 0.15);
  --accent-subtle: rgba(192, 132, 252, 0.08);
  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.1);
  --green-border: rgba(74, 222, 128, 0.2);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.1);
  --amber-border: rgba(251, 191, 36, 0.2);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 24px 80px rgba(0,0,0,0.5);
  --sidebar-width: 240px;
  --nav-bg: rgba(9, 9, 11, 0.85);
}

/* Light mode */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f4f4f5;
  --bg-card: #ffffff;
  --bg-input: #f4f4f5;
  --bg-hover: #e4e4e7;
  --border: #e4e4e7;
  --border-hover: #d4d4d8;
  --text-primary: #09090b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --accent: #9333ea;
  --accent-hover: #7e22ce;
  --accent-glow: rgba(147, 51, 234, 0.1);
  --accent-subtle: rgba(147, 51, 234, 0.05);
  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, 0.08);
  --green-border: rgba(22, 163, 74, 0.2);
  --amber: #d97706;
  --amber-bg: rgba(217, 119, 6, 0.08);
  --amber-border: rgba(217, 119, 6, 0.2);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.08);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 24px 80px rgba(0,0,0,0.12);
  --nav-bg: rgba(255, 255, 255, 0.85);
}

/* ===================== */
/* GLOBAL RESET */
/* ===================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.15;
}

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

/* ===================== */
/* SHARED COMPONENTS */
/* ===================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--accent-subtle);
  color: var(--text-primary);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Form inputs */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
  color: var(--text-muted);
}

/* Alert messages */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 20px;
  display: none;
}

.alert-error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.alert-success {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.alert.show {
  display: block;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--border-hover);
}

/* ===================== */
/* SHARED NAV */
/* ===================== */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 14px 24px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}

.topnav .inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.logo span { color: var(--accent); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Theme toggle */
.theme-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s ease;
  color: var(--text-secondary);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* Light mode icon swap */
.theme-toggle .icon-moon { display: inline; }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: inline; }

/* ===================== */
/* SHARED FOOTER */
/* ===================== */
.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-left {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-links a:hover {
  color: var(--text-primary);
}

/* ===================== */
/* AUTH PAGES (login/signup) */
/* ===================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px 40px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.auth-card h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.auth-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.auth-card .auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-card .auth-footer a {
  color: var(--accent);
  font-weight: 500;
}

/* Password requirements */
.password-requirements {
  margin: -8px 0 20px;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: 8px;
  font-size: 0.78rem;
}

.password-requirements .req-title {
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.requirement {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  color: var(--text-muted);
  transition: color 0.15s;
}

.requirement .check {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  transition: all 0.15s;
  flex-shrink: 0;
}

.requirement.met {
  color: var(--green);
}

.requirement.met .check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* ===================== */
/* LEGAL PAGES */
/* ===================== */
.legal-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 100px 24px 60px;
}

.legal-page h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.legal-page .last-updated {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 40px;
}

.legal-page h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 40px;
  margin-bottom: 12px;
}

.legal-page p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 16px;
}

.legal-page ul {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 16px;
  padding-left: 24px;
}

.legal-page li {
  margin-bottom: 6px;
}

/* ===================== */
/* DASHBOARD LAYOUT */
/* ===================== */
.dash-layout {
  display: flex;
  min-height: 100vh;
  padding-top: 57px; /* nav height */
}

.dash-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  top: 57px;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-label {
  padding: 8px 20px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s ease;
  border-left: 2px solid transparent;
}

.sidebar-item:hover {
  color: var(--text-secondary);
  background: var(--accent-subtle);
}

.sidebar-item.active {
  color: var(--text-primary);
  background: var(--accent-subtle);
  border-left-color: var(--accent);
}

.sidebar-item .icon {
  width: 18px;
  text-align: center;
  font-size: 0.9rem;
}

.dash-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  min-height: calc(100vh - 57px);
}

/* Dashboard header */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.dash-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dash-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.15s;
}

.stat-card:hover {
  border-color: var(--border-hover);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-value.green { color: var(--green); }
.stat-value.accent { color: var(--accent); }
.stat-value.amber { color: var(--amber); }

.stat-change {
  font-size: 0.75rem;
  color: var(--green);
  margin-top: 4px;
}

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
}

/* Agent cards */
.agents-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
}

.agent-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s;
}

.agent-card:hover {
  border-color: var(--border-hover);
}

.agent-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: var(--accent-subtle);
  border: 1px solid rgba(192, 132, 252, 0.15);
}

.agent-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.agent-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.agent-status {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 100px;
  font-weight: 500;
}

.agent-status.running {
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid var(--green-border);
}

.agent-status.queued {
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
}

.agent-status.idle {
  color: var(--text-muted);
  background: var(--bg-primary);
  border: 1px solid var(--border);
}

/* Recent activity */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-dot.green { background: var(--green); }
.activity-dot.accent { background: var(--accent); }
.activity-dot.amber { background: var(--amber); }

.activity-text {
  flex: 1;
  color: var(--text-secondary);
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Placeholder/empty states */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 0.9rem;
}

/* User menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.user-menu:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ===================== */
/* RESPONSIVE */
/* ===================== */
@media (max-width: 768px) {
  .dash-sidebar {
    display: none;
  }

  .dash-main {
    margin-left: 0;
    padding: 20px 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 28px 24px;
  }

  .site-footer {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .topnav .nav-actions .btn {
    display: none;
  }

  .topnav .nav-actions .btn.btn-primary {
    display: inline-flex;
  }

  .agent-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .dash-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}
