/* ================================================================
   QuizMaster — Design System Premium
   Version 1.0.0 | 2026
================================================================ */

/* ── Variables ────────────────────────────────────────────────── */
:root {
  /* Primary palette */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --primary-glow: rgba(99, 102, 241, .25);

  /* Secondary */
  --secondary: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* Neutral */
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #273449;
  --surface3: #334155;
  --border: rgba(255, 255, 255, .08);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-light: #cbd5e1;

  /* Sidebar */
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 72px;
  --sidebar-bg: #0f172a;
  --topbar-h: 64px;

  /* Effects */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
  --shadow-glow: 0 0 20px var(--primary-glow);
  --transition: .2s cubic-bezier(.4, 0, .2, 1);
}

/* ── Light Theme Overrides ────────────────────────────────────── */
.light-theme {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --surface3: #e2e8f0;
  --border: rgba(0, 0, 0, .08);
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #475569;

  --sidebar-bg: #ffffff;

  --shadow: 0 4px 24px rgba(0, 0, 0, .08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .04);
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary);
}

img {
  max-width: 100%;
  display: block;
}

/* ── Rich Content Enhancements ───────────────────────────────── */
.rich-content img,
.rich-textarea img,
.rich-preview img,
.question-text img,
.question-card img,
.journey-block-content img,
.preview-img {
  max-height: 320px !important;
  width: auto !important;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 0.3s ease;
  border-radius: var(--radius-sm);
  display: block;
  margin: 10px 0 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Side-by-side Layout for PC */
.question-flex-container {
  display: flex;
  gap: 30px;
  align-items: flex-start;
  margin-top: 20px;
}

.question-flex-image {
  flex: 0 0 auto;
  max-width: 50%;
}

.question-flex-options {
  flex: 1;
  min-width: 0;
}

@media (max-width: 992px) {
  .question-flex-container {
    flex-direction: column;
    gap: 15px;
  }

  .question-flex-image {
    max-width: 100%;
    width: 100%;
  }
}

.rich-content img:hover {
  transform: scale(1.02);
}

/* Image Overlay (Idea 3) */
.img-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  padding: 40px;
}

.img-overlay img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  border-radius: var(--radius);
}

/* ── Layout ───────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s cubic-bezier(.4, 0, .2, 1);
}

.main-content.collapsed {
  margin-left: var(--sidebar-collapsed-w);
}

.page-body {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width .3s cubic-bezier(.4, 0, .2, 1), transform .3s ease;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Custom Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.sidebar:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

.light-theme .sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
}

.light-theme .sidebar:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-w);
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-label {
  display: none;
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 20px 0;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 12px 0;
}

.sidebar.collapsed .nav-item i {
  margin: 0;
  font-size: 1.1rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 18px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  display: block;
}

.brand-version {
  font-size: .7rem;
  color: var(--text-muted);
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}

.nav-section-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 24px 14px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.7;
}

.nav-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
}

.light-theme .nav-section-label::after {
  background: rgba(0, 0, 0, 0.05);
}

.sidebar-collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .8rem;
  cursor: pointer;
  margin-left: auto;
  padding: 4px;
  border-radius: 4px;
  transition: all .2s;
}

.sidebar-collapse-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.sidebar.collapsed .sidebar-collapse-btn {
  margin-left: 0;
  margin-right: 0;
}

.sidebar.collapsed .sidebar-collapse-btn i {
  transform: rotate(180deg);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .95rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 4px;
  text-decoration: none;
}

.nav-item i {
  width: 24px;
  text-align: center;
  font-size: 1.1rem;
  transition: transform var(--transition);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav-item:hover i {
  transform: scale(1.1);
}

.light-theme .nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.15); /* var(--primary-glow) opaque version */
  color: var(--primary-light);
  font-weight: 600;
}

.light-theme .nav-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-dark);
}

.nav-item.active i {
  color: var(--primary-light);
  filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.4));
}

.light-theme .nav-item.active i {
  color: var(--primary-dark);
  filter: none;
}

