html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* Traffic-themed background colors */
.bg-traffic-red {
  background-color: var(--traffic-red) !important;
}

.bg-traffic-green {
  background-color: var(--traffic-green) !important;
}

.bg-road-orange {
  background-color: var(--road-orange) !important;
}

.bg-road-green {
  background-color: var(--road-green) !important;
}

/* Traffic-themed text colors */
.text-traffic-red {
  color: var(--traffic-red) !important;
}

.text-traffic-green {
  color: var(--traffic-green) !important;
}

.text-road-orange {
  color: var(--road-orange) !important;
}

.text-road-grey {
  color: var(--road-grey) !important;
}

/* Traffic-themed border-left accents for cards */
.border-left-traffic-red {
  border-left: 4px solid var(--traffic-red) !important;
}

.border-left-traffic-green {
  border-left: 4px solid var(--traffic-green) !important;
}

.border-left-road-orange {
  border-left: 4px solid var(--road-orange) !important;
}

.border-left-road-yellow {
  border-left: 4px solid var(--road-yellow) !important;
}

/* Traffic-themed buttons */
.btn-traffic-red {
  background-color: var(--traffic-red);
  border-color: var(--traffic-red);
  color: white;
}

.btn-traffic-red:hover {
  background-color: #b71c1c;
  border-color: #b71c1c;
  color: white;
}

.btn-traffic-green {
  background-color: var(--traffic-green);
  border-color: var(--traffic-green);
  color: white;
}

.btn-traffic-green:hover {
  background-color: #2e7d32;
  border-color: #2e7d32;
  color: white;
}

.btn-road-orange {
  background-color: var(--road-orange);
  border-color: var(--road-orange);
  color: white;
}

.btn-road-orange:hover {
  background-color: #e66a02;
  border-color: #e66a02;
  color: white;
}

/* Profile avatar */
.profile-avatar {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border: 3px solid var(--traffic-red);
  max-width: 100%;
}

.profile-avatar-placeholder {
  width: 100px;
  height: 100px;
  border: 3px solid var(--traffic-red);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Rank badge */
.rank-badge {
  color: white;
}

/* Stat card */
.stat-card-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Card accent borders */
.card-accent {
  border-left: 4px solid var(--road-orange);
}

/* Section header with border accent */
.section-header-accent {
  border-left: 4px solid var(--road-orange);
  padding-left: 15px;
  margin-bottom: 20px;
}

/* Page header icon */
.page-header-icon {
  font-size: 2rem;
}

/* Empty state */
.empty-state-icon {
  font-size: 3rem;
}

/* Attempt cards (exam/quiz history) */
.attempt-card {
  border-top: 4px solid var(--road-grey);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.attempt-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12) !important;
}

.attempt-card-passed {
  border-top-color: var(--traffic-green);
}

.attempt-card-failed {
  border-top-color: var(--traffic-red);
}

