/* ============================================================
   StudyFlow — hoja de estilos
   Diseño basado en los wireframes: encabezado azul claro,
   títulos azul marino, acento verde, tarjetas redondeadas.
   Sin dependencias externas. Accesible y adaptable a móvil.
   ============================================================ */

:root {
  --navy:        #23262c;
  --navy-soft:   #474b53;
  --ink:         #262a30;
  --muted:       #6c7178;
  --muted-2:     #8a9099;

  --bg:          #f3f4f6;
  --surface:     #ffffff;
  --header-bg:   #e8eaed;
  --panel-bg:    #eef0f2;
  --panel-br:    #dcdfe3;
  --field-br:    #c6cace;

  --accent:      #2f6b34;   /* verde texto */
  --accent-bg:   #e4f0e2;   /* verde fondo */
  --accent-br:   #bcd8ba;   /* verde borde */

  --danger:      #a32424;
  --danger-bg:   #fbe9e9;
  --danger-br:   #e7bcbc;

  --again:       #b14a3b;
  --hard:        #9a6a1f;
  --good:        #2f6b34;
  --easy:        #41464e;

  --radius:      14px;
  --radius-lg:   18px;
  --shadow:      0 8px 30px rgba(22, 35, 63, 0.08);
  --shadow-sm:   0 2px 8px rgba(22, 35, 63, 0.06);

  --maxw:        880px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: clamp(0px, 3vw, 28px) 16px 48px;
}

/* ---------- Contenedor principal (la "tarjeta" grande) ---------- */
.app-shell {
  max-width: var(--maxw);
  margin: 0 auto;
  background: var(--surface);
  border: 1.5px solid var(--navy-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 70vh;
}

.loading { padding: 3rem; color: var(--muted); text-align: center; }

/* ---------- Encabezado ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--header-bg);
  padding: 18px 28px;
}
.brand {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.01em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand .logo { width: 26px; height: 26px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.topbar-link {
  color: var(--navy-soft);
  text-decoration: none;
  font-size: 1rem;
  border-radius: 8px;
  padding: 4px 8px;
}
.topbar-link:hover { background: rgba(22,35,63,.06); }

/* ---------- Área de contenido ---------- */
.content { padding: 26px 28px 30px; }
@media (max-width: 560px) {
  .topbar { padding: 14px 18px; }
  .content { padding: 20px 18px 24px; }
  .brand { font-size: 1.3rem; }
}

h1.page-title {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--navy);
  margin: 2px 0 18px;
  letter-spacing: -0.01em;
}
h2 { color: var(--navy); font-weight: 700; }
.breadcrumb { color: var(--muted-2); font-size: 1.05rem; margin: 0 0 16px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---------- Tarjetas de estadística ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr; gap: 10px; } }
.stat {
  background: var(--panel-bg);
  border: 1px solid var(--panel-br);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .label { color: var(--muted); font-size: .9rem; }
.stat .value { color: var(--navy); font-size: 1.7rem; font-weight: 800; margin-top: 4px; }

/* ---------- CTA grande (Continuar estudiando) ---------- */
.cta {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--accent-bg);
  border: 1px solid var(--accent-br);
  border-radius: var(--radius);
  padding: 20px 22px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .15s ease;
  text-decoration: none;
}
.cta:hover { box-shadow: var(--shadow-sm); }
.cta:active { transform: translateY(1px); }
.cta .cta-title { color: var(--accent); font-size: 1.35rem; font-weight: 800; }
.cta .cta-sub { color: #3c6b40; margin-top: 4px; }
.cta.is-empty { background: var(--panel-bg); border-color: var(--panel-br); }
.cta.is-empty .cta-title { color: var(--navy); }
.cta.is-empty .cta-sub { color: var(--muted); }

/* ---------- Barra de acciones de pie ---------- */
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: center;
  margin-top: 24px;
}
.actions-row.spread { justify-content: space-between; }

/* ---------- Botones ---------- */
.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--field-br);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 18px;
  text-decoration: none;
  display: inline-block;
  transition: background .12s ease, border-color .12s ease, transform .05s ease;
}
.btn:hover { background: #f3f6fc; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid #b4b8bf; outline-offset: 2px; }
.btn-primary {
  background: var(--accent-bg);
  border-color: var(--accent-br);
  color: var(--accent);
  font-weight: 700;
}
.btn-primary:hover { background: #d8ead5; }
.btn-danger { background: var(--danger-bg); border-color: var(--danger-br); color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--navy-soft); padding: 8px 10px; }
.btn-ghost:hover { background: rgba(22,35,63,.06); }
.btn-lg { padding: 13px 26px; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn {
  background: none; border: none; color: var(--easy);
  cursor: pointer; font: inherit; padding: 0; text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 18px; }
.field > label { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 7px; }
.input, .textarea, select.input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--field-br);
  border-radius: 10px;
  padding: 12px 14px;
}
.textarea { min-height: 84px; resize: vertical; }
.input:focus, .textarea:focus, select.input:focus {
  outline: none; border-color: #9aa0a8; box-shadow: 0 0 0 3px rgba(130,135,145,.25);
}
.field .hint { color: var(--muted); font-size: .85rem; margin-top: 6px; }
.field .error-text { color: var(--danger); font-size: .9rem; margin-top: 6px; }
.input.invalid, .textarea.invalid { border-color: var(--danger-br); }