.nav-logout {
  color: var(--danger) !important;
  opacity: .7;
}

.nav-logout:hover {
  opacity: 1;
  background: linear-gradient(90deg, rgba(239, 68, 68, .1), transparent) !important;
}

.sidebar-footer {
  padding: 12px 10px 16px;
  border-top: 1px solid var(--border);
}

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.user-menu:hover {
  background: var(--surface2);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  font-weight: 700;
  color: #fff;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: .9rem;
  font-weight: 600;
}

.user-role-badge {
  font-size: .65rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  text-transform: uppercase;
}

.badge-admin {
  background: rgba(99, 102, 241, .2);
  color: var(--primary-light);
}

.badge-teacher {
  background: rgba(6, 182, 212, .2);
  color: #67e8f9;
}

.badge-student {
  background: rgba(16, 185, 129, .2);
  color: #6ee7b7;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 160px;
  display: none;
  box-shadow: var(--shadow);
  z-index: 300;
}

.user-menu:hover .user-dropdown {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  color: var(--text);
  transition: background var(--transition);
}

.dropdown-item:hover {
  background: var(--surface3);
}

.text-danger {
  color: var(--danger) !important;
}

/* ── Alertas Especiales ────────────────────────────────────────── */
@keyframes pulse-critical {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes vibrate-subtle {
  0% {
    transform: translate(0);
  }

  10% {
    transform: translate(-1px, 1px);
  }

  20% {
    transform: translate(-1px, -1px);
  }

  30% {
    transform: translate(1px, 1px);
  }

  40% {
    transform: translate(1px, -1px);
  }

  50% {
    transform: translate(0);
  }
}

.card-critical-alert {
  background: linear-gradient(135deg, #ef4444, #991b1b);
  color: #fff;
  border: none;
  animation: pulse-critical 2s infinite, vibrate-subtle 8s infinite 2s;
  position: relative;
  overflow: hidden;
}

.card-critical-alert h4,
.card-critical-alert p,
.card-critical-alert .stat-value,
.card-critical-alert .stat-label {
  color: #fff !important;
}

.card-critical-alert .stat-icon {
  background: rgba(255, 255, 255, 0.2) !important;
}

.card-critical-alert .stat-icon i {
  color: #fff !important;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}

.stat-label {
  font-size: .8rem;
  color: var(--text-muted);
}

/* Quiz cards (student dashboard) */
.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}

.quiz-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.quiz-card-header {
  padding: 20px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  position: relative;
  overflow: hidden;
}

.quiz-card-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
}

.quiz-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.quiz-card-subject {
  font-size: .8rem;
  color: rgba(255, 255, 255, .75);
}

.quiz-card-body {
  padding: 16px 20px;
  flex: 1;
}

.quiz-card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, .4);
  color: #fff;
}

.btn-success {
  background: linear-gradient(135deg, #059669, var(--success));
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, .3);
}

.btn-success:hover {
  transform: translateY(-1px);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, var(--danger));
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, .3);
}

.btn-danger:hover {
  transform: translateY(-1px);
  color: #fff;
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, var(--warning));
  color: #fff;
}

.btn-warning:hover {
  transform: translateY(-1px);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary-light);
}

.btn-sm {
  padding: 6px 14px;
  font-size: .8rem;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* ── Forms ────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .9rem;
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 8px;
}

.form-check:hover {
  background: var(--surface2);
}

.form-check input[type="radio"],
.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.form-check.is-correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, .08);
}

.input-group {
  display: flex;
  align-items: center;
}

.input-group .form-control {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-group .btn {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ── Tables ───────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

thead th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--surface2);
}

tbody tr:last-child {
  border-bottom: none;
}

td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