.attempt-score {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.attempt-progress {
  height: 6px;
  border-radius: 3px;
}

.attempt-progress .progress-bar {
  border-radius: 3px;
}

.attempt-footer {
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

/* Card search filter */
.card-search {
  max-width: 300px;
}

/* History section (row with cards) */
.history-grid {
  margin-bottom: -1rem;
}

/* Profile tabs */
.profile-tabs {
  border-bottom: 2px solid rgba(0,0,0,0.06);
  gap: 0.25rem;
}

.tab-pane:not(.active) {
  display: none !important;
}

.profile-tabs .nav-link {
  border: none;
  border-radius: 8px 8px 0 0;
  padding: 0.75rem 1.25rem;
  font-weight: 500;
  color: var(--road-grey);
  transition: all 0.2s ease;
  background: transparent;
  opacity: 0.7;
}

.profile-tabs .nav-link:hover {
  color: var(--traffic-red);
  background: rgba(211, 47, 47, 0.05);
}

.profile-tabs .nav-link.active {
  color: white;
  background: var(--traffic-red);
  box-shadow: 0 -2px 8px rgba(211, 47, 47, 0.15);
  border-bottom: 3px solid #b71c1c;
  margin-bottom: -2px;
}

.profile-tabs .nav-link i {
  font-size: 1.1rem;
}

/* ===== Page Loading Overlay ===== */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(26, 26, 46, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
  transition: opacity 0.3s ease;
}

.loader-overlay.show {
  display: flex;
}

.loader-overlay-content {
  text-align: center;
  color: white;
}

.loader-overlay-spinner {
  width: 3.5rem;
  height: 3.5rem;
  border-width: 0.35em;
  color: var(--traffic-red);
}

.loader-overlay-icon {
  font-size: 3rem;
  color: var(--traffic-yellow);
  margin-bottom: 0.5rem;
}

.loader-overlay-text {
  font-size: 1.15rem;
  opacity: 0.95;
  font-weight: 500;
  margin-top: 1rem;
  margin-bottom: 0;
}

.loader-overlay-subtext {
  font-size: 0.9rem;
  opacity: 0.6;
  margin-top: 0.25rem;
}

/* ===== Inline Loader Placeholder ===== */
.loader-placeholder {
  gap: 0.5rem;
}

.loader-placeholder-text {
  font-size: 0.9rem;
}

/* ===== Traffic-themed pulse animation for loader ===== */
@keyframes traffic-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.loader-pulse {
  animation: traffic-pulse 1.5s ease-in-out infinite;
}

/* ===== Button loading state ===== */
.btn-loading {
  pointer-events: none;
  opacity: 0.8;
}

.btn-loading .btn-loader {
  display: inline-flex !important;
}

.btn-loading .btn-text {
  display: none !important;
}

/* ===== Profile Layout (sidebar + content) ===== */
.profile-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.profile-sidebar {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 1rem;
}

.profile-sidebar-inner {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border-top: 4px solid;
  border-image: linear-gradient(90deg, var(--traffic-red), var(--road-orange), var(--traffic-green)) 1;
  overflow: hidden;
}

.sidebar-avatar-section {
  text-align: center;
  padding: 1.5rem 1rem 1rem;
}

.sidebar-name {
  margin: 0.5rem 0 0;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-email {
  color: var(--road-grey);
  font-size: 0.8rem;
  margin: 0 0 0.5rem;
}

.sidebar-divider {
  height: 1px;
  background: rgba(0,0,0,0.06);
  margin: 0.5rem 0;
}

.sidebar-actions {
  padding: 0.75rem 1rem 1rem;
}

.avatar-camera-btn {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--traffic-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(211,47,47,0.3);
  transition: transform 0.2s;
}

.avatar-camera-btn:hover {
  transform: scale(1.1);
  color: #fff;
}

.profile-content {
  flex: 1;
  min-width: 0;
}

/* Large avatar */
.profile-avatar-lg {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border: 3px solid var(--traffic-red);
  max-width: 100%;
}

.profile-avatar-placeholder-lg {
  width: 120px;
  height: 120px;
  border: 3px solid var(--traffic-red);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
}

/* Profile nav */
.profile-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0 0.75rem;
}

.profile-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--road-grey);
  font-weight: 500;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.profile-nav-item:hover {
  background: rgba(211, 47, 47, 0.06);
  color: var(--traffic-red);
}

.profile-nav-item.active {
  background: var(--traffic-red);
  color: #fff;
}

.profile-nav-item i {
  width: 1.25rem;
  text-align: center;
  font-size: 1.1rem;
}

/* Content cards */
.content-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  overflow: hidden;
}

.content-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.content-card-header i {
  font-size: 1.25rem;
}

.content-card-header h5 {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
}

.content-card-body {
  padding: 1.25rem;
}

/* Detail grid with icon cards */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.detail-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #fafbfc;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.04);
  transition: box-shadow 0.2s, transform 0.2s;
}

.detail-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

.detail-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.detail-icon i {
  font-size: 1.15rem;
}

.detail-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--road-grey);
  font-weight: 600;
  display: block;
  line-height: 1.2;
}

.detail-value {
  font-size: 0.9rem;
  color: #212529;
  font-weight: 500;
  display: block;
  line-height: 1.3;
}

/* Stat cards */
.stats-row {
  margin-bottom: 1.25rem;
}

.stat-card {
  border-radius: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1) !important;
}

.stat-card .card-body {
  padding: 0.85rem 1rem;
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.stat-card-value {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  color: #212529;
}

.stat-card-label {
  font-size: 0.75rem;
  color: var(--road-grey);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Activity icon in recent activity */
.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: rgba(0,0,0,0.04);
  flex-shrink: 0;
}

.activity-icon.text-traffic-red {
  background: rgba(211,47,47,0.08);
}

.activity-icon.text-traffic-green {
  background: rgba(46,125,50,0.08);
}

.min-width-0 {
  min-width: 0;
}

/* Pagination controls */
.pagination-control .page-link {
  color: var(--traffic-red);
  border-color: rgba(211, 47, 47, 0.2);
  border-radius: 6px !important;
  margin: 0 0.15rem;
}

.pagination-control .page-link:hover {
  background: rgba(211, 47, 47, 0.08);
  border-color: var(--traffic-red);
  color: var(--traffic-red);
}

.pagination-control .page-item.active .page-link {
  background: var(--traffic-red);
  border-color: var(--traffic-red);
  color: #fff;
}

.pagination-control .page-item.disabled .page-link {
  color: #ccc;
  border-color: rgba(0,0,0,0.08);
}

/* Responsive: collapse sidebar below lg */
@media (max-width: 991.98px) {
  .profile-layout {
    flex-direction: column;
  }
  .profile-sidebar {
    width: 100%;
    position: static;
  }
}

@media (max-width: 767.98px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Custom color utilities */
.bg-purple {
  background-color: #6f42c1;
}

.text-purple {
  color: #6f42c1;
}

/* ===== Quiz Index (Listing) ===== */
.quiz-card {
  transition: transform 0.2s, box-shadow 0.2s;
  border-top: 4px solid var(--road-grey);
  overflow: hidden;
}

.quiz-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.12) !important;
}

