:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --success-hover: #059669;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #0b1329;
  --bg-card: #15203b;
  --bg-card-sub: #1e294b;
  --border: rgba(255, 255, 255, 0.09);
  --border-focus: rgba(59, 130, 246, 0.5);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }
body { background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }

/* Navbar */
.navbar {
  background: rgba(21, 32, 59, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Tabs Navigation in Navbar */
.tab-nav {
  display: flex;
  background: rgba(11, 19, 41, 0.7);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

.pill-mini {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

/* Main Container */
.main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
}

@media (max-width: 992px) {
  .main-content { grid-template-columns: 1fr; }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: rgba(11, 19, 41, 0.7);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: #ffffff;
  font-size: 13.5px;
  outline: none;
  transition: all 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

textarea.form-control {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
}
.btn-success:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

.btn-block { width: 100%; }

/* Question Preview List */
.questions-container {
  flex: 1;
  overflow-y: auto;
  max-height: 560px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 6px;
}

.question-card {
  background: var(--bg-card-sub);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  transition: all 0.2s;
  position: relative;
}

.question-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.question-num {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.question-text {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.45;
  flex: 1;
}

.preview-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.preview-option-item {
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  color: #cbd5e1;
}

.preview-option-item.correct {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  font-weight: 700;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-icon {
  padding: 4px 8px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* Login Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.alert-box {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-box.success { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.3); color: #34d399; }
.alert-box.error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: #f87171; }
.alert-box.info { background: rgba(59, 130, 246, 0.15); border: 1px solid rgba(59, 130, 246, 0.3); color: #93c5fd; }

/* Tab Panes */
.tab-pane {
  display: none !important;
}
.tab-pane.active {
  display: grid !important;
}
.main-content-single.tab-pane.active {
  display: flex !important;
  flex-direction: column;
}

.main-content-single {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  gap: 20px;
}

/* Stats Banner */
.stats-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 22px;
  display: flex;
  align-items: center;
  gap: 30px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-icon {
  font-size: 28px;
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-val {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
}

/* Bank Filters */
.bank-filters {
  display: flex;
  gap: 14px;
  align-items: center;
}

/* GitHub Contests & Questions Display */
.github-contests-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.contest-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.contest-header {
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.contest-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.contest-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.contest-name {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.contest-id-tag {
  font-size: 11px;
  color: #94a3b8;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 8px;
  border-radius: 6px;
  font-family: monospace;
}

.contest-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================================ */
/* Progress Bar & Spinner Animation                             */
/* ============================================================ */
.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #06b6d4, #10b981);
  background-size: 200% 100%;
  animation: shimmerProgress 1.5s infinite linear;
  border-radius: 999px;
  transition: width 0.35s ease;
}

@keyframes shimmerProgress {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.spinner-ring {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(96, 165, 250, 0.25);
  border-top-color: #60a5fa;
  border-radius: 50%;
  display: inline-block;
  animation: spinRing 0.7s infinite linear;
}

@keyframes spinRing {
  to { transform: rotate(360deg); }
}

/* ============================================================ */
/* Mobile Responsive Optimization (Trình duyệt điện thoại)      */
/* ============================================================ */
@media (max-width: 768px) {
  .navbar {
    padding: 10px 12px;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .brand {
    justify-content: flex-start;
  }

  .brand-name {
    font-size: 16px;
  }

  .tab-nav {
    width: 100%;
    display: flex;
  }

  .tab-btn {
    flex: 1;
    justify-content: center;
    padding: 8px 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .nav-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: space-between;
  }

  .nav-btn {
    flex: 1;
    justify-content: center;
    padding: 7px 8px;
    font-size: 11.5px;
    white-space: nowrap;
  }

  #token-status-tag {
    width: 100%;
    justify-content: center;
    font-size: 11px;
    padding: 5px 8px;
    order: -1;
  }

  .main-content, .main-content-single {
    padding: 12px 10px;
    gap: 16px;
  }

  .card {
    padding: 16px 14px;
    border-radius: 12px;
  }

  .card-header {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 10px;
  }

  .card-title {
    font-size: 14.5px;
  }

  .form-label {
    font-size: 12.5px;
  }

  .form-control {
    font-size: 16px; /* 16px prevents iOS Safari from auto-zooming page on tap */
    padding: 10px 12px;
    border-radius: 8px;
  }

  #txt-raw-input {
    min-height: 180px;
  }

  .btn {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 10px;
    min-height: 44px; /* Touch friendly */
  }

  .questions-container {
    max-height: 480px;
  }

  .question-card {
    padding: 12px;
    border-radius: 10px;
  }

  .question-text {
    font-size: 13.5px;
    line-height: 1.45;
  }

  .preview-option-item {
    font-size: 12.5px;
    padding: 8px 10px;
  }

  /* Modals on mobile */
  .modal-box {
    width: 95% !important;
    max-width: 95% !important;
    padding: 20px 16px !important;
    margin: 10px auto;
  }

  .stats-banner {
    padding: 12px 14px;
    gap: 16px;
  }

  .stat-val {
    font-size: 18px;
  }

  .contest-header {
    padding: 12px 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .contest-title-wrap {
    gap: 8px;
  }

  .contest-name {
    font-size: 14.5px;
  }

  #tab-extension-settings > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================ */
/* Extension Settings Toggles & Controls UI                     */
/* ============================================================ */
.switch-ui {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.switch-ui input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-ui {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.slider-ui:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 2px;
  background-color: #ffffff;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.switch-ui input:checked + .slider-ui {
  background-color: #2563eb;
  border-color: #3b82f6;
}

.switch-ui input:checked + .slider-ui:before {
  transform: translateX(20px);
  background-color: #ffffff;
}

.btn-speed-opt {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.btn-speed-opt:hover {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #ffffff;
}

.btn-speed-opt.active {
  background: rgba(37, 99, 235, 0.25);
  border-color: #3b82f6;
  color: #60a5fa;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

