/**
 * ElMaître design system — shared styles for SaaS platform
 * Dark theme, amber accent, Libre Baskerville + IBM Plex Sans
 */

@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Backgrounds — dark gray (not pure black) */
  --bg-primary: #171717;
  --bg-secondary: #1c1c1c;
  --bg-tertiary: #222;
  --bg-card: rgba(255, 255, 255, 0.03);
  /* Text */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.8);
  --text-muted: rgba(255, 255, 255, 0.5);
  --text-muted-strong: rgba(255, 255, 255, 0.6);
  /* Accent */
  --accent: #fbbf24;
  --accent-hover: #fcd34d;
  --accent-muted: rgba(251, 191, 36, 0.9);
  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-medium: rgba(255, 255, 255, 0.2);
  --border-strong: rgba(255, 255, 255, 0.3);
  --border-accent: rgba(251, 191, 36, 0.2);
  --border-accent-hover: rgba(251, 191, 36, 0.3);
  /* Light page (e.g. login card) */
  --surface-light: hsl(0, 0%, 98%);
  --text-on-light: #1a1a2e;
  --text-on-light-muted: #666;
}

/* Base */
body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

*, *::before, *::after { box-sizing: border-box; }

/* Typography */
.font-display, .font-heading, h1, h2, h3, h4 {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-weight: 400;
  color: var(--text-primary);
}

.font-display { font-family: 'Libre Baskerville', Georgia, serif; }
.text-hero { font-size: clamp(2.25rem, 5vw, 4rem); line-height: 1.15; }
.text-section-title { font-size: 1.875rem; }
@media (min-width: 1024px) { .text-section-title { font-size: 2.25rem; } }
.text-body { font-size: 1rem; }
.text-body-lg { font-size: 1.125rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-muted);
}

/* Layout */
.container {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 2rem;
  padding-right: 2rem;
}
@media (min-width: 640px) { .container { padding-left: 3rem; padding-right: 3rem; } }
@media (min-width: 1024px) { .container { padding-left: 4rem; padding-right: 4rem; } }

/* Navbar */
.navbar, .header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 100;
}
.navbar-left, .header-left { display: flex; align-items: center; gap: 2rem; }
.navbar h1, .header h1 { font-size: 1rem; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.navbar-nav, .header-nav { display: flex; gap: 4px; }
.navbar-nav button, .navbar-nav a, .header-nav button, .header-nav a {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
}
.navbar-nav button:hover, .navbar-nav a:hover, .header-nav button:hover, .header-nav a:hover { color: var(--text-primary); background: rgba(255,255,255,0.08); }
.navbar-nav button.active, .navbar-nav a.active, .header-nav button.active, .header-nav a.active { color: var(--text-primary); background: rgba(255,255,255,0.12); }
.navbar-right, .header-right { display: flex; align-items: center; gap: 1rem; }
.navbar-right .muted, .header-right .muted { font-size: 0.8rem; color: var(--text-muted); }
.logout-btn {
  border: 1px solid var(--border-medium);
  background: transparent;
  color: var(--text-secondary);
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.logout-btn:hover { background: rgba(255,255,255,0.08); border-color: var(--border-strong); color: var(--text-primary); }

/* Main content (clear fixed nav) */
.main { padding-top: 5rem; padding-bottom: 2rem; }
.main .container { padding-top: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  border: none;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  border: 1px solid var(--border-medium);
  background: transparent;
  color: rgba(255,255,255,0.9);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: var(--border-strong); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }
.btn-success { background: rgba(16, 185, 129, 0.25); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.4); }
.btn-success:hover { background: rgba(16, 185, 129, 0.35); }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  overflow: hidden;
  margin-bottom: 1.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: var(--border-accent); box-shadow: 0 10px 40px -10px rgba(251, 191, 36, 0.05); }
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-header h3 { font-size: 1rem; font-weight: 600; margin: 0; }
.card-body { padding: 1.5rem; }
.card-body.no-padding { padding: 0; }

