@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&display=swap');

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #0a0e1a; /* Updated (Option A): Deep navy applied globally across the canvas */
  color: #e5e7eb;
  display: flex;
  min-height: 100vh;
  flex-direction: row;
}

/* =========================
   SIDEBAR
========================= */
.sidebar {
  width: 220px;
  background: linear-gradient(180deg, #25272b 0%, #141619 100%); /* Gunmetal gray to dark gradient */
  min-height: 100vh;
  height: auto;
  padding: 20px;
  box-sizing: border-box;
  border-right: 1px solid #2d3139; /* Cleaner contrast with new sidebar */
}

.sidebar .logo-container {
  width: 170px;
  margin-bottom: 20px;
}

.sidebar .logo-container img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}

.sidebar h2 {
  color: #60a5fa;
  font-size: 18px;
  margin-bottom: 20px;
  font-family: 'Orbitron', sans-serif;
}

.nav-item {
  display: block;
  width: 170px;
  padding: 10px;
  margin: 6px 0;
  border-radius: 8px;
  cursor: pointer;
  color: #94a3b8;
  text-decoration: none;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05); /* Subtle overlay hover */
  color: #fff;
  padding-left: 14px; /* Optional UI flavor: slight text push on hover */
}

.nav-item.active {
  background: rgba(96, 165, 250, 0.15); /* Distinct active indicator */
  border-left: 3px solid #60a5fa; /* Left indicator accent */
  color: #fff;
}

.sidebar-beta-code {
  width: 170px;
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: rgba(17, 24, 39, 0.75);
}

.sidebar-beta-code-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  margin-bottom: 6px;
}

.sidebar-beta-code-value {
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 700;
  word-break: break-word;
}

.sidebar-toggle-btn {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid #1f2937;
  border-radius: 10px;
  background: #111827;
  color: #e5e7eb;
  font-weight: 700;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
}

/* =========================
   MAIN WRAPPER
========================= */
.main {
  flex: 1;
  padding: 26px;
  background: #0f172a !important; /* Forces the deep navy color on the right pane */
  min-height: 100vh;             /* Ensures it stretches the full height of the screen */
}

/* =========================
   HERO HEADER
========================= */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.commander-name {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.commander-name select {
  background: #111827;
  border: 1px solid #1f2937;
  color: #e5e7eb;
  font-size: 18px;
  padding: 10px 12px;
  border-radius: 10px;
  min-width: 170px;
  max-width: 260px;
}

.hero-left,
.hero-right {
  display: flex;
  align-items: center;
}

.hero-right {
  justify-content: flex-end;
}

.subtext-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 170px;
  max-width: 260px;
  margin-top: 0;
}

.subtext {
  font-size: 18px;
  font-weight: 700;
  color: #94a3b8;
}

.trend {
  background: #111827;
  border: 1px solid #1f2937;
  padding: 10px 14px;
  border-radius: 10px;
  color: #22c55e;
  font-weight: 600;
}

/* =========================
   SELECTION PANEL
========================= */
.selection-panel {
  background: #111827;
  border: 1px solid rgba(96, 165, 250, 0.2); /* Subtle colored border */
  border-radius: 16px;
  padding: 10px;
  margin-top: 20px;
  box-shadow: 0 0 25px rgba(96, 165, 250, 0.05); /* Ambient backdrop glow */
}

.selection-text {
  color: #cbd5e1;
  font-size: 14px;
  margin-bottom: 18px;
}

.selection-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.selection-fields label {
  display: block;
  color: #9ca3af;
  font-size: 11px;
  text-transform: uppercase; /* Tactical HUD label aesthetic */
  letter-spacing: 0.05em;
  font-weight: 600;
}

.selection-fields input,
.selection-fields select,
.selection-fields textarea {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #1f2937;
  background: #0b1220; /* Inner fields contrasted against card */
  color: #e5e7eb;
  font-size: 14px;
  transition: all 0.25s ease;
}

.selection-fields input:focus,
.selection-fields select:focus,
.selection-fields textarea:focus {
  border-color: #3b82f6; /* Focus highlight color */
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.35); /* Focus glow */
  outline: none;
}

.selection-fields textarea {
  min-height: 180px;
  resize: vertical;
}

.submit-button,
.confirm-button {
  margin-top: 18px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); /* Vibrant gradient background */
  color: #ffffff; /* High contrast crisp white text */
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3);
}

.submit-button:hover,
.confirm-button:hover {
  background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%); /* Lively hover transition state */
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.45);
}


/* =========================
   KPI GRID
========================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

/* KPI CARD */
.kpi-card {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left-width: 6px;
  border-left-style: solid;
  border-radius: 18px;
  padding: 18px 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32), 0 0 0 rgba(0, 0, 0, 0);
  --accent-glow: rgba(255, 255, 255, 0.12);
  text-align: center;
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.38), 0 0 24px var(--accent-glow);
}

.kpi-value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 6px;
}

.kpi-label {
  font-family: 'Press Start 2P', retro arcade;
  font-size: 14px;
  color: #9ca3af;
  margin: 0 auto 8px;
}

.kpi-delta {
  font-size: 12px;
  margin-top: 10px;
  color: #22c55e;
}

/* ACCENTS */
.kpi-card.blue {
  border-left-color: #60a5fa;
  --accent-glow: rgba(96, 165, 250, 0.45);
}
.kpi-card.purple {
  border-left-color: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.45);
}
.kpi-card.orange {
  border-left-color: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.45);
}
.kpi-card.green {
  border-left-color: #22c55e;
  --accent-glow: rgba(34, 197, 94, 0.45);
}
.kpi-card.red {
  border-left-color: #ef4444;
  --accent-glow: rgba(239, 68, 68, 0.45);
}
.kpi-card.teal {
  border-left-color: #14b8a6;
  --accent-glow: rgba(20, 184, 166, 0.45);
}

