/* === Variables y base === */
:root {
  --c-bg: #f5f7fa;
  --c-card: #ffffff;
  --c-text: #1f2937;
  --c-muted: #6b7280;
  --c-primary: #2563eb;
  --c-primary-dark: #1d4ed8;
  --c-success: #16a34a;
  --c-success-bg: #dcfce7;
  --c-error: #dc2626;
  --c-error-bg: #fee2e2;
  --c-border: #e5e7eb;
  --c-warn: #ea580c;
  --c-warn-bg: #fed7aa;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--c-primary); }
.muted { color: var(--c-muted); font-size: .9em; }
.error { color: var(--c-error); background: var(--c-error-bg); padding: .5em .75em; border-radius: var(--radius); }
.success { color: var(--c-success); background: var(--c-success-bg); padding: .5em .75em; border-radius: var(--radius); }

/* === Login === */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  padding: 1rem;
}
.login-card {
  background: var(--c-card);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%; max-width: 400px;
}
.login-card h1 { margin: 0 0 .25rem; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; }
.login-card label { display: flex; flex-direction: column; gap: .35rem; font-size: .9em; font-weight: 600; }
.login-card input {
  font-size: 1em; padding: .6em .75em;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  width: 100%;
}

/* === Topbar === */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--c-card); padding: .75rem 1rem;
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 10;
  flex-wrap: wrap; gap: .5rem;
}
.brand { font-weight: 700; font-size: 1.1em; }
.topbar-right { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.badge {
  background: var(--c-primary); color: white; padding: .2em .6em;
  border-radius: 999px; font-size: .85em; font-weight: 600;
}

/* === Botones === */
button, .btn { font: inherit; cursor: pointer; border: none; }
.btn-primary {
  background: var(--c-primary); color: white;
  padding: .7em 1.2em; border-radius: var(--radius);
  font-weight: 600;
}
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-primary:disabled { background: var(--c-muted); cursor: not-allowed; }
.btn-secondary {
  background: var(--c-border); color: var(--c-text);
  padding: .7em 1.2em; border-radius: var(--radius); font-weight: 500;
}
.btn-link {
  background: transparent; color: var(--c-primary);
  padding: .3em .6em; font-weight: 500; font-size: .9em;
}
.btn-link:hover { text-decoration: underline; }

/* === Container === */
.container { max-width: 800px; margin: 0 auto; padding: 1rem; }

/* === Home grid === */
.mode-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 1rem; }
@media (min-width: 600px) { .mode-grid { grid-template-columns: 1fr 1fr; } }
.mode-card {
  background: var(--c-card); padding: 1.25rem; border-radius: var(--radius);
  box-shadow: var(--shadow); text-align: left; transition: transform .15s;
  display: flex; flex-direction: column; gap: .5rem;
}
.mode-card:hover { transform: translateY(-2px); }
.mode-card h3 { margin: 0; }
.mode-card .desc { color: var(--c-muted); font-size: .9em; flex: 1; }
.mode-card.featured { border: 2px solid var(--c-primary); }

/* === Test === */
.test-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.progress { color: var(--c-muted); font-size: .9em; }
.timer { font-size: 1.2em; font-weight: 700; background: var(--c-card); padding: .3em .7em; border-radius: var(--radius); box-shadow: var(--shadow); }
.timer.warn { color: var(--c-warn); background: var(--c-warn-bg); }
.timer.crit { color: var(--c-error); background: var(--c-error-bg); }

.question-card {
  background: var(--c-card); padding: 1.5rem; border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 1rem;
}
.question-card .qnum { color: var(--c-muted); font-size: .85em; font-weight: 600; }
.question-card .qtext { font-size: 1.1em; margin: .5rem 0 1rem; font-weight: 500; }

.options { display: flex; flex-direction: column; gap: .6rem; }
.option {
  background: var(--c-bg); padding: .9em 1em; border-radius: var(--radius);
  border: 2px solid transparent; cursor: pointer; text-align: left;
  font-size: 1em; width: 100%; transition: background .15s, border-color .15s;
}
.option:hover { background: #e0e7ff; }
.option.selected { border-color: var(--c-primary); background: #dbeafe; }
.option.correct { border-color: var(--c-success); background: var(--c-success-bg); }
.option.wrong { border-color: var(--c-error); background: var(--c-error-bg); }
.option .letter { font-weight: 700; margin-right: .5em; color: var(--c-primary); }

.feedback {
  margin-top: 1rem; padding: 1rem; border-radius: var(--radius);
  border-left: 4px solid var(--c-border);
}
.feedback.ok { background: var(--c-success-bg); border-color: var(--c-success); }
.feedback.ko { background: var(--c-error-bg); border-color: var(--c-error); }
.feedback .label { font-weight: 700; margin-bottom: .25rem; }
.feedback .explanation { font-size: .95em; color: var(--c-text); }

.test-actions { display: flex; justify-content: space-between; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }

/* === Resultados === */
.result-card { background: var(--c-card); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; }
.result-score { font-size: 3em; font-weight: 700; text-align: center; margin: .5em 0; }
.result-score.pass { color: var(--c-success); }
.result-score.fail { color: var(--c-error); }
.result-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 1rem; text-align: center; margin: 1rem 0; }
.result-meta .item { background: var(--c-bg); padding: .75rem; border-radius: var(--radius); }
.result-meta .item .v { font-size: 1.5em; font-weight: 700; }
.result-meta .item .l { font-size: .85em; color: var(--c-muted); }

.detail-list { display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; }
.detail-item {
  background: var(--c-card); padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 4px solid var(--c-border);
}
.detail-item.ok { border-color: var(--c-success); }
.detail-item.ko { border-color: var(--c-error); }
.detail-item.blank { border-color: var(--c-warn); }
.detail-item .hd { display: flex; gap: .5rem; align-items: center; font-size: .9em; font-weight: 600; margin-bottom: .25rem; }
.detail-item .hd .tag { padding: .15em .5em; border-radius: 4px; font-size: .8em; }
.detail-item .hd .tag.ok { background: var(--c-success-bg); color: var(--c-success); }
.detail-item .hd .tag.ko { background: var(--c-error-bg); color: var(--c-error); }
.detail-item .hd .tag.blank { background: var(--c-warn-bg); color: var(--c-warn); }

/* === Stats === */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card { background: var(--c-card); padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.stat-card .v { font-size: 2em; font-weight: 700; color: var(--c-primary); }
.stat-card .l { font-size: .9em; color: var(--c-muted); }

table { width: 100%; border-collapse: collapse; background: var(--c-card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: .6em .8em; text-align: left; border-bottom: 1px solid var(--c-border); }
th { background: var(--c-bg); font-weight: 600; font-size: .9em; }
tr:last-child td { border-bottom: none; }

.bar { background: var(--c-border); height: 8px; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--c-primary); }

/* === Forms === */
form .row { display: flex; flex-direction: column; gap: 1rem; }
form input, form select {
  font: inherit; padding: .6em .75em; border: 1px solid var(--c-border); border-radius: var(--radius); width: 100%;
}
form label { display: flex; flex-direction: column; gap: .25rem; font-size: .9em; font-weight: 600; }

/* === Móvil === */
@media (max-width: 500px) {
  .topbar { padding: .5rem; }
  .topbar-right { gap: .25rem; }
  .btn-link { padding: .25em .4em; font-size: .85em; }
  .container { padding: .75rem; }
  .question-card { padding: 1rem; }
  .question-card .qtext { font-size: 1em; }
  .option { padding: .75em .85em; font-size: .95em; }
}
