/* ============================================================
   BASE.CSS - CSS Variables, Typography, Reset
   ============================================================ */

:root {
  /* Primary Colors (Dark Mode) */
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --border: #475569;
  --border-hi: #64748b;
  --text: #f1f5f9;
  --muted: #94a3b8;

  /* Accent Colors */
  --accent: #6366f1;
  --accent2: #8b5cf6;
  --cyan: #06b6d4;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --orange: #f97316;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Transitions */
  --transition-fast: 0.15s ease-in-out;
  --transition-base: 0.25s ease-in-out;
  --transition-slow: 0.35s ease-in-out;

  /* Typography */
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Z-index */
  --z-dropdown: 100;
  --z-modal: 1000;
  --z-toast: 1001;
}

/* Light Mode Overrides */
body.light-mode {
  --bg: #ffffff;
  --surface: #f8fafc;
  --surface2: #e2e8f0;
  --border: #cbd5e1;
  --border-hi: #94a3b8;
  --text: #0f172a;
  --muted: #64748b;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  /* Flex column is declared here (not on .shell) so that #app-content can
     grow with `flex: 1` and the footer sticks to the bottom on short pages.
     Previously this was on .shell, which was used twice in the DOM and
     produced a full-viewport empty area at the top of every page. */
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* ========== TYPOGRAPHY ========== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
}

h1 { font-size: 32px; margin-bottom: 16px; }
h2 { font-size: 24px; margin-bottom: 12px; }
h3 { font-size: 18px; margin-bottom: 8px; }
h4 { font-size: 16px; margin-bottom: 8px; }
h5 { font-size: 14px; margin-bottom: 6px; }
h6 { font-size: 12px; margin-bottom: 4px; }

p {
  margin: 0;
  margin-bottom: 12px;
}

p:last-child {
  margin-bottom: 0;
}

/* ========== CODE BLOCKS ========== */
code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(99, 102, 241, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent);
  line-height: 1.4;
}

pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  overflow-x: auto;
  margin: var(--spacing-md) 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}

pre code {
  background: transparent;
  padding: 0;
  color: var(--text);
  border-radius: 0;
}

/* ========== LINKS ========== */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
  cursor: pointer;
}

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

a:active {
  opacity: 0.8;
}

/* ========== LISTS ========== */
ul, ol {
  margin: 0 0 12px 20px;
  padding: 0;
}

li {
  margin-bottom: 6px;
}

/* ========== TABLES ========== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
}

.table-container[style*="max-height"] thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface2);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--spacing-md) 0;
}

thead {
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
}

th {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

td {
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: var(--surface2);
}

/* ========== FORM ELEMENTS ========== */
input, textarea, select {
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--text);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface2);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input:disabled, textarea:disabled, select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  font-family: var(--font-mono);
  min-height: 100px;
}

/* ========== SCROLLBARS ========== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hi);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ========== UTILITIES ========== */
.hidden {
  display: none !important;
}

.invisible {
  visibility: hidden;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-left {
  text-align: left;
}

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

.text-success {
  color: var(--green);
}

.text-danger {
  color: var(--red);
}

.text-warning {
  color: var(--yellow);
}

.text-info {
  color: var(--accent);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }

.m-sm { margin: var(--spacing-sm); }
.m-md { margin: var(--spacing-md); }
.m-lg { margin: var(--spacing-lg); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