.kpi-card.blue .kpi-label { color: #60a5fa; }
.kpi-card.orange .kpi-label { color: #f59e0b; }
.kpi-card.purple .kpi-label { color: #a78bfa; }
.kpi-card.green .kpi-label { color: #22c55e; }
.kpi-card.red .kpi-label { color: #ef4444; }
.kpi-card.teal .kpi-label { color: #14b8a6; }

/* =========================
   CHART SECTION
========================= */
.chart-section {
  margin-top: 10px;
}

.section-title {
  font-size: 14px;
  color: #9ca3af;
  margin-bottom: 10px;
}

.history-table thead th.sortable { cursor: pointer; }

.history-table thead th.sortable::after { content: ''; margin-left: 8px; color: #9ca3af; }
.history-table thead th.sortable.sort-asc::after { content: '▲'; }
.history-table thead th.sortable.sort-desc::after { content: '▼'; }

/* 🔥 FIXED CHART CONTAINER */
.chart-box {
  background: #111827;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid #1f2937;
  height: 420px;
  position: relative;
  overflow: hidden;
}

/* FORCE CANVAS TO RENDER CLEANLY */
.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

/* extra polish for Chart.js rendering */
.chart-box canvas {
  image-rendering: -webkit-optimize-contrast;
}

/* =========================
   RESPONSIVE LAYOUT
========================= */
@media (max-width: 960px) {
  body {
    flex-direction: row;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: 250px;
    height: 100vh;
    padding: 16px 18px;
    border-right: 1px solid #1f2937;
    border-bottom: none;
    background: #25272b;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
  }

  .sidebar .logo-container {
    width: 120px;
    margin-bottom: 14px;
  }

  .nav-item {
    width: 100%;
    max-width: none;
    padding: 12px 14px;
  }

  .main {
    padding: 20px;
    width: 100%;
  }

  .sidebar-toggle-btn {
    display: inline-flex;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(2, 6, 23, 0.55);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .hero {
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
  }

  .commander-name select {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .chart-box {
    height: 340px;
  }
}

@media (max-width: 640px) {
  .sidebar {
    width: 235px;
    padding: 14px 16px;
  }

  .sidebar h2 {
    font-size: 16px;
  }

  .nav-item {
    padding: 10px 12px;
    font-size: 14px;
  }

  .main {
    padding: 16px;
  }

  .hero {
    align-items: flex-start;
  }

  .commander-name {
    flex-direction: column;
    gap: 10px;
  }

  .commander-name select {
    min-width: 100%;
  }

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

  .chart-box {
    height: 280px;
  }

  .selection-panel,
  .chart-box,
  .kpi-card {
    border-radius: 12px;
  }

  .history-table th,
  .history-table td {
    padding: 8px 10px;
  }
}

/* =========================
   HISTORY TABLE
========================= */
.history-table-wrap {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  background: #111827; /* Match container depth */
  border: 1px solid #1f2937;
}

.history-table th,
.history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #1f2937;
  text-align: left;
}

.history-table thead th {
  color: #cbd5e1;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.history-empty, .history-error {
  color: #9ca3af;
  padding: 12px;
}

.error-text {
  color: #ef4444;
  font-size: 13px;
  margin-top: 8px;
}

.history-table td {
  font-size: 13px;
}

.delta-positive {
  color: #22c55e;
  font-weight: 700;
}

.delta-negative {
  color: #ef4444;
  font-weight: 700;
}

.delta-neutral {
  color: #9ca3af;
}

.individual-metric-title {
  margin-bottom: 10px;
  font-weight: 700;
  text-align: center;
  font-size: 16px;
}

.individual-metric-blue {
  color: #60a5fa;
}

.individual-metric-orange {
  color: #f59e0b;
}

.individual-metric-purple {
  color: #a78bfa;
}

.individual-metric-green {
  color: #22c55e;
}

.individual-metric-red {
  color: #ef4444;
}

.individual-metric-teal {
  color: #14b8a6;
}

/* Disabled/readonly selection fields on input page */
input[disabled], input[readonly] {
  background: #0b1220;
  color: #94a3b8;
  border: 1px solid #1f2937;
  padding: 8px;
}

/* =========================
   OPTIONAL: subtle page polish
========================= */
* {
  box-sizing: border-box;
}

.page-footer {
  margin-top: auto;
  text-align: center;
  font-size: 11px;
}

body {
  min-height: 100vh;
}

.main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-footer {
  margin-top: auto;
  text-align: center;
  font-size: 11px;
}

.beta-access {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.beta-access input {
  width: 320px;
  max-width: 90%;
  padding: 14px;
  font-size: 16px;
  text-align: center;
  border: 2px solid #3b82f6;
  border-radius: 8px;
  background: #111827;
  color: white;
  outline: none;
}

.beta-access input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.beta-access button {
  width: 180px;
  padding: 14px;
  font-size: 16px;
  font-weight: bold;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
}

.beta-access button:hover {
  background: #1d4ed8;
}

#errorMessage {
  color: #ef4444;
  font-weight: bold;
  min-height: 20px;
}

.input-footer {
  margin-top: 16px;
}

.input-selection-panel {
  margin-top: 0;
}

.individual-footer {
  margin-top: 24px;
}

#admin-login-button {
  justify-self: start;
  width: auto;
}

