:root {
  /* Core Colors */
  --clr-bg: #0A1929;
  --clr-surface: #11121a;
  --clr-surface-alt: #111c28;
  --clr-border: #122d49;
  --clr-line: #42434a;
  --clr-hover: #222533;
  
  /* Brand Colors */
  --clr-primary: #10b981; /* Emerald Green */
  --clr-secondary: #3b82f6; /* Bright Blue */
  --clr-tertiary: #8b5cf6; /* Violet */
  --clr-accent: #f59e0b; /* Amber/Gold - Gotham style */
  --clr-accent-alt: #f97316; /* Orange */
  
  /* Text Colors */
  --clr-text: #e6e6ef;
  --clr-text-muted: #b0b3c1;
  --clr-text-label: #8d979e;
  
  /* Input Colors */
  --clr-input-bg: #1f1f21;
  --clr-input-border: #3f3f46;
  --clr-input-focus: #10b981;

  /* Status Colors */
  --clr-error: #b53c38;
  --clr-success: #4caf50;
  --clr-warning: #f0ad4e;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Fonts */
  --font-main: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

  /* Theme-aware transparency (defaults to dark) */
  --clr-card-header-bg: rgba(0, 0, 0, 0.3);
  --clr-card-border: rgba(255, 255, 255, 0.08);
  --clr-card-header-border: rgba(255, 255, 255, 0.03);
  --clr-question-bg: rgba(255, 255, 255, 0.01);
  --clr-nav-hover: rgba(255, 255, 255, 0.08);
}

/* Light Theme Overrides */
body.light-theme {
  --clr-bg: #f8fafc;
  --clr-surface: #ffffff;
  --clr-surface-alt: #f1f5f9;
  --clr-border: #e2e8f0;
  --clr-line: #cbd5e1;
  --clr-hover: #f1f5f9;

  --clr-text: #0f172a;
  --clr-text-muted: #475569;
  --clr-text-label: #64748b;

  --clr-input-bg: #ffffff;
  --clr-input-border: #cbd5e1;

  --clr-card-header-bg: rgba(0, 0, 0, 0.04);
  --clr-card-border: rgba(0, 0, 0, 0.08);
  --clr-card-header-border: rgba(0, 0, 0, 0.05);
  --clr-question-bg: rgba(0, 0, 0, 0.01);
  --clr-nav-hover: rgba(0, 0, 0, 0.05);
}

html {
  font-family: var(--font-main);
  line-height: 1.5;
  background-color: var(--clr-bg);
}

body {
  min-height: 100vh;
  background-color: var(--clr-bg);
  color: var(--clr-text);
  display: grid;
  grid-template-columns: auto 1fr;
  font-size: 1rem;
  margin: 0;
}

/* Base Elements */
input, textarea, select {
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--clr-input-bg);
  color: var(--clr-text);
  border: 1px solid var(--clr-input-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--clr-input-focus);
}

button {
  font-family: inherit;
  cursor: pointer;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  transition: opacity 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

button:hover {
  filter: brightness(1.2);
}

/* button:active {
  transform: translateY(1px);
} */

/* Sidebar Styles */
#sidebar {
  box-sizing: border-box;
  height: 100vh;
  width: 280px;
  padding: var(--space-sm) 1em;
  background-color: var(--clr-surface);
  border-right: 1px solid var(--clr-line);
  position: sticky;
  top: 0;
  align-self: start;
  transition: 300ms ease-in-out;
  overflow: hidden;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
}

#sidebar * {
  margin: 0;
  padding: 0;
}

#sidebar.close {
  padding: var(--space-sm);
  width: 60px;
}

#sidebar.close .logo {
  display: none;
}

#sidebar.close li span {
  display: none;
}

#sidebar.close li:first-child {
  justify-content: center;
  padding: 0;
}

#sidebar ul {
  list-style: none;
}

#sidebar .main-menu {
  flex: 1;
}

#sidebar .bottom-menu {
  margin-top: auto;
  border-top: 1px solid var(--clr-line);
  padding-top: var(--space-sm);
  margin-bottom: var(--space-sm);
}

