/* ═══════════════════════════════════════════
   DAILY QUEST — Tema gamer dark, mobile-first
   ═══════════════════════════════════════════ */

:root {
  --bg: #0d0e1a;
  --bg-2: #14162a;
  --card: #1b1e38;
  --card-2: #232750;
  --border: #2e3363;
  --text: #eef0ff;
  --muted: #9aa0c7;
  --primary: #7c5cff;
  --primary-2: #9d7bff;
  --accent: #00e5b0;
  --gold: #ffc93c;
  --danger: #ff5470;
  --warn: #ff9f43;
  --info: #38bdf8;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .45);
  --glow: 0 0 18px rgba(124, 92, 255, .45);
  --nav-h: 64px;
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}

[data-theme="light"] {
  --bg: #f2f3fb;
  --bg-2: #e8eaf6;
  --card: #ffffff;
  --card-2: #eef0ff;
  --border: #d5d9f0;
  --text: #1b1e38;
  --muted: #5b6191;
  --shadow: 0 4px 18px rgba(27, 30, 56, .12);
  --glow: 0 0 14px rgba(124, 92, 255, .25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 80% -10%, rgba(124,92,255,.18), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(0,229,176,.10), transparent 60%),
              var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.brand {
  font-size: 1.9rem; letter-spacing: .18em; font-weight: 800;
  background: linear-gradient(90deg, var(--primary-2), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ───── Splash ───── */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg);
}
.splash-logo { font-size: 4rem; animation: pulse 1.4s ease-in-out infinite; }
.splash-tip { color: var(--muted); }
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.15);} }

/* ───── Auth ───── */
.auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--border); border-radius: 22px; padding: 32px 26px;
  box-shadow: var(--shadow); text-align: center;
}
.auth-logo { font-size: 3rem; margin-bottom: 6px; }
.auth-motto { color: var(--muted); margin: 8px 0 22px; font-size: .9rem; }
.auth-card form { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.auth-card label { font-size: .8rem; color: var(--muted); margin-top: 8px; }
.auth-error { color: var(--danger); font-size: .85rem; margin-top: 8px; }
.auth-links { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.auth-local hr { border: none; border-top: 1px solid var(--border); margin: 18px 0 10px; }
.auth-local .btn { margin: 8px 0; }

/* ───── Inputs ───── */
input, textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  font-size: 1rem; font-family: var(--font); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,92,255,.2); }
textarea { resize: vertical; min-height: 70px; }
input[type="range"] { padding: 0; accent-color: var(--primary); height: 30px; }

/* ───── Botones ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 14px; border: none; cursor: pointer;
  font-size: .95rem; font-weight: 700; font-family: var(--font);
  color: var(--text); background: var(--card-2);
  transition: transform .1s, filter .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: var(--glow); }
.btn-accent  { background: linear-gradient(135deg, #00b890, var(--accent)); color: #06281f; }
.btn-danger  { background: rgba(255,84,112,.16); color: var(--danger); border: 1px solid rgba(255,84,112,.4); }
.btn-warn    { background: rgba(255,159,67,.16); color: var(--warn); border: 1px solid rgba(255,159,67,.4); }
.btn-ghost   { background: transparent; border: 1px solid var(--border); }
.btn-block   { width: 100%; margin-top: 14px; }
.btn-sm      { padding: 8px 12px; font-size: .82rem; border-radius: 10px; }
.btn-icon    { padding: 8px 10px; font-size: 1rem; border-radius: 10px; }
.link { background: none; border: none; color: var(--primary-2); cursor: pointer; font-size: .88rem; font-family: var(--font); }

/* ───── Layout app ───── */
.app { max-width: 760px; margin: 0 auto; padding-bottom: calc(var(--nav-h) + 18px); }
#main { padding: 0 14px; }
.view { animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 16px 8px;
}
.topbar-greet { font-size: 1.15rem; font-weight: 800; display: block; }
.topbar-date { font-size: .78rem; color: var(--muted); text-transform: capitalize; }
.topbar-right { display: flex; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 13px; font-size: .88rem; color: var(--text); cursor: pointer; font-family: var(--font);
}
.chip-streak b { color: var(--warn); }
.chip-points b { color: var(--gold); }

.levelbar { display: flex; align-items: center; gap: 10px; padding: 4px 16px 12px; }
.levelbar-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 800; font-size: .74rem; border-radius: 8px; padding: 3px 8px; white-space: nowrap;
}
.levelbar-track { flex: 1; height: 10px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--border); overflow: hidden; }
.levelbar-fill { height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .5s ease; }
.levelbar-name { font-size: .74rem; color: var(--muted); white-space: nowrap; }

