/* ============================================================
   HỆ THỐNG THI TRẮC NGHIỆM TRỰC TUYẾN - TIỆN ÍCH CÔNG (TIC)
   Modern, Premium & Responsive Stylesheet
   ============================================================ */

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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  --primary-glow: rgba(37, 99, 235, 0.25);
  
  --party-red: #dc2626;
  --party-red-gradient: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  --party-gold: #f59e0b;
  --party-gold-gradient: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);

  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --info: #0284c7;
  --info-bg: #f0f9ff;

  --bg-main: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.07), 0 4px 10px -2px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 16px 40px -8px rgba(15, 23, 42, 0.1), 0 6px 16px -4px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 0 25px rgba(37, 99, 235, 0.2);

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 15% 10%, rgba(37, 99, 235, 0.06) 0px, transparent 50%),
    radial-gradient(at 85% 20%, rgba(220, 38, 38, 0.05) 0px, transparent 40%),
    radial-gradient(at 50% 90%, rgba(245, 158, 11, 0.04) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   CONTAINER & LAYOUT
   ============================================================ */
.app-portal-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 24px 80px 24px;
}

@media (max-width: 640px) {
  .app-portal-container {
    padding: 16px 14px 60px 14px;
  }
}

/* ============================================================
   TOP NAVIGATION
   ============================================================ */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 32px;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-logo img {
  height: 44px;
  width: auto;
  object-fit: contain;
  transition: transform 0.25s ease;
}

.brand-logo:hover img {
  transform: scale(1.04);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.btn-nav-outline {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-nav-outline:hover {
  background: var(--surface-subtle);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.btn-nav-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-nav-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* ============================================================
   HERO / PORTAL HEADER
   ============================================================ */
.portal-header {
  text-align: center;
  margin: 10px auto 36px auto;
  max-width: 780px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(220, 38, 38, 0.08));
  color: #1e3a8a;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(37, 99, 235, 0.2);
  margin-bottom: 16px;
}

.brand-badge i {
  color: var(--party-red);
  font-size: 1rem;
}

.brand-badge h1 {
  font-size: 0.88rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 0;
  display: inline;
}

.portal-title-hero {
  font-size: 2.2rem;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: -0.8px;
  line-height: 1.25;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #0f172a 30%, #1e40af 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

@media (max-width: 640px) {
  .portal-title-hero {
    font-size: 1.65rem;
  }
}

.portal-subtitle {
  font-size: 0.98rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Feature chips bar under hero */
.feature-pills-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.feature-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.feature-pill i {
  color: var(--primary);
}

/* ============================================================
   ACTIVE QUIZZES GRID & CARDS
   ============================================================ */
#active-quizzes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

@media (max-width: 480px) {
  #active-quizzes-list {
    grid-template-columns: 1fr;
  }
}

.quiz-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.quiz-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.quiz-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(37, 99, 235, 0.4);
}

.quiz-card:hover::before {
  opacity: 1;
}

.quiz-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.quiz-badge {
  font-size: 0.74rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.2px;
}

.badge-active {
  background: var(--success-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-active i {
  color: #10b981;
  font-size: 7px;
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.badge-upcoming {
  background: var(--warning-bg);
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-ended {
  background: var(--danger-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.quiz-card-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 10px;
  line-height: 1.4;
}

.quiz-card-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.quiz-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.quiz-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.quiz-card-footer {
  border-top: 1px solid var(--surface-subtle);
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-submit,
.btn-primary-action {
  background: var(--primary-gradient);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px var(--primary-glow);
  text-decoration: none;
}

.btn-submit:hover,
.btn-primary-action:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

.btn-submit:active,
.btn-primary-action:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--surface-subtle);
  border-color: var(--border-hover);
}

.btn-submit:disabled,
.btn-primary-action:disabled {
  background: #cbd5e1 !important;
  color: #64748b !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  transform: none !important;
}

/* ============================================================
   EXAM TAKING SCREEN (MAIN AREA)
   ============================================================ */
#quiz-main-area {
  max-width: 900px;
  margin: 0 auto;
}

/* Banner cuộc thi */
.exam-banner {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 22px 28px;
  margin-bottom: 22px;
  box-shadow: 0 10px 30px rgba(30, 58, 138, 0.25);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.exam-banner-sub {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.85;
  margin-bottom: 4px;
  font-weight: 700;
}

.exam-banner-title {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.35;
}

/* Sticky HUD Header: Thí sinh & Timer */
.quiz-header-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 16px;
  z-index: 100;
  gap: 16px;
  flex-wrap: wrap;
}

.quiz-user-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
}

.quiz-user-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.quiz-timer {
  background: #0f172a;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 1.35rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
  letter-spacing: 1px;
}

.quiz-timer i {
  color: #38bdf8;
  font-size: 1.15rem;
}

.quiz-timer.timer-warning {
  background: linear-gradient(135deg, #dc2626, #991b1b);
  animation: pulse-timer 1s infinite;
}

@keyframes pulse-timer {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Question Items */
.question-item {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.question-item:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.question-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.q-badge {
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 1px solid #bfdbfe;
  flex-shrink: 0;
}

.question-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.5;
}

.options-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.option-btn {
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px 18px;
  font-size: 0.95rem;
  color: #334155;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.option-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  transform: translateX(3px);
}

.opt-key {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.88rem;
  flex-shrink: 0;
  transition: all 0.18s ease;
}

.option-btn.selected {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1e40af;
  box-shadow: 0 0 0 1px #2563eb;
}

.option-btn.selected .opt-key {
  background: #2563eb;
  color: #ffffff;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  position: relative;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: var(--surface-subtle);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 6px;
  letter-spacing: -0.4px;
}

.modal-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 22px;
}

/* Forms */
.form-group {
  margin-bottom: 18px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 7px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  color: #0f172a;
  background: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Result Modal Special Styling */
.result-score-box {
  background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 2px solid #bae6fd;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 20px 0;
  text-align: center;
}

.result-score-val {
  font-size: 3rem;
  font-weight: 900;
  color: #0369a1;
  line-height: 1;
  margin: 10px 0;
  letter-spacing: -1px;
}

.result-time-val {
  font-size: 1rem;
  font-weight: 700;
  color: #0284c7;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.result-ranking-tip {
  font-size: 0.85rem;
  color: #059669;
  font-weight: 700;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ============================================================
   LEADERBOARD & TABLES
   ============================================================ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #ffffff;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.custom-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 800;
  padding: 14px 16px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.custom-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: #1e293b;
  vertical-align: middle;
}

.custom-table tbody tr:hover {
  background: #f8fafc;
}

.badge-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  padding: 4px 12px;
}

.rank-1 {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #b45309;
  border: 1px solid #fcd34d;
}

.rank-2 {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  color: #475569;
  border: 1px solid #cbd5e1;
}

.rank-3 {
  background: linear-gradient(135deg, #ffedd5, #fed7aa);
  color: #9a3412;
  border: 1px solid #fdba74;
}

.rank-other {
  background: var(--surface-subtle);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  padding: 0;
}

/* ============================================================
   ADMIN DASHBOARD SPECIAL STYLES
   ============================================================ */
.admin-tab-btn {
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  cursor: pointer;
  background: #f1f5f9;
  color: #475569;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}

.admin-tab-btn.active {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.admin-tab-content {
  display: none;
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 28px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-top: 20px;
}

.admin-tab-content.active {
  display: block;
}

.perfect-badge {
  background: #fef3c7;
  color: #b45309;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 10px;
  display: inline-block;
}