/* KPI / stat cards */
.kpi-card, .stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  transition: border-color 0.2s;
}
.kpi-card:hover, .stat-card:hover { border-color: var(--border-accent); }
.kpi-card .label, .stat-card .label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.kpi-card .value, .stat-card .value { font-size: 1.75rem; font-weight: 600; color: var(--text-primary); }
.kpi-card.primary, .stat-card.primary { background: linear-gradient(135deg, var(--accent) 0%, #d97706 100%); border-color: transparent; }
.kpi-card.primary .label, .kpi-card.primary .value, .stat-card.primary .label, .stat-card.primary .value { color: #000; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text-secondary);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border-medium);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: rgba(0,0,0,0.2);
  color: var(--text-primary);
  transition: border-color 0.2s;
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-group small { color: var(--text-muted); font-size: 0.75rem; display: block; margin-top: 0.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.875rem 1.25rem; text-align: left; border-bottom: 1px solid var(--border-subtle); }
th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(255,255,255,0.02);
}
tr:hover { background: rgba(255,255,255,0.02); }
td { font-size: 0.9rem; color: var(--text-secondary); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-live { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.badge-onboarding { background: rgba(251, 191, 36, 0.2); color: var(--accent); }
.badge-created { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
.badge-paused { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.badge-error { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.badge-managed { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.badge-self { background: rgba(255,255,255,0.08); color: var(--text-muted-strong); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border-subtle); }
.tab {
  padding: 0.875rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-muted-strong);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
  font-weight: 500;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Toggle */
.toggle { position: relative; width: 3rem; height: 1.625rem; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-medium);
  border-radius: 9999px;
  transition: 0.3s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 1.25rem;
  width: 1.25rem;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(1.375rem); }

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  padding: 2.5rem 1rem;
  overflow-y: auto;
}
.modal.open { display: flex; }
.modal-content {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  width: 100%;
  max-width: 32rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--bg-tertiary);
  z-index: 10;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 600; margin: 0; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  position: sticky;
  bottom: 0;
  background: var(--bg-tertiary);
}

/* Section */
.section { padding: 4rem 0; }
@media (min-width: 1024px) { .section { padding: 5rem 0; } }
.section-sm { padding: 2rem 0; }
@media (min-width: 1024px) { .section-sm { padding: 2.5rem 0; } }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.page-header h2 { font-size: 1.5rem; font-weight: 600; margin: 0; }
.page { display: none; }
.page.active { display: block; }

/* Filters */
.filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border-subtle);
}
.filters select, .filters input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-medium);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background: rgba(0,0,0,0.2);
  color: var(--text-primary);
}
.filters input { min-width: 12rem; }

/* Status dots */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 0.5rem; }
.status-dot.green { background: #10b981; }
.status-dot.yellow { background: #f59e0b; }
.status-dot.red { background: #ef4444; }
.status-dot.gray { background: #9ca3af; }

/* Info / warning boxes */
.info-box {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid rgba(59, 130, 246, 0.5);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: #93c5fd;
  border-radius: 0 0.375rem 0.375rem 0;
}
.warning-box {
  background: rgba(251, 191, 36, 0.1);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--accent-muted);
  border-radius: 0 0.375rem 0.375rem 0;
}

/* Code / pre */
pre, .embed-code {
  background: var(--bg-secondary);
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  font-size: 0.8rem;
  font-family: 'Monaco', 'Menlo', monospace;
  border: 1px solid var(--border-subtle);
}

/* Light surface (e.g. login card) */
.surface-light {
  background: var(--surface-light);
  color: var(--text-on-light);
  border-radius: 0.75rem;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  max-width: 24rem;
  width: 100%;
}
.surface-light .form-group label { color: var(--text-on-light); }
.surface-light .form-group input,
.surface-light .form-group select,
.surface-light .form-group textarea {
  background: #fff;
  border-color: #e5e7eb;
  color: var(--text-on-light);
}
.surface-light .form-group input:focus,
.surface-light .form-group select:focus,
.surface-light .form-group textarea:focus { border-color: var(--accent); }
.surface-light .btn-primary { background: var(--accent); color: #000; }
.surface-light .btn-primary:hover { background: var(--accent-hover); }
.surface-light a { color: var(--accent); }
.surface-light a:hover { color: var(--accent-hover); }
.surface-light .text-muted { color: var(--text-on-light-muted); }
.surface-light .error { color: #dc2626; }

/* Grid helpers */
.grid-2 { display: grid; gap: 1rem; }
@media (min-width: 1024px) { .grid-2 { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; } }
.grid-3 { display: grid; gap: 1rem; }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .grid-3 { gap: 1.5rem; } }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (min-width: 1024px) { .grid-4 { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; } }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem; }
.kpi-section { margin-bottom: 2rem; }
.kpi-section-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 0.75rem; font-weight: 600; }
.kpi-card.attention { border-left: 4px solid rgba(239, 68, 68, 0.6); }
.kpi-card .value.green { color: #34d399; }
.kpi-card .value.yellow { color: var(--accent); }
.kpi-card .value.red { color: #f87171; }
.table-empty { padding: 3rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