/* ───── Tarjetas ───── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.section-title { font-size: .82rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 18px 2px 10px; font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ───── Misiones ───── */
.mission { position: relative; overflow: hidden; }
.mission.done { border-color: rgba(0,229,176,.5); }
.mission.failed { border-color: rgba(255,84,112,.45); opacity: .8; }
.mission.skipped { opacity: .6; }
.mission-head { display: flex; align-items: center; gap: 12px; }
.mission-icon {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
  background: var(--card-2); border: 1px solid var(--border);
}
.mission-info { flex: 1; min-width: 0; }
.mission-title { font-weight: 800; font-size: 1rem; }
.mission-meta { font-size: .78rem; color: var(--muted); }
.mission-points { font-weight: 800; color: var(--gold); font-size: .9rem; white-space: nowrap; }
.mission-status { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.st-pending { background: rgba(154,160,199,.15); color: var(--muted); }
.st-active  { background: rgba(56,189,248,.15); color: var(--info); animation: pulse 2s infinite; }
.st-paused  { background: rgba(255,159,67,.15); color: var(--warn); }
.st-done    { background: rgba(0,229,176,.15); color: var(--accent); }
.st-skipped { background: rgba(154,160,199,.15); color: var(--muted); }
.st-failed  { background: rgba(255,84,112,.15); color: var(--danger); }

.progress { height: 9px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--border); overflow: hidden; margin: 10px 0 4px; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .4s; }
.progress-fill.gold { background: linear-gradient(90deg, var(--warn), var(--gold)); }
.progress-label { font-size: .74rem; color: var(--muted); }

.mission-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.mission-timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--info); }

/* Resumen del día */
.day-summary { background: linear-gradient(135deg, var(--card), var(--card-2)); }
.day-summary .big { font-size: 1.6rem; font-weight: 900; }
.motivation { font-size: .9rem; color: var(--primary-2); font-style: italic; margin-top: 6px; }

/* ───── Estado personal ───── */
.mood-emojis { display: flex; gap: 10px; justify-content: center; margin: 8px 0; }
.mood-emoji {
  font-size: 1.9rem; background: var(--bg-2); border: 2px solid var(--border);
  border-radius: 14px; padding: 8px 14px; cursor: pointer; transition: all .15s; filter: grayscale(.6);
}
.mood-emoji.selected { border-color: var(--primary); filter: none; transform: scale(1.1); box-shadow: var(--glow); }
.slider-row { margin: 12px 0 4px; }
.slider-row .row-between { font-size: .85rem; margin-bottom: 2px; }
.slider-val { font-weight: 800; color: var(--primary-2); }

/* ───── Modo Enfoque ───── */
.focus-hero { text-align: center; padding: 26px 16px; }
.focus-ring {
  width: 220px; height: 220px; margin: 0 auto 14px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(closest-side, var(--card) 82%, transparent 83% 100%),
    conic-gradient(var(--primary) calc(var(--pct, 0) * 1%), var(--bg-2) 0);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.focus-ring.break-mode {
  background:
    radial-gradient(closest-side, var(--card) 82%, transparent 83% 100%),
    conic-gradient(var(--accent) calc(var(--pct, 0) * 1%), var(--bg-2) 0);
}
.focus-time { font-size: 2.8rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.focus-phase { font-size: .8rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }
.focus-blocks { display: flex; gap: 6px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.block-dot { width: 22px; height: 22px; border-radius: 7px; background: var(--bg-2); border: 1px solid var(--border); }
.block-dot.done { background: linear-gradient(135deg, var(--primary), var(--accent)); border: none; }
.block-dot.current { border-color: var(--info); animation: pulse 1.5s infinite; }
.focus-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

/* ───── Calendario ───── */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; }
.cal-month { font-weight: 800; font-size: 1.05rem; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: .7rem; color: var(--muted); font-weight: 700; padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; cursor: pointer;
  font-size: .85rem; font-weight: 700; color: var(--text); font-family: var(--font);
  transition: transform .1s;
}
.cal-day:active { transform: scale(.93); }
.cal-day.other { opacity: .25; pointer-events: none; }
.cal-day.today { border-color: var(--info); box-shadow: 0 0 8px rgba(56,189,248,.4); }
.cal-day.perfect { background: rgba(0,229,176,.2); border-color: var(--accent); }
.cal-day.complete { background: rgba(124,92,255,.22); border-color: var(--primary); }
.cal-day.partial { background: rgba(255,201,60,.14); border-color: rgba(255,201,60,.5); }
.cal-day.failed { background: rgba(255,84,112,.13); border-color: rgba(255,84,112,.45); }
.cal-day-pts { font-size: .6rem; color: var(--muted); font-weight: 600; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; font-size: .74rem; color: var(--muted); }
.cal-legend span::before { content: "⬤ "; }
.leg-perfect::before { color: var(--accent) !important; }
.leg-complete::before { color: var(--primary) !important; }
.leg-partial::before { color: var(--gold) !important; }
.leg-failed::before { color: var(--danger) !important; }

/* ───── Gráficas ───── */
.chart-card { position: relative; }
.chart-card canvas { max-height: 260px; }

/* ───── Recompensas ───── */
.reward { display: flex; align-items: center; gap: 12px; }
.reward.locked { opacity: .55; }
.reward-cost { font-weight: 800; color: var(--gold); white-space: nowrap; }
.badge-cat { font-size: .68rem; padding: 2px 8px; border-radius: 99px; font-weight: 700; }
.cat-small  { background: rgba(0,229,176,.15); color: var(--accent); }
.cat-medium { background: rgba(56,189,248,.15); color: var(--info); }
.cat-large  { background: rgba(255,201,60,.15); color: var(--gold); }

/* Insignias */
.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge {
  width: 74px; text-align: center; background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 10px 4px;
}
.badge.locked { opacity: .35; filter: grayscale(1); }
.badge .b-icon { font-size: 1.6rem; }
.badge .b-name { font-size: .62rem; color: var(--muted); margin-top: 4px; }

/* ───── Reportes ───── */
.report-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 10px; }
.stat { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; text-align: center; }
.stat .s-val { font-size: 1.25rem; font-weight: 900; }
.stat .s-label { font-size: .68rem; color: var(--muted); }
.report-tabs { display: flex; gap: 8px; margin: 14px 0; }
.tab { flex: 1; padding: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--muted); font-weight: 700; cursor: pointer; font-family: var(--font); font-size: .85rem; }
.tab.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border: none; }