/* ── Badges & Tags ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-primary {
  background: rgba(99, 102, 241, .2);
  color: var(--primary-light);
}

.badge-success {
  background: rgba(16, 185, 129, .2);
  color: #6ee7b7;
}

.badge-danger {
  background: rgba(239, 68, 68, .2);
  color: #fca5a5;
}

.badge-warning {
  background: rgba(245, 158, 11, .2);
  color: #fcd34d;
}

.badge-info {
  background: rgba(59, 130, 246, .2);
  color: #93c5fd;
}

.badge-muted {
  background: rgba(148, 163, 184, .1);
  color: var(--text-muted);
}

/* ── Alerts ───────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: .9rem;
  animation: slideDown .3s ease;
}

.alert button {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  opacity: .6;
  font-size: 1rem;
}

.alert-success {
  background: rgba(16, 185, 129, .15);
  border: 1px solid rgba(16, 185, 129, .3);
  color: #6ee7b7;
}

.alert-danger {
  background: rgba(239, 68, 68, .15);
  border: 1px solid rgba(239, 68, 68, .3);
  color: #fca5a5;
}

.alert-warning {
  background: rgba(245, 158, 11, .15);
  border: 1px solid rgba(245, 158, 11, .3);
  color: #fcd34d;
}

.alert-info {
  background: rgba(59, 130, 246, .15);
  border: 1px solid rgba(59, 130, 246, .3);
  color: #93c5fd;
}

/* ── Page headers ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-title h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}

.page-header-title p {
  color: var(--text-muted);
  font-size: .9rem;
  margin-top: 4px;
}

/* ── Quiz Engine ─────────────────────────────────────────────── */
.quiz-layout {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1100px) {
  .quiz-layout {
    grid-template-columns: 1fr;
  }
}

/* Timer bar */
.timer-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.1rem;
  font-weight: 700;
}

.timer-bar.warning {
  border-color: var(--warning);
  box-shadow: 0 0 16px rgba(245, 158, 11, .2);
}

.timer-bar.danger {
  border-color: #ef4444 !important;
  box-shadow: 0 0 16px rgba(239, 68, 68, .3);
  animation: pulse 1s infinite;
}

.timer-display {
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .05em;
}

.timer-label {
  font-size: .8rem;
  color: var(--text-muted);
}

/* Question card */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  min-height: 300px;
}

.question-number {
  font-size: .8rem;
  font-weight: 600;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 12px;
}

.question-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 24px;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.option-item:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, .05);
}

.option-item.selected {
  border-color: var(--primary);
  background: rgba(99, 102, 241, .1);
}

.option-item.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, .1);
}

.option-item.incorrect {
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, .1);
}

.option-indicator {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all var(--transition);
}

.option-item.selected .option-indicator {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.option-text {
  flex: 1;
  font-size: .95rem;
}

/* Drag & Drop */
.dragdrop-text {
  font-size: 1.05rem;
  line-height: 2.2;
  color: var(--text);
  margin-bottom: 20px;
}

.drop-zone {
  display: inline-flex;
  align-items: center;
  min-width: 120px;
  height: 36px;
  border: 2px dashed var(--primary);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  margin: 0 4px;
  vertical-align: middle;
  background: rgba(99, 102, 241, .05);
  cursor: default;
  transition: all var(--transition);
  position: relative;
}

.drop-zone.drag-over {
  background: rgba(99, 102, 241, .15);
  border-style: solid;
}

.drop-zone.filled {
  border-style: solid;
  background: rgba(99, 102, 241, .12);
}

.drop-zone .drop-label {
  font-size: .85rem;
  color: var(--text-muted);
  font-style: italic;
}

.drop-zone .filled-item {
  background: var(--primary-dark);
  color: #fff;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: .85rem;
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 6px;
}

.drop-zone .filled-item .remove-item {
  cursor: pointer;
  opacity: .7;
  font-size: .75rem;
}

.drop-zone .filled-item .remove-item:hover {
  opacity: 1;
}

.drag-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  background: var(--surface2);
  border-radius: var(--radius);
  min-height: 56px;
}

.drag-item {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: .9rem;
  cursor: grab;
  transition: all var(--transition);
  user-select: none;
}

.drag-item:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, .1);
}

