:root {
  --bg: #0b1020;
  --bg-2: #0f1a2e;
  --panel: #0f1629;
  --card: #111a33;
  --muted: #9fb0c7;
  --text: #79818b;
  --placeholder: #a9b5c2;
  --brand: #60a5fa; /* blue */
  --brand-2: #22d3ee; /* cyan */
  --accent: #34d399; /* green */
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 20px 60px rgba(0,0,0,0.35);
  /* Scrollbar (dark by default) */
  --scrollbar-thumb: rgba(96,165,250,0.35);
  --scrollbar-thumb-hover: rgba(96,165,250,0.55);
  --scrollbar-track: transparent;
}

/* Light theme variables */
.theme-light {
  --bg: #f6f8fb;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --card: #ffffff;
  --muted: #5b6b7f;
  --text: #0f172a;
  --placeholder: #94a3b8;
  --brand: #2563eb;
  --brand-2: #06b6d4;
  --accent: #16a34a;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
  --scrollbar-thumb: rgba(37,99,235,0.45);
  --scrollbar-thumb-hover: rgba(37,99,235,0.65);
  --scrollbar-track: rgba(0,0,0,0.04);
}

/* .theme-dark intentionally uses root variables */

* { box-sizing: border-box; }
html, body { height: 100%; min-height: 100vh; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, rgba(96,165,250,0.15), transparent 60%),
              radial-gradient(1000px 500px at 110% 10%, rgba(34,211,238,0.12), transparent 50%),
              linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden; /* keep header/footer visible; scroll only main */
}

.app-navbar {
  background: rgba(10, 15, 26, 0.6);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.theme-light .app-navbar {
  background: rgba(0, 0, 0, 0.12);
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.app-navbar .navbar-brand {
  font-weight: 800;
  letter-spacing: 0.4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-main { flex: 1 1 auto; overflow: auto; }

.app-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(10, 15, 26, 0.6);
  padding: 24px 0;
  backdrop-filter: blur(8px);
}

/* Cards */
.card-modern {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

/* Buttons */
.btn-gradient {
  background: linear-gradient(90deg, var(--accent), var(--brand));
  color: #04121f;
  border: none;
  font-weight: 700;
}
.btn-gradient:hover { opacity: 0.95; transform: translateY(-1px); }
.btn-outline-light { border-color: rgba(255,255,255,0.35) !important; color: var(--text) !important; }
.btn-outline-warning { border-color: rgba(245, 158, 11, 0.6) !important; color: var(--warning) !important; }

/* Typography helpers */
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; font-size: 0.78rem; }
.headline-xl { font-weight: 800; letter-spacing: -0.02em; }
.subhead { color: #b9c9de; }

/* Hero */
.hero-wrap {
  padding: 72px 16px 24px;
}
.hero {
  max-width: 960px;
  margin: 0 auto;
  text-align: center;
}
.hero h1.headline-xl {
  font-size: clamp(2.2rem, 4vw + 1rem, 3.5rem);
  background: linear-gradient(90deg, var(--brand-2), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 24px rgba(34,211,238,0.25));
}
.hero .cta { gap: 12px; justify-content: center; }

/* Feature grid */
.feature-grid {
  display: grid; gap: 16px; margin: 36px auto 0; padding: 0 16px; max-width: 1100px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.feature-card {
  padding: 20px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.08);
  background: radial-gradient(200px 120px at 20% -20%, rgba(52,211,153,0.2), transparent 55%),
              linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.03));
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.feature-card:hover { transform: translateY(-3px); border-color: rgba(255,255,255,0.16); }
.feature-card h3 { color: var(--accent); font-weight: 800; font-size: 1.1rem; }
.feature-card p { color: var(--muted); }

/* Tables */
.table-modern { overflow: hidden; border-radius: 14px; border: 1px solid rgba(255,255,255,0.08); }
.table-modern thead { background: rgba(255,255,255,0.06); color: var(--text); }
.table-modern tbody tr:hover { background: rgba(255,255,255,0.03); }
.table-modern table { table-layout: fixed; width: 100%; }
.table-modern th, .table-modern td { vertical-align: middle; }
.table-modern th, .table-modern td { word-break: break-word; overflow-wrap: anywhere; }
.table-modern .col-id { width: 64px; text-align: center; }
.table-modern .col-rank { width: 64px; text-align: center; }
.table-modern .col-xp { width: 120px; text-align: center; }
.table-modern .col-last { width: 160px; text-align: center; }
.table-modern .col-user, .table-modern .col-title, .table-modern .col-tags { text-align: left; }
.questions-table th.col-xp { padding-left: 6px; text-align: left; }
.questions-table td:nth-child(4) { padding-left: 6px; }
.table-modern .col-tags { width: 240px; }
.table-modern .user-cell { display: flex; align-items: center; gap: 10px; }
.table-modern .username { color: var(--brand); font-weight: 600; }

/* More gap between rank and user on leaderboard */
.leaderboard-table td.col-user, .leaderboard-table th.col-user {
  padding-left: 14px;
}

/* Question title link legibility */
.question-link { color: var(--text); text-decoration: none; font-weight: 600; }
.question-link:hover { text-decoration: underline; }

/* Truncation helpers for table cells */
.truncate { display: block; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wrap { white-space: normal; word-break: break-word; }

/* Forms */
.form-control, .form-select, textarea {
  background: rgba(255,255,255,0.04) !important;
  color: var(--text) !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
}
.form-control:focus, .form-select:focus, textarea:focus {
  border-color: rgba(96,165,250,0.6) !important;
  background: rgba(255,255,255,0.06) !important;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.2);
}
/* Lighter placeholders (applies to questions search, etc.) */
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--placeholder) !important;
  opacity: 1; /* ensure consistent appearance across browsers */
}

