/* VialPro — Tema oscuro/dorado (Santi edition) */

:root {
  --void:          #050505;
  --surface:       #121110;
  --surface-2:     #1c1a16;
  --bone:          #f5f3ef;
  --smoke:         #a8a49c;
  --ash:           #c9c5bd;
  --gold:          #d4a843;
  --gold-light:    #efd28a;
  --gold-deep:     #9a7728;
  --red:           #ff3b3b;
  --green:         #4ade80;
  --border:        rgba(212, 168, 67, 0.18);
  --border-sub:    rgba(255, 255, 255, 0.07);
  --font-display:  'Playfair Display', Georgia, serif;
  --font-body:     'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--void);
  color: var(--bone);
  line-height: 1.55;
  min-height: 100vh;
}

/* Grain */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.025;
  pointer-events: none;
  z-index: 9000;
}

/* ── Header ──────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 24px;
  background: rgba(5, 5, 5, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-img {
  height: 40px;
  mix-blend-mode: lighten;
}

.logo-text {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 21px;
  color: var(--bone);
  letter-spacing: -0.01em;
}

.gold-text {
  background: linear-gradient(110deg, #9a7728 0%, #d4a843 30%, #f3dc9a 50%, #d4a843 70%, #9a7728 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: goldShimmer 6s linear infinite;
}

@keyframes goldShimmer {
  to { background-position: 200% center; }
}

/* ── Loading ─────────────────────────────── */
#loading-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 100px;
}

.loading-inner {
  text-align: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.loading-text {
  color: var(--smoke);
  font-size: 0.9rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Layout ──────────────────────────────── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 36px 20px 60px;
}

/* ── Views ───────────────────────────────── */
.view { animation: fadeUp 0.3s ease; }
.view.hidden { display: none; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view h2 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--bone);
}

.view > p {
  color: var(--smoke);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

/* ── Card grid ───────────────────────────── */
.card-grid {
  display: grid;
  gap: 12px;
  margin: 20px 0 8px;
}

/* ── Widget de progreso ──────────────────── */
.progress-widget {
  margin: 12px 0 20px;
  animation: fadeUp 0.4s ease;
}

.progress-widget.hidden { display: none; }

.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.progress-icon {
  font-size: 18px;
  color: var(--gold);
}

.progress-label {
  font-size: 0.85rem;
  color: var(--smoke);
  font-weight: 500;
}

.progress-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--bone);
  margin-left: auto;
}

.progress-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.predictor-message {
  font-size: 0.8rem;
  color: var(--smoke);
  text-align: center;
  margin-top: 8px;
  font-style: italic;
}

/* ── Buttons ─────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  appearance: none;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 14px;
  padding: 16px 20px;
  text-align: center;
  transition: all 0.18s ease;
  border: 1px solid var(--border-sub);
  background: var(--surface-2);
  color: var(--ash);
  line-height: 1.4;
}

.btn:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--bone);
}

.btn-primary {
  background: linear-gradient(110deg, #9a7728 0%, #d4a843 25%, #f3dc9a 50%, #d4a843 75%, #9a7728 100%);
  background-size: 200% auto;
  color: #0a0903;
  font-weight: 700;
  border: none;
  letter-spacing: 0.02em;
}

.btn-primary:hover {
  background-position: 100% center;
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ash);
}

.btn-accent {
  background: var(--surface);
  border-color: rgba(251, 146, 60, 0.3);
  color: #fb923c;
}

.btn-ghost {
  width: auto;
  display: inline-block;
  background: transparent;
  border-color: var(--border);
  color: var(--smoke);
  padding: 11px 18px;
}

/* ── Login ───────────────────────────────── */
#login-view {
  max-width: 460px;
  margin: 0 auto;
}

#login-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px 22px;
  margin: 18px 0 0;
}

input[type="text"] {
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-2);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 1rem;
  margin: 0 0 14px;
  transition: border-color 0.2s;
}

input[type="text"]::placeholder { color: var(--smoke); }

input[type="text"]:focus {
  outline: none;
  border-color: var(--gold);
}

.disclaimer {
  font-size: 0.75rem;
  color: var(--smoke);
  text-align: center;
  margin-top: 14px;
}