.drag-item.dragging {
  opacity: .4;
  transform: scale(.95);
}

/* Navigation bar (quiz) */
.quiz-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  margin-top: 20px;
  flex-wrap: wrap;
}

.progress-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  flex: 1;
}

.progress-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
}

.progress-dot:hover {
  border-color: var(--primary);
  color: var(--primary-light);
}

.progress-dot.answered {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.progress-dot.current {
  border-color: var(--secondary);
  color: var(--secondary);
}

/* Exam sidebar (ads) */
.exam-sidebar-ad {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 90px;
}

/* ── Inline Editor ────────────────────────────────────────────── */
.inline-edit-container {
  border-top: 1px solid var(--border);
  margin-top: 16px;
  padding-top: 16px;
  animation: fadeIn .3s ease;
}

.question-view-hidden {
  display: none !important;
}

/* ── Floating Ad Modal ───────────────────────────────────────── */
.floating-ad-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .3s ease;
  backdrop-filter: blur(4px);
}

.floating-ad-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 560px;
  width: 90%;
  position: relative;
  box-shadow: 0 25px 60px rgba(0, 0, 0, .6);
  animation: slideUp .3s ease;
  transition: opacity .3s ease, visibility .3s ease;
  min-height: 100px; /* Asegura espacio para scripts de carga */
}

.floating-ad-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--danger);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .9rem;
  transition: all var(--transition);
  box-shadow: 0 4px 10px rgba(239, 68, 68, .3);
  z-index: 10;
}

.floating-ad-close:hover:not(:disabled) {
  transform: rotate(90deg) scale(1.1);
  background: #b91c1c;
}

.floating-ad-close:disabled {
  background: var(--surface3);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: .6;
  box-shadow: none;
}

.floating-ad-timer-wrap {
  position: absolute;
  top: -45px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  padding: 6px 16px;
  border-radius: 30px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10000;
}

.floating-ad-timer-wrap i {
  color: var(--warning);
}

.floating-ad-timer-wrap span {
  color: var(--danger);
  font-variant-numeric: tabular-nums;
}

/* ── Timer alert (1 min warning) ────────────────────────────── */
.timer-alert-popup {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8000;
  background: linear-gradient(135deg, var(--warning), #d97706);
  color: #fff;
  padding: 14px 28px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 8px 32px rgba(245, 158, 11, .5);
  display: none;
  align-items: center;
  gap: 10px;
  animation: slideDown .3s ease;
}

.timer-alert-popup i {
  font-size: 1.3rem;
}

/* ── Login page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, .15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(6, 182, 212, .1) 0%, transparent 60%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow);
  animation: slideUp .4s ease;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 16px;
  box-shadow: var(--shadow-glow);
}

.login-logo h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}

.login-logo p {
  color: var(--text-muted);
  font-size: .9rem;
  margin-top: 4px;
}

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp .3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--danger);
  color: #fff;
}

/* ── Misc utilities ─────────────────────────────────────────── */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: #ef4444 !important;
}

.text-warning {
  color: var(--warning);
}

.text-primary {
  color: var(--primary-light);
}

.mt-0 {
  margin-top: 0;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mt-4 {
  margin-top: 2rem;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.mb-4 {
  margin-bottom: 2rem;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 1rem;
}

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.flex-wrap {
  flex-wrap: wrap;
}

.w-100 {
  width: 100%;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: .4;
  display: block;
}

.empty-state p {
  font-size: 1rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Grade colors */
.grade-bajo {
  color: #ef4444 !important;
}

.grade-basico {
  color: var(--warning);
}

.grade-alto {
  color: var(--info);
}

.grade-superior {
  color: var(--success);
}

.mode-tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition);
}

.mode-tab:hover {
  background: rgba(var(--primary-rgb), 0.05);
  color: var(--primary-light);
}

.mode-tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-light);
  background: rgba(var(--primary-rgb), 0.08);
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .6;
  }
}