#sidebar .main-menu > li:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding: 0 0.5em;
}

#sidebar .logo a {
  padding: 0;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--clr-accent);
  background: none;
}

#sidebar .logo a:hover {
  background: none;
}

#sidebar a, #sidebar .dropdown-btn, #toggle-btn {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.85em;
  text-decoration: none;
  color: var(--clr-text);
  display: flex;
  align-items: center;
  gap: 1em;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
  transition: background-color 0.2s;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
}

#sidebar li span {
  font-size: 1rem;
}

#sidebar .sub-menu {
  display: none;
  list-style: none;
  padding-left: 3.5em; /* Indent sub-items */
}

#sidebar .sub-menu.show {
  display: block;
}

#sidebar.close .sub-menu {
  display: none !important; /* Hide submenus when sidebar is collapsed */
}

#sidebar .dropdown-btn {
  justify-content: space-between;
}

#sidebar .dropdown-btn div {
  display: flex;
  align-items: center;
  gap: 1em;
}

#toggle-btn {
  width: auto;
  padding: 0.5em;
  transition: transform 0.3s ease;
}

#sidebar.close #toggle-btn {
  transform: rotate(180deg);
}

#sidebar a:hover, #sidebar .dropdown-btn:hover, #toggle-btn:hover {
  background-color: var(--clr-hover);
}

.rotate svg:last-child {
  transform: rotate(180deg);
}

#sidebar li.active > a, #sidebar li.active > .dropdown-btn {
  color: var(--clr-accent-alt);
}

#sidebar li.active > a svg, #sidebar li.active > .dropdown-btn svg {
  fill: var(--clr-accent-alt);
}

#sidebar svg {
  flex-shrink: 0;
  fill: var(--clr-text);
  transition: transform 0.3s ease;
}

main {
  padding: min(var(--space-xl), 7%);
  line-height: 1.6;
}

/* Utility Classes */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }
.p-md { padding: var(--space-md); }
.w-full { width: 100%; }

/* Layout Utilities */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.grid {
  display: grid;
  gap: var(--space-md);
}

/* Card Component */
.card {
  background: var(--clr-surface-alt);
  border: 1px solid var(--clr-card-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  overflow: hidden;
  transition: all 0.2s ease;
}

.card:hover {
  border-color: var(--clr-line);
}

.card-header {
  background: var(--clr-card-header-bg);
  padding: var(--space-xs) var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border-bottom: 1px solid var(--clr-card-header-border);
  cursor: pointer;
  user-select: none;
}

.card-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.collapse-icon {
  transition: transform 0.2s ease;
  color: var(--clr-text-muted);
}

.card.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.card.collapsed .card-body {
  display: none;
}

.card.collapsed .card-header {
  border-bottom: none;
}

.card-body {
  padding: var(--space-md);
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn:active {
  filter: brightness(0.9);
}

.btn-primary { background-color: var(--clr-primary); color: white; }
.btn-secondary { background-color: var(--clr-secondary); color: white; }
.btn-accent { background-color: var(--clr-accent); color: white; }
.btn-danger { background-color: var(--clr-error); color: white; }
.btn-ghost { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--clr-line); color: var(--clr-text); }

.btn svg {
  flex-shrink: 0;
}

.btn-sm { padding: var(--space-xs) var(--space-sm); font-size: 0.8rem; }
.btn-xs { padding: 2px 6px; font-size: 0.7rem; }

@media(max-width: 800px) {
  body {
    grid-template-columns: 1fr;
  }
  main {
    padding: 2em 1em 60px 1em;
  }
  #sidebar {
    height: 60px;
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--clr-line);
    padding: 0;
    position: fixed;
    top: unset;
    bottom: 0;
    z-index: 100;
  }
  #sidebar > ul {
    display: grid;
    grid-auto-columns: 60px;
    grid-auto-flow: column;
    align-items: center;
    overflow-x: auto;
  }
  #sidebar li span, #sidebar li:first-child {
    display: none;
  }
}