.quiz-card .card-img-top {
  height: 100px;
  background: linear-gradient(135deg, var(--traffic-red) 0%, var(--road-orange) 100%);
}

.quiz-card-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(211,47,47,0.1);
  flex-shrink: 0;
}

.quiz-card-icon i {
  font-size: 1.5rem;
  color: var(--traffic-red);
}

.quiz-meta span {
  font-size: 0.8rem;
}

.quiz-progress {
  height: 6px;
  border-radius: 3px;
  background-color: rgba(0,0,0,0.06);
}

.quiz-progress-bar {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--traffic-red), var(--road-orange));
}

.btn-quiz-start {
  background: linear-gradient(135deg, var(--traffic-red), var(--road-orange));
  color: #fff;
  border: none;
  transition: opacity 0.2s;
}

.btn-quiz-start:hover {
  opacity: 0.9;
  color: #fff;
}

/* ===== Quiz Start (Taking) ===== */
.quiz-header-gradient {
  background: linear-gradient(135deg, #d32f2f 0%, #fd7e14 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
}

.question-card {
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  transition: box-shadow 0.2s;
}

.question-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.question-number-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.question-option {
  border: 2px solid rgba(0,0,0,0.1) !important;
  border-radius: 10px !important;
  padding: 0.85rem 1rem !important;
  transition: all 0.2s;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.question-option:hover {
  border-color: var(--traffic-red);
  background: rgba(211,47,47,0.04);
}

.question-option input[type="radio"]:checked + span,
.question-option input[type="radio"]:checked + label {
  font-weight: 600;
}

.question-option:has(input:checked) {
  border-color: var(--traffic-red) !important;
  background: rgba(211,47,47,0.06) !important;
  box-shadow: 0 0 0 1px var(--traffic-red);
}

.question-option:has(input:checked) span,
.question-option:has(input:checked) label {
  color: var(--traffic-red);
}

.timer-display {
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: color 0.3s;
}

.timer-seconds {
  font-size: 1rem;
  font-weight: 400;
  opacity: 0.8;
}

.timer-critical {
  color: #d32f2f !important;
  animation: timerPulse 1s infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.timer-well {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: 30px;
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(4px);
}

/* Progress indicator */
.progress-gradient {
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
}

.progress-gradient-bar {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--road-orange), var(--traffic-green));
  transition: width 0.4s ease;
}

/* Right/left answer borders */
.border-left-success {
  border-left: 4px solid #388e3c !important;
}

.border-left-danger {
  border-left: 4px solid #d32f2f !important;
}

/* Result page */
.pass-gradient {
  background: linear-gradient(135deg, #388e3c, #1b5e20);
  border: none;
  border-radius: 12px;
}

.fail-gradient {
  background: linear-gradient(135deg, #d32f2f, #b71c1c);
  border: none;
  border-radius: 12px;
}

.cta-gradient {
  background: linear-gradient(135deg, #388e3c, #0d6efd);
  border: none;
  border-radius: 12px;
}

.score-card-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.score-card-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
}

.progress-circle {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto;
}

.progress-circle svg {
  transform: rotate(-90deg);
}

.progress-circle-bg {
  fill: none;
  stroke: rgba(0,0,0,0.06);
  stroke-width: 8;
}

.progress-circle-fill {
  fill: none;
  stroke: var(--road-orange);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease;
}

.progress-circle-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--road-dark);
}

.result-question-card {
  border-radius: 10px;
  transition: box-shadow 0.2s;
}

.result-question-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.review-option {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.review-option-correct {
  background: rgba(56,142,60,0.08);
  color: #388e3c;
  font-weight: 500;
}

.review-option-incorrect {
  background: rgba(211,47,47,0.08);
  color: #d32f2f;
  font-weight: 500;
}

.review-option-neutral {
  background: rgba(0,0,0,0.03);
  color: #6c757d;
}

.btn-gradient-blue {
  background: linear-gradient(135deg, #0d6efd, #6395e8);
  color: #fff;
  border: none;
  color: #fff;
  transition: opacity 0.2s;
}

.btn-gradient-blue:hover {
  opacity: 0.9;
  color: #fff;
}

.btn-gradient-red {
  background: linear-gradient(135deg, #d32f2f, #fd7e14);
  color: #fff;
  border: none;
  transition: opacity 0.2s;
}

.btn-gradient-red:hover {
  opacity: 0.9;
  color: #fff;
}

.btn-gradient-green {
  background: linear-gradient(135deg, #388e3c, #58a55b);
  border: none;
  color: #fff;
  transition: opacity 0.2s;
}

.btn-gradient-green:hover {
  opacity: 0.9;
  color: #fff;
}

/* responsive helpers */
@media (max-width: 575.98px) {
  .btn-responsive {
    width: 100%;
  }
}