/* ─── Sistema de Notificaciones (Categorías & Glassmorphism) ──────────────── */
.notification-bell-wrapper {
  position: relative;
  margin-right: 15px;
}

.notification-bell-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  position: relative;
  padding: 8px;
  transition: color 0.3s, transform 0.2s;
}

.notification-bell-btn:hover {
  color: var(--primary-light);
  transform: scale(1.1);
}

.bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.notification-dropdown {
  position: absolute !important;
  top: 100% !important;
  right: 0 !important;
  width: 340px !important;
  max-width: calc(100vw - 32px) !important;
  background: rgba(15, 23, 42, 0.98) !important;
  backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: var(--radius-lg) !important;
  overflow: hidden !important;
  margin-top: 15px !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6) !important;
  z-index: 9999 !important;

  /* Reinforced Hiding */
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.notification-bell-wrapper.active .notification-dropdown {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0);
}

@keyframes slideUp {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.notif-dropdown-header {
  padding: 15px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-weight: 700;
  color: var(--text);
}

.notif-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.notif-tab {
  flex: 1;
  text-align: center;
  padding: 10px 5px;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: 0.2s;
  position: relative;
  border-bottom: 2px solid transparent;
}

.notif-tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-light);
  background: rgba(99, 102, 241, 0.05);
}

.tab-count {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 10px;
  font-size: 0.65rem;
  margin-left: 3px;
}

.notif-dropdown-body {
  max-height: 380px;
  overflow-y: auto;
}

.notif-tab-pane {
  display: none !important;
}

.notif-tab-pane.active {
  display: block !important;
}

.notif-item {
  padding: 15px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  transition: background 0.2s;
}

.notif-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.notif-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.notif-item-text strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 3px;
  line-height: 1.2;
}

.notif-item-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.3;
}

.notif-item-text small {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.3);
  display: block;
  margin-top: 5px;
}

.notif-dropdown-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.notif-dropdown-empty i {
  font-size: 2rem;
  margin-bottom: 10px;
  opacity: 0.2;
}

/* Custom colors for categories */
.notif-pending {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.notif-missing {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.notif-graded {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Loading Overlay for Navigation */
.nav-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  z-index: 20000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 15px;
  color: white;
  transition: opacity 0.3s ease;
}

.nav-loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.btn-loading {
  position: relative !important;
  color: transparent !important;
  pointer-events: none !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  margin-top: -9px;
  margin-left: -9px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-left-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Profile Module ────────────────────────────────────────────── */
.profile-container {
  max-width: 800px;
  margin: 0 auto;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 30px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 16px;
  color: white;
  margin-bottom: 25px;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.2);
}

.profile-header-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.3);
  overflow: hidden;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.profile-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-header-info h2 {
  font-size: 1.8rem;
  margin-bottom: 5px;
  font-weight: 700;
}

.profile-header-info p {
  opacity: 0.9;
  margin-bottom: 10px;
  font-size: 1rem;
}

.profile-card {
  padding: 30px;
}

.preset-avatars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.preset-avatar-opt {
  cursor: pointer;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid transparent;
  transition: all 0.2s;
}

.preset-avatar-opt img {
  width: 100%;
  height: auto;
  display: block;
  background: var(--surface2);
}

.preset-avatar-opt input {
  display: none;
}

.preset-avatar-opt input:checked+img {
  border: 3px solid var(--primary);
  transform: scale(1.05);
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
  border-radius: 50%;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 0px;
  }

  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: block !important;
  }

  .main-content {
    margin-left: 0;
  }

  .page-body {
    padding: 16px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .notification-dropdown {
    right: -60px !important;
    transform-origin: top right;
  }

  .quiz-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 24px;
  }
}

/* ── Forms Support ────────────────────────────────────────────── */
.error-input { 
    border-color: var(--danger) !important; 
    background-color: rgba(239, 68, 68, 0.05) !important; 
}
.error-text { 
    color: #ef4444 !important; 
    font-size: 0.75rem; 
    margin-top: 4px; 
    display: none; 
}
