/* ChecheIA - estilos */

:root,
:root[data-theme="dark"] {
  --bg: #14161c;
  --bg-elevated: #1b1e27;
  --surface: #21242f;
  --surface-hover: #2a2e3b;
  --border: #333747;
  --text: #eef0f5;
  --text-dim: #9aa0b4;
  --text-faint: #6b7186;
  --accent: #7c8cff;
  --accent-hover: #93a0ff;
  --accent-text: #10121a;
  --danger: #ff6b6b;
  --success: #4cd97b;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 9px;

  --prio-muy-alta: #ff5c5c;
  --prio-alta: #ff9f4a;
  --prio-media: #ffd23f;
  --prio-baja: #6fb1ff;
  --prio-none: #565c70;
}

:root[data-theme="light"] {
  --bg: #f4f5f8;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-hover: #eef0f6;
  --border: #e1e4ec;
  --text: #1c1f2a;
  --text-dim: #5b6072;
  --text-faint: #8a90a3;
  --accent: #5a67e8;
  --accent-hover: #4753d6;
  --accent-text: #ffffff;
  --danger: #e34848;
  --success: #26a35a;
  --shadow: 0 8px 24px rgba(30, 34, 60, 0.08);

  --prio-muy-alta: #e34848;
  --prio-alta: #e07f22;
  --prio-media: #c99a06;
  --prio-baja: #2f7fd6;
  --prio-none: #9096a8;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f4f5f8;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-hover: #eef0f6;
    --border: #e1e4ec;
    --text: #1c1f2a;
    --text-dim: #5b6072;
    --text-faint: #8a90a3;
    --accent: #5a67e8;
    --accent-hover: #4753d6;
    --accent-text: #ffffff;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding-bottom: 96px;
}

a { color: inherit; text-decoration: none; }

button { font-family: inherit; }

/* ---------- Logo ---------- */
.logo {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
}
.logo span { color: var(--accent); }
.logo-lg { font-size: 1.9rem; text-align: center; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.topbar-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.topbar .logo { flex: 0 0 auto; }
.topbar.search-active .logo,
.topbar.search-active .topbar-actions {
  display: none;
}

/* Search overlay: covers the full topbar edge-to-edge when expanded,
   instead of fighting other icons for leftover flex space. */
.topbar-search {
  display: none;
  align-items: center;
  gap: 8px;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 16px;
  background: var(--bg-elevated);
  z-index: 5;
}
.topbar-search.expanded { display: flex; }

.search-input-wrap { flex: 1; min-width: 0; }
.search-input {
  width: 100%;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.topbar-search .icon-btn { flex: 0 0 auto; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.05rem;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* ---------- Container ---------- */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- Deadline bar (sticky) ---------- */
.deadline-bar {
  position: sticky;
  top: var(--topbar-h, 66px);
  z-index: 15;
  background: var(--bg);
  margin: 0 -16px;
  padding: 10px 16px 0;
  transition: opacity 0.15s ease;
}
.deadline-bar.disabled { opacity: 0.4; }
.deadline-bar.disabled:hover { opacity: 0.7; }

/* ---------- View tabs ---------- */
.view-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.view-tabs::-webkit-scrollbar { display: none; }

.view-tab {
  flex: 0 0 auto;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.view-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.month-picker {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.month-picker.visible { display: flex; }
.month-picker select {
  flex: 1;
}

@media (max-width: 480px) {
  .view-tabs {
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 4px;
  }
  .view-tab {
    padding: 5px 7px;
    font-size: 0.66rem;
  }
  .month-picker select {
    padding: 8px 8px;
    font-size: 0.85rem;
  }
}

/* ---------- Filters ---------- */
/* button.filters-toggle (element+class) so this reliably outranks the
   later .btn rule's `display: inline-flex` at equal class specificity. */
button.filters-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  width: auto;
  font-weight: 600;
}
.filters-toggle .chevron { transition: transform 0.15s ease; }
.filters-toggle.open .chevron { transform: rotate(180deg); }
.filters-toggle .filters-badge {
  display: inline-flex;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.filters-row select { flex: 1 1 140px; }

/* Placed after the base rules above so these actually win the cascade
   at equal specificity (a media query alone does not add specificity). */
@media (max-width: 480px) {
  .filters-row {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .filters-row select {
    flex: 1 1 0;
    min-width: 0;
    font-size: 0.72rem;
    padding: 7px 4px;
  }
  button.filters-toggle { display: inline-flex; }
  .filters-panel {
    display: none;
    overflow: hidden;
  }
  .filters-panel.open { display: block; }
}

/* ---------- Section / accion groups ---------- */
.group-block { margin-bottom: 22px; }
.group-title {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-weight: 800;
  margin: 0 0 10px;
  padding: 8px 14px;
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-elevated));
  border-radius: var(--radius-sm);
}

/* ---------- Task card ---------- */
.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color .15s;
}
.task-card:hover { background: var(--surface-hover); }
.task-card.completed { opacity: 0.5; }
.task-card.completed .task-title { text-decoration: line-through; }

.task-check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 2px solid var(--text-faint);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  margin-top: 1px;
}
.task-check.checked {
  background: var(--success);
  border-color: var(--success);
  color: #0c1710;
}

.task-body { flex: 1; min-width: 0; }
.task-title {
  font-size: 0.98rem;
  font-weight: 600;
  margin: 0 0 6px;
  word-wrap: break-word;
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.prio-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.prio-dot.muy-alta { background: var(--prio-muy-alta); }
.prio-dot.alta { background: var(--prio-alta); }
.prio-dot.media { background: var(--prio-media); }
.prio-dot.baja { background: var(--prio-baja); }

.task-obs {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text-faint);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}
.empty-state .big { font-size: 2.4rem; margin-bottom: 8px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab:hover { background: var(--accent-hover); }

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 12px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.btn-group { display: flex; gap: 8px; }

/* Segmented deadline picker */
.deadline-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 6px;
}
.deadline-opt {
  padding: 10px;
  text-align: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.deadline-opt.active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
}
.deadline-month-picker {
  display: none;
  gap: 8px;
  margin-top: 8px;
}
.deadline-month-picker.visible { display: flex; }
.deadline-month-picker select { flex: 1; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 16, 0.55);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-elevated);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
@media (min-width: 620px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: var(--radius); max-height: 88vh; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h2 { margin: 0; font-size: 1.15rem; }

.modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.modal-footer .btn-danger { margin-right: auto; }

/* ---------- Auth page ---------- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 26px;
  box-shadow: var(--shadow);
}
.auth-sub { text-align: center; color: var(--text-faint); margin: 6px 0 24px; font-size: 0.9rem; }
.auth-form label { margin-bottom: 14px; }

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.alert-error {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}
.alert-success {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
}

/* ---------- Settings page ---------- */
.settings-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}
.option-list { display: flex; flex-direction: column; gap: 6px; }
.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.option-row input[type="text"] { margin: 0; flex: 1; }
.option-row.inactive { opacity: 0.45; }
.option-actions { display: flex; gap: 4px; flex: 0 0 auto; }

.add-option-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.add-option-row input { margin: 0; }

@media (max-width: 480px) {
  .option-row { flex-wrap: wrap; }
  .option-row input[type="text"] { flex: 1 1 100%; }
  .option-actions { flex: 1 1 100%; justify-content: flex-end; }
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 4px 0 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.88rem;
  margin-bottom: 10px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