/* ---------- Listas de mazos / tarjetas ---------- */
.list { display: grid; gap: 12px; margin: 6px 0 4px; }
.deck-item, .card-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--panel-br);
  border-radius: var(--radius);
  padding: 15px 18px;
}
.deck-item:hover, .card-item:hover { box-shadow: var(--shadow-sm); }
.deck-item .main, .card-item .main { min-width: 0; flex: 1; cursor: pointer; }
.deck-item .title { color: var(--navy); font-weight: 700; font-size: 1.1rem; }
.deck-item .meta, .card-item .meta { color: var(--muted); font-size: .9rem; margin-top: 3px; }
.card-item .front { color: var(--ink); font-weight: 600; }
.card-item .back { color: var(--muted); margin-top: 3px; font-size: .95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }

.pill {
  display: inline-block; font-size: .78rem; font-weight: 600;
  padding: 2px 9px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.pill.grade { background: #e4e6ea; color: #4a4f58; }
.pill.due { background: var(--accent-bg); color: var(--accent); }
.pill.seed { background: #f0ecdd; color: #7a6a2a; }
.tag { display:inline-block; background:#eef2f9; color:var(--muted); border-radius:6px;
  padding:1px 7px; font-size:.78rem; margin:0 4px 4px 0; }

/* ---------- Estado vacío ---------- */
.empty {
  text-align: center; color: var(--muted);
  border: 1px dashed var(--field-br); border-radius: var(--radius);
  padding: 34px 20px; background: #fbfcfe;
}
.empty h3 { color: var(--navy); margin: 0 0 6px; }

/* ---------- Sesión de estudio ---------- */
.study-wrap { max-width: 760px; margin: 0 auto; }
.flashcard {
  border: 1.5px solid var(--field-br);
  border-radius: var(--radius-lg);
  background: #fbfcff;
  padding: 44px 28px;
  min-height: 230px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
}
.flashcard .q { color: var(--navy); font-size: 1.6rem; font-weight: 700; }
.flashcard .divider { width: 60%; height: 1px; background: var(--panel-br); margin: 22px 0; }
.flashcard .a { color: var(--ink); font-size: 1.3rem; }
.reveal-btn { margin-top: 26px; }
@media (max-width: 560px) {
  .flashcard { padding: 30px 18px; }
  .flashcard .q { font-size: 1.3rem; }
}

.rating-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-top: 22px;
}
.rating-btn {
  border: 1px solid var(--field-br); background: var(--surface);
  border-radius: 12px; padding: 14px 8px; cursor: pointer; font: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.rating-btn:hover { background: #f3f6fc; }
.rating-btn:focus-visible { outline: 3px solid #b4b8bf; outline-offset: 2px; }
.rating-btn .r-label { font-weight: 700; }
.rating-btn .r-when { font-size: .8rem; color: var(--muted); }
.rating-btn.again .r-label { color: var(--again); }
.rating-btn.hard  .r-label { color: var(--hard); }
.rating-btn.good  .r-label { color: var(--good); }
.rating-btn.easy  .r-label { color: var(--easy); }
@media (max-width: 560px) { .rating-row { grid-template-columns: repeat(2, 1fr); } }

.session-foot { text-align: center; color: var(--muted-2); font-size: .9rem; margin-top: 16px; }
.progress-bar { height: 6px; background: var(--panel-bg); border-radius: 999px; margin-bottom: 18px; overflow: hidden; }
.progress-bar > span { display:block; height:100%; background: var(--accent-br); transition: width .2s ease; }

/* ---------- Toast ---------- */
.toast-root {
  position: fixed; left: 0; right: 0; bottom: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; z-index: 60;
}
.toast {
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px;
  box-shadow: var(--shadow); font-size: .95rem; max-width: 90vw;
  animation: toast-in .18s ease;
}
.toast.err { background: var(--danger); }
.toast.ok  { background: #275e2c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px);} to {opacity:1;transform:none;} }

/* ---------- Modal ---------- */
.modal { border: none; border-radius: var(--radius-lg); padding: 0; max-width: 460px; width: 92vw;
  box-shadow: var(--shadow); color: var(--ink); }
.modal::backdrop { background: rgba(22,35,63,.4); }
.modal .modal-body { padding: 24px 24px 20px; }
.modal h3 { color: var(--navy); margin: 0 0 10px; }
.modal p { color: var(--muted); margin: 0 0 18px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Varios ---------- */
.muted { color: var(--muted); }
.spacer { flex: 1; }
.subject-head { display:flex; align-items:center; gap:10px; margin: 20px 0 10px; }
.subject-head h2 { font-size: 1.15rem; margin: 0; }
.subject-head .count { color: var(--muted); font-size:.9rem; }
.notice { background: var(--panel-bg); border:1px solid var(--panel-br); border-radius:12px;
  padding: 14px 16px; color: var(--muted); font-size:.92rem; margin: 12px 0; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden;
  clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* ---------- Modo oscuro (ligero, no retrasa lo básico) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --navy:#e6e8ec; --navy-soft:#b9bdc4; --ink:#e7e9ed; --muted:#9ba0a8; --muted-2:#868b93;
    --bg:#121316; --surface:#1b1d21; --header-bg:#222429; --panel-bg:#202227; --panel-br:#333640;
    --field-br:#3d414b; --accent:#8fd49a; --accent-bg:#1e3326; --accent-br:#2f5438;
    --danger:#f0a3a3; --danger-bg:#3a1f1f; --danger-br:#5a3030;
    --shadow:0 8px 30px rgba(0,0,0,.4); --shadow-sm:0 2px 8px rgba(0,0,0,.35);
  }
  .btn:hover { background:#24262b; }
  .flashcard { background:#141d30; }
  .empty { background:#141d30; }
}
