/* =========================
   CSS RESET & VARIABLES
   ========================= */
   
:root {
  --bg: #0f172a;            /* slate-900 */
  --panel: #111827;         /* gray-900 */
  --card: #1f2933;          /* gray-800 */
  --text: #e5e7eb;          /* gray-200 */
  --muted: #9ca3af;         /* gray-400 */
  --accent: #38bdf8;        /* sky-400 */
  --success: #22c55e;       /* green-500 */
  --danger: #ef4444;        /* red-500 */
  --border: #334155;        /* slate-700 */
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, #020617, #0f172a);
  color: var(--text);
  min-height: 100vh;
}

/* =========================
   LAYOUT
   ========================= */
.container {
  max-width: 1200px;
  margin: auto;
  padding: 1rem;
}

header {
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
}

header p {
  color: var(--muted);
  margin-top: 0.25rem;
}

/* =========================
   TABS
   ========================= */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab-button {
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-button:hover {
  background: #273449;
}

.tab-button.active {
  background: var(--accent);
  color: #020617;
  font-weight: 600;
}

/* =========================
   PANELS / CARDS
   ========================= */
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

/* =========================
   BUTTONS
   ========================= */
button {
  border-radius: var(--radius);
  border: none;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

.primary {
  background: var(--accent);
  color: #020617;
  font-weight: 600;
}

.secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.success {
  background: var(--success);
  color: #022c22;
}

input[type="file"] {
  background: var(--card);
  padding: 0.6rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text);
  width: 100%;
}

/* =========================
   TABLE
   ========================= */
.table-wrapper {
  overflow-x: auto;
  margin-top: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

thead {
  background: #020617;
}

th, td {
  padding: 0.75rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--accent);
}

tbody tr:hover {
  background: #020617;
}

tfoot td {
  font-weight: 700;
  background: #020617;
}

/* =========================
   CHART AREA
   ========================= */
.chart-container {
  width: 100%;
  height: 420px;
  padding: 1rem;
}

/* =========================
   METRICS / BADGES
   ========================= */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge.danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* =========================
   FOOTER ACTIONS
   ========================= */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.5rem;
  }

  .tabs {
    justify-content: center;
  }

  table {
    font-size: 0.85rem;
  }

  .chart-container {
    height: 300px;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.25rem;
  }

  th, td {
    padding: 0.5rem;
  }

  button {
    width: 100%;
  }

  .actions {
    flex-direction: column;
  }
}

/* ===== TAB VISIBILITY ===== */
.tab {
  display: none;
}

.tab.active {
  display: block;
}

/* ===== INPUTS ===== */
input[type="number"] {
  background: #020617;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.4rem;
  border-radius: 8px;
  width: 80px;
  text-align: center;
}

/* =========================
   DARK / LIGHT MODE
   ========================= */

body {
  transition: background 0.3s ease, color 0.3s ease;
}

/* Light mode variables */
body.light {
  --bg: #f8fafc;
  --panel: #ffffff;
  --card: #f1f5f9;
  --text: #020617;
  --muted: #475569;
  --border: #cbd5f5;
  background: linear-gradient(135deg, #f8fafc, #e2e8f0);
}

/* Toggle button */
.theme-toggle {
  margin-top: 1rem;
  align-self: center;
}

/* Fix table text in light mode */
body.light table {
  color: var(--text);
}

body.light thead {
  background: #e5e7eb;
}

body.light tfoot td {
  background: #e5e7eb;
}

/* =========================
   LIGHT MODE FIXES
   ========================= */

body.light {
  color: var(--text);
}

/* Tables */
body.light table {
  background: var(--panel);
  color: var(--text);
}

body.light th {
  background: #e5e7eb;
  color: #020617;
}

body.light td {
  color: #020617;
  background: #ffffff;
}

body.light tbody tr:hover {
  background: #f1f5f9;
}

body.light tfoot td {
  background: #e5e7eb;
  color: #020617;
}

/* Inputs */
body.light input {
  background: #ffffff;
  color: #020617;
  border: 1px solid #cbd5e1;
}

body.light input::placeholder {
  color: #64748b;
}

/* Buttons */
body.light button {
  color: #020617;
}

body.light .secondary {
  background: #e5e7eb;
  border: 1px solid #cbd5e1;
}

/* Upload / result table visibility */
body.light #resultTable {
  background: #ffffff;
}

/* Chart canvas background */
body.light canvas {
  background: #ffffff;
}

/* Borders */
body.light th,
body.light td {
  border-bottom: 1px solid #cbd5e1;
}