/* ───── Navegación inferior ───── */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; max-width: 760px; margin: 0 auto;
  background: rgba(20, 22, 42, .92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
}
[data-theme="light"] .bottomnav { background: rgba(255,255,255,.92); }
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; color: var(--muted); font-size: .66rem; font-weight: 700;
  cursor: pointer; font-family: var(--font); -webkit-tap-highlight-color: transparent;
}
.nav-btn span { font-size: 1.35rem; transition: transform .15s; }
.nav-btn.active { color: var(--primary-2); }
.nav-btn.active span { transform: translateY(-2px) scale(1.15); }

/* Sheet (menú Más) */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop, .modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet-panel {
  position: absolute; bottom: 0; left: 0; right: 0; max-width: 760px; margin: 0 auto;
  background: var(--card); border-radius: 22px 22px 0 0; border: 1px solid var(--border);
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-item {
  text-align: left; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font-size: 1rem; font-weight: 700;
  cursor: pointer; font-family: var(--font);
}

/* ───── Modal ───── */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal-panel {
  position: relative; width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  background: var(--card); border-radius: 22px 22px 0 0; border: 1px solid var(--border);
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom)); animation: slideUp .22s ease;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { font-size: 1.05rem; }
.modal-x { background: var(--bg-2); border: 1px solid var(--border); color: var(--muted); border-radius: 10px; padding: 6px 11px; cursor: pointer; }
.modal-body label { display: block; font-size: .8rem; color: var(--muted); margin: 12px 0 4px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ───── Toasts ───── */
.toasts { position: fixed; top: 14px; left: 0; right: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 18px; font-size: .9rem; font-weight: 700; box-shadow: var(--shadow);
  animation: toastIn .25s ease; max-width: 92vw;
}
.toast.success { border-color: rgba(0,229,176,.5); }
.toast.error { border-color: rgba(255,84,112,.5); }
.toast.gold { border-color: rgba(255,201,60,.6); box-shadow: 0 0 18px rgba(255,201,60,.25); }
@keyframes toastIn { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ───── Confetti ───── */
.confetti { position: fixed; inset: 0; z-index: 95; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 10px; height: 10px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .6; } }

/* Historial listas */
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.list-item:last-child { border-bottom: none; }

/* Configuración */
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-row input[type="number"] { width: 84px; text-align: center; padding: 8px; }
.switch { position: relative; width: 48px; height: 27px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--border); transition: .2s; cursor: pointer; }
.switch .track::before { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); top: 2.5px; left: 3px; transition: .2s; }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::before { transform: translateX(20px); background: #fff; }

/* Escritorio */
@media (min-width: 760px) {
  #main { padding: 0 20px; }
  .missions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .missions-grid .card { margin-bottom: 0; }
  .modal { align-items: center; }
  .modal-panel { border-radius: 22px; }
}

/* Impresión (reporte → PDF) */
@media print {
  body { background: #fff; color: #000; }
  .topbar, .levelbar, .bottomnav, .report-tabs, .btn, .toasts { display: none !important; }
  .card, .stat { border: 1px solid #ccc; box-shadow: none; background: #fff; color: #000; }
  .stat .s-label, .muted { color: #555; }
}