/* Focus visibility for keyboard users */
:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}

/* Alerts */
.app-alert { border-radius: 10px; border: none; }

/* Utilities */
.container-narrow { max-width: 720px; margin: 0 auto; }
.glass { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); backdrop-filter: blur(12px); }

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Layout grid and sidebar */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 30px;
  align-items: start;
  overflow: hidden; /* prevent children from causing horizontal overflow */
}

@media (max-width: 991px) {
  /* Bring content closer to navbar and use grid gap for separation */
  .container.py-4 { padding-top: 0; margin-top: 0;}
  .layout { grid-template-columns: 1fr; row-gap: 40px; padding-top: 0; margin-top:-70px;}
  .app-sidebar { top: auto; margin-top: 0; margin-bottom: 10rem; }
  .content-scroll { max-height: none; overflow: visible; }
  /* add gentle top padding to main content when stacked */
  .layout > :not(.app-sidebar) { padding-top: 16px; }
  .layout > .app-sidebar { padding-top: 0px; }
  .mobile-small{font-size: 0.7rem;}
}

@media (min-width: 991px) {
  .big-dash{margin-top: 127px;}
}

.nav-mb{
  margin-bottom: 10rem;
}

.app-sidebar {
  position: sticky;
  top: clamp(80px, 18vh, 220px);
  align-self: start;
  min-width: 0; /* allow flex/grid truncation */
}
.app-sidebar .sidebar-inner {
  border: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.03));
  border-radius: 16px;
  padding: 16px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  max-width: 100%;
}
.theme-light .app-sidebar .sidebar-inner {
  border: 1px solid rgba(0,0,0,0.08);
  background: linear-gradient(180deg, rgba(0,0,0,0.06), rgba(0,0,0,0.03));
}
.app-sidebar .brand { color: var(--muted); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.app-sidebar .nav-link {
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  min-width: 0;
}
.app-sidebar .nav-link:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }
.theme-light .app-sidebar .nav-link:hover { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.12); }

/* Ensure text in sidebar links doesn't cause horizontal overflow */
.app-sidebar .nav-link span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Limit vertical growth of large content areas and enable scrolling */
.content-scroll {
  max-height: calc(100vh - 140px);
  overflow: auto;
}

/* Push main content down to visually align with sidebar (use on pages that feel too top-heavy) */
.page-main-offset {
  padding-top: clamp(40px, 12vh, 140px);
}

/* Sticky table headers when scrolling */
.table-modern thead th { position: sticky; top: 0; z-index: 2; }

/* Uniform spacing helpers */
.stack-sm > * + * { margin-top: 8px; }
.stack-md > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 24px; }


/* Improve table readability on small screens */
@media (max-width: 576px) {
  /* Let the browser size columns naturally */
  .table-modern table { table-layout: auto; }

  /* Make ID column a bit narrower */
  .table-modern .col-id { width: 44px; }

  /* Hide Tags (3rd) and the last icon column (5th) */
  .table-modern table thead th:nth-child(3),
  .table-modern table tbody td:nth-child(3),
  .table-modern table thead th:nth-child(5),
  .table-modern table tbody td:nth-child(5) { display: none; } /* Hide the last icon column */

  /* Allow question titles to wrap instead of truncating */
  .table-modern .truncate { white-space: normal; overflow: visible; text-overflow: clip; }

  /* Keep difficulty compact */
  .table-modern .col-xp { width: 96px; }
}

/* Password reveal toggle */
.password-wrapper { position: relative; }
.password-wrapper .toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 4px;
  line-height: 1;
}
.password-wrapper .toggle-password:hover { color: var(--text); }
.password-wrapper input.form-control { padding-right: 44px; }

/* Hide native Edge/IE password reveal/clear to avoid double-eye */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none; }

/* Themed minimal scrollbars (Firefox + WebKit) */
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* WebKit */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
*::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box; /* creates a thin thumb */
}
*::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

/* --- Light theme definition improvements --- */
.theme-light .subhead { color: #475569; }

.theme-light .card-modern {
  background: linear-gradient(180deg, rgba(0,0,0,0.02), rgba(0,0,0,0.01));
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.theme-light .glass {
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.08);
}

.theme-light .table-modern thead {
  background: rgba(0,0,0,0.04);
}
.theme-light .table-modern tbody tr:hover {
  background: rgba(0,0,0,0.03);
}
.theme-light .table-striped>tbody>tr:nth-of-type(odd)>* {
  --bs-table-accent-bg: rgba(0,0,0,0.02);
}

.theme-light .form-control,
.theme-light .form-select,
.theme-light textarea {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid rgba(0,0,0,0.14) !important;
}
.theme-light .form-control:focus,
.theme-light .form-select:focus,
.theme-light textarea:focus {
  border-color: rgba(37,99,235,0.5) !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.theme-light .btn-outline-light {
  border-color: rgba(0,0,0,0.25) !important;
  color: #0f172a !important;
}

.theme-light .app-footer {
  /* Match the light navbar styling */
  background: rgba(0, 0, 0, 0.12);
  border-top: 1px solid rgba(0,0,0,0.08);
}

/* Footer link visibility and hover contrast */
.app-footer a {
  /* Match AmazingSQL brand text style */
  font-weight: 800;
  letter-spacing: 0.4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent; /* fallback */
  text-decoration: none;
}
.app-footer a:hover,
.app-footer a:focus {
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: underline;
}



