/* ==========================================================
   TASK MANAGER · Estilos
   Orden: 1. Variables  2. Base  3. Componentes  4. Responsive
   ========================================================== */

/* ---------- 1. VARIABLES ---------- */
:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #5a6675;
  --line: #dde2e8;
  --accent: #2457f5;        /* azul de acción */
  --accent-dark: #1a42c4;
  --danger: #b3261e;

  /* Prioridades (siempre se muestran con texto, no solo con color) */
  --high-bg: #fde8e6;  --high-ink: #9c1f17;
  --mid-bg: #fff2d6;   --mid-ink: #8a5a00;
  --low-bg: #e1f4e8;   --low-ink: #1d6b3c;

  --font: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
}

/* ---------- 2. BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.5;
  color: var(--ink); background: var(--bg);
}
h1, h2 { margin: 0; line-height: 1.15; }
p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.container { width: min(1080px, 100% - 2.5rem); margin-inline: auto; }

/* ---------- 3. COMPONENTES ---------- */
.demo-bar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.2rem 1.25rem;
  padding: 0.5rem 1rem; background: #0f161f; color: #b9c4d2; font-size: 0.85rem; text-align: center;
}
.demo-bar a { color: #fff; font-weight: 600; }

.app-header { background: var(--ink); color: #fff; padding: 1.5rem 0; }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; }
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-icon { width: 36px; height: 36px; }
.brand h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.header-text { color: #b9c4d2; }

main { padding-block: 1.75rem 2.5rem; }

/* Resumen */
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { display: flex; flex-direction: column; gap: 0.1rem; padding: 1rem 1.25rem; background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line); }
.stat-label { font-size: 0.9rem; color: var(--muted); }
.stat strong { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }

/* Tarjetas */
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.card { padding: 1.5rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card h2 { font-size: 1.2rem; font-weight: 700; }
.form-card { position: sticky; top: 1rem; }
.form-card.is-editing { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 87, 245, 0.15); }

/* Formulario */
.field { margin-top: 1rem; }
.field label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; font-weight: 600; }
.optional { font-weight: 400; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%; min-width: 0; padding: 0.65rem 0.8rem; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 87, 245, 0.18); }
.field [aria-invalid="true"] { border-color: var(--danger); }
.field-error { min-height: 1.25rem; margin-top: 0.3rem; font-size: 0.85rem; color: var(--danger); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-actions { display: flex; gap: 0.6rem; margin-top: 1.25rem; }

/* Botones */
.btn {
  padding: 0.7rem 1.2rem; border: 1.5px solid transparent; border-radius: 10px; cursor: pointer;
  font-weight: 600; transition: background-color 0.2s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { flex: 1; background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }

/* Cabecera de la lista y filtros */
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.counter { font-size: 0.9rem; color: var(--muted); }
.filters { display: inline-flex; gap: 0.25rem; margin: 1rem 0 1.25rem; padding: 0.25rem; background: var(--bg); border-radius: 12px; }
.filter-btn { padding: 0.45rem 0.95rem; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-weight: 600; font-size: 0.92rem; color: var(--muted); transition: background-color 0.2s ease, color 0.2s ease; }
.filter-btn:hover { color: var(--ink); }
.filter-btn.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(27, 36, 48, 0.15); }

/* Tareas */
.task-list { display: flex; flex-direction: column; gap: 0.75rem; }
.task {
  display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 0.85rem;
  padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  animation: task-in 0.25s ease both;
}
.task.is-editing { border-color: var(--accent); background: #f5f8ff; }
.task-check { width: 22px; height: 22px; margin-top: 0.15rem; accent-color: var(--accent); cursor: pointer; }
.task-title { font-weight: 600; overflow-wrap: anywhere; }
.task-desc { margin-top: 0.2rem; font-size: 0.93rem; color: var(--muted); overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin-top: 0.55rem; font-size: 0.85rem; color: var(--muted); }
.badge { padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; }
.badge-alta { background: var(--high-bg); color: var(--high-ink); }
.badge-media { background: var(--mid-bg); color: var(--mid-ink); }
.badge-baja { background: var(--low-bg); color: var(--low-ink); }
.overdue { color: var(--danger); font-weight: 600; }

.task-actions { display: flex; gap: 0.25rem; }
.icon-btn { padding: 0.4rem 0.65rem; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn.danger:hover { background: var(--high-bg); color: var(--danger); }

/* Estado visual de completada */
.task.is-done { background: #f7f9fb; }
.task.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task.is-done .task-desc { text-decoration: line-through; }
.task.is-done .badge { opacity: 0.55; }

.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); border: 1.5px dashed var(--line); border-radius: 12px; }

.site-footer { padding-bottom: 2rem; font-size: 0.88rem; color: var(--muted); text-align: center; }

@keyframes task-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 4. RESPONSIVE ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .form-card { position: static; }
}
@media (max-width: 520px) {
  .summary { gap: 0.6rem; }
  .stat { padding: 0.8rem; }
  .stat strong { font-size: 1.5rem; }
  .task { grid-template-columns: auto 1fr; }
  .task-actions { grid-column: 2; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .filters { display: flex; }
  .filter-btn { flex: 1; padding: 0.45rem 0.4rem; font-size: 0.88rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