/* ── Quiz header ─────────────────────────── */
.quiz-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.badge {
  background: rgba(212, 168, 67, 0.1);
  color: var(--gold);
  border: 1px solid rgba(212, 168, 67, 0.3);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.quiz-progress {
  color: var(--smoke);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.exam-timer-row {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 999px;
}

.exam-timer-row.hidden { display: none; }

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--gold);
  font-size: 0.95rem;
}

/* ── Question card ───────────────────────── */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
}

.question-number {
  font-size: 0.72rem;
  color: var(--smoke);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.question-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 20px;
  color: var(--bone);
}

/* ── Options ─────────────────────────────── */
.options-list { display: grid; gap: 10px; }

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-sub);
  border-radius: 12px;
  padding: 13px 16px;
  cursor: pointer;
  text-align: left;
  color: var(--ash);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.4;
  width: 100%;
  transition: all 0.15s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--border);
  background: rgba(212, 168, 67, 0.05);
  color: var(--bone);
}

.option-btn strong {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(212, 168, 67, 0.12);
  color: var(--gold);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.option-btn.correct {
  border-color: var(--green);
  background: rgba(74, 222, 128, 0.07);
  color: var(--bone);
}

.option-btn.correct strong {
  background: rgba(74, 222, 128, 0.2);
  color: var(--green);
}

.option-btn.wrong {
  border-color: var(--red);
  background: rgba(255, 59, 59, 0.07);
  color: var(--bone);
}

.option-btn.wrong strong {
  background: rgba(255, 59, 59, 0.2);
  color: var(--red);
}

/* ── Feedback ────────────────────────────── */
.feedback {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
}

.feedback.hidden { display: none; }

#feedback-text {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.feedback-reason {
  font-size: 0.855rem;
  color: var(--smoke);
  line-height: 1.65;
  border-left: 2px solid var(--gold);
  padding-left: 12px;
  margin-top: 12px;
}

/* ── Results ─────────────────────────────── */
.results-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 12px;
}

.results-summary p {
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--ash);
}

.results-summary strong { color: var(--bone); }

.weak-topics, .recommendations {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 12px;
}

.weak-topics h3, .recommendations h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--bone);
  margin-bottom: 8px;
}

.recommendations ul {
  padding-left: 18px;
  color: var(--smoke);
  font-size: 0.9rem;
  line-height: 1.6;
}

.recommendations li {
  margin-bottom: 6px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ── History ─────────────────────────────── */
.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
}

.history-item p {
  font-size: 0.85rem;
  color: var(--ash);
  margin-bottom: 4px;
}

.history-item strong {
  color: var(--bone);
  font-size: 0.9rem;
}

/* ── Footer ──────────────────────────────── */
.app-footer {
  padding: 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--smoke);
  border-top: 1px solid var(--border);
}

/* ── Estilos para imágenes de preguntas ──── */
#question-image-container {
  margin: 16px 0 20px;
  text-align: center;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
}

#question-image-container img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  border: 2px solid var(--border);
  margin: 0 auto;
  display: block;
  transition: opacity 0.3s ease, transform 0.2s ease;
  background: linear-gradient(45deg, #121110, #1c1a16);
}

#question-image-container img:hover {
  transform: scale(1.01);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
}

#question-image-container img.loaded {
  opacity: 1 !important;
}

#question-image-container .image-source {
  font-size: 11px;
  color: var(--smoke);
  margin-top: 8px;
  font-style: italic;
  opacity: 0.8;
}

#question-image-container .image-source::before {
  content: "📸 ";
  font-size: 10px;
}

/* Animación para carga de imágenes */
@keyframes pulseFade {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

#question-image-container img.loading {
  animation: pulseFade 1.5s ease-in-out infinite;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 640px) {
  .container { padding: 24px 16px 50px; }
  .question-card { padding: 18px; }
  .question-text { font-size: 1rem; }
  .option-btn { padding: 12px 14px; }
  #question-image-container img {
    max-height: 220px;
  }
}

@media (max-width: 480px) {
  .progress-card { flex-direction: column; gap: 12px; }
  .progress-divider { display: none; }
  .quiz-header { flex-direction: column; align-items: flex-start; }
  #question-image-container img {
    max-height: 180px;
  }
}