/* ============================================================
   FocusPI v3 — Hoy, agenda editable, navegacion y estado de la IA.
   Usa los mismos tokens que app.css / a11y.css (funciona en los 6
   temas de lectura). Texto siempre alineado a la izquierda y sin cursiva.
   ============================================================ */

/* ---------- Navegacion ---------- */
.mainnav { align-items: center; overflow: visible; flex-wrap: nowrap; min-width: 0; gap: .05rem; }
.mainnav a { padding: .42rem .55rem; }
.topbar { gap: .8rem; }
.topbar .brand { flex: none; }
.logout { flex: none; }
/* En pantallas medianas se quitan los iconos y el nombre para que quepa todo. */
@media (max-width: 1480px) { .logout .who { display: none; } }
@media (max-width: 1320px) { .mainnav .ni { display: none; } }
.navmore { position: relative; }
.navmore > summary {
  list-style: none; cursor: pointer; color: var(--muted);
  padding: .42rem .65rem; border-radius: var(--r-sm); font-size: .88rem; white-space: nowrap;
}
.navmore > summary::-webkit-details-marker { display: none; }
.navmore > summary::after { content: " ▾"; font-size: .7rem; }
.navmore > summary:hover, .navmore[open] > summary { background: var(--surface); color: var(--text); }
.navmore.active > summary { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-ring); }
.navmore-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg); padding: .35rem; display: flex; flex-direction: column; gap: .1rem;
}
.navmore-menu a { display: block; }
.nav-icon {
  font-size: 1.05rem; padding: .35rem .5rem; border-radius: var(--r-sm); color: var(--muted);
}
.nav-icon:hover, .nav-icon.active { background: var(--accent-soft); color: var(--text); }
.btn-ghost.small { padding: .35rem .7rem; font-size: .82rem; }

/* Barra inferior (solo movil) */
.tabbar { display: none; }
@media (max-width: 760px) {
  .mainnav, .nav-icon, .logout .who { display: none; }
  .topbar { justify-content: space-between; }
  .container { padding-bottom: 6.5rem; }
  .a11y-fab { bottom: 5.2rem !important; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 18px rgba(0,0,0,.12);
    padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom));
  }
  .tabbar > a, .tabmore > summary {
    display: flex; flex-direction: column; align-items: center; gap: .1rem;
    font-size: .72rem; color: var(--muted); padding: .3rem 0; border-radius: var(--r-xs);
    list-style: none; cursor: pointer; text-align: center;
  }
  .tabmore > summary::-webkit-details-marker { display: none; }
  .tabbar span { font-size: 1.25rem; line-height: 1.1; }
  .tabbar > a.active { color: var(--text); background: var(--accent-soft); }
  .tabmore { position: relative; }
  .tabmore-menu {
    position: absolute; bottom: calc(100% + 10px); right: .3rem; min-width: 200px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
    box-shadow: var(--shadow-lg); padding: .4rem; display: flex; flex-direction: column;
  }
  .tabmore-menu a { padding: .6rem .7rem; border-radius: var(--r-xs); color: var(--text); }
  .tabmore-menu a:hover { background: var(--accent-soft); }
}

/* ---------- Piezas comunes ---------- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .6rem; }
.card-head .card-title { margin: 0; }
.chip-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: .32rem .75rem; font-size: .82rem; cursor: pointer;
  font-family: inherit; line-height: 1.4; text-align: left;
  transition: border-color var(--trans), background var(--trans);
}
.chip-btn:hover { border-color: var(--accent-ring); background: var(--accent-soft); }
.chip-btn.is-on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.linklike {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent-hover);
  cursor: pointer; text-align: left;
}
.linklike:hover { text-decoration: underline; }
.plain-list { margin: .4rem 0 .8rem; padding-left: 1.1rem; }
.plain-list li { margin: .15rem 0; }
.status.warn { color: var(--warn); font-weight: 700; }
.two-col.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .two-col.even { grid-template-columns: 1fr; } }

/* ---------- Asistente ---------- */
.assistant { margin-bottom: 1.1rem; }
.assistant-label { display: block; font-weight: 700; margin-bottom: .45rem; }
.assistant-row { display: flex; gap: .5rem; align-items: stretch; }
.assistant-row input { flex: 1; min-width: 0; font-size: 1rem; }
.assistant-examples { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.assistant-examples .chip-btn { font-size: .78rem; color: var(--muted); }
@media (max-width: 760px) {
  /* En el movil basta con dos ejemplos: el resto empuja "Hoy" hacia abajo. */
  .assistant-examples .chip-btn:nth-child(n+3) { display: none; }
  .page-head h1 { font-size: 1.45rem; }
}
.assist-reply {
  margin-top: .8rem; padding: .7rem .9rem; border-radius: var(--r-sm);
  background: var(--accent-soft); border: 1px solid var(--accent-ring);
}
.assist-you { color: var(--muted); font-size: .85rem; margin: 0 0 .3rem; }
.assist-ai { margin: 0; }
.assist-done { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .9rem; }

/* ---------- Hoy ---------- */
.today-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.today-main, .today-side { display: flex; flex-direction: column; gap: 1.1rem; }
@media (max-width: 900px) { .today-grid { grid-template-columns: 1fr; } }

.now-card { border-left: 4px solid var(--accent); }
.now-tag {
  display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .4px;
  padding: .15rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-hover);
}
.now-tag.is-now { background: var(--accent); color: var(--accent-ink); }
.now-tag.is-free { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--text); }
.now-title { font-size: 1.3rem; font-weight: 700; margin: .5rem 0 .3rem; line-height: 1.4; }
.now-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.day-progress { margin-top: 1rem; display: flex; flex-direction: column; gap: .3rem; }

.fix-card { border-left: 4px solid var(--warn); }
.fix-card p { margin: 0 0 .4rem; }
.fix-card.is-soft { border-left-color: var(--muted-2); }

.allday-list { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .7rem; }
.allday-list .ev-chip { font-size: .8rem; white-space: normal; }
.ev-chip.is-deadline {
  background: color-mix(in srgb, var(--warn) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
}
.ev-chip.is-unscheduled {
  border: 1px dashed var(--muted-2); background: transparent; cursor: pointer;
  font-family: inherit; color: var(--text); text-align: left;
}

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.tl-row {
  display: grid; grid-template-columns: 4.2rem 1fr auto; gap: .7rem; align-items: center;
  padding: .55rem .7rem; border-radius: var(--r-sm); background: var(--surface-2);
  border-left: 4px solid var(--muted-2);
}
.tl-row.kind-google { border-left-color: var(--ev-color, var(--accent)); }
.tl-row.kind-block { border-left-color: var(--ev-color, var(--ok)); }
.tl-row.kind-busy { opacity: .8; }
.tl-row.state-now { box-shadow: 0 0 0 2px var(--accent-ring); background: var(--accent-soft); }
.tl-row.state-past, .tl-row.state-done { opacity: .55; }
.tl-row.state-done .tl-title { text-decoration: line-through; }
.tl-time { font-weight: 700; font-size: .9rem; display: flex; flex-direction: column; line-height: 1.3; }
.tl-time small { font-weight: 400; color: var(--muted); font-size: .78rem; }
.tl-body { display: flex; flex-direction: column; min-width: 0; }
.tl-title { font-weight: 700; display: flex; align-items: center; gap: .45rem; overflow-wrap: anywhere; }
.tl-check { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); flex: none; margin: 0; }
.tl-meta { font-size: .78rem; color: var(--muted); }
.tl-actions { display: flex; gap: .15rem; }
@media (max-width: 520px) {
  .tl-row { grid-template-columns: 3.6rem 1fr; }
  .tl-actions { grid-column: 2; justify-content: flex-start; }
}

.gaps { margin-top: 1rem; display: flex; flex-direction: column; gap: .45rem; }
.gaps-list { display: flex; flex-wrap: wrap; gap: .4rem; }

.mini-list { list-style: none; margin: 0 0 .8rem; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.mini-list li { display: flex; gap: .6rem; font-size: .9rem; }
.mini-list .kind-busy { color: var(--muted); }
.tl-time-s { font-weight: 700; min-width: 3rem; color: var(--muted); }
.shortcut-list { display: flex; flex-direction: column; gap: .45rem; }
.shortcut-list .btn-ghost { text-align: left; }

/* ---------- Dialogo de bloque ---------- */
.block-dialog {
  border: 1px solid var(--border); border-radius: var(--r); padding: 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  width: min(460px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem);
}
.block-dialog::backdrop { background: rgba(20, 16, 10, .45); }
.block-form { padding: 1.2rem 1.3rem 1.3rem; display: flex; flex-direction: column; gap: .55rem; }
.bf-head { display: flex; align-items: center; justify-content: space-between; }
.bf-head h2 { margin: 0; font-size: 1.15rem; }
.bf-hint { margin: -.2rem 0 0; }
.bf-legend { font-size: .88rem; font-weight: 700; }
.bf-durations { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.bf-durations input { width: 5.2rem; }
.bf-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .5rem; }
.btn-ghost.danger:hover { color: var(--danger); border-color: rgba(207,122,122,.4); }

/* ---------- Calendario ---------- */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.prefs-form { display: flex; flex-direction: column; gap: .6rem; }
.prefs-form .btn-primary { align-self: flex-start; }

.lg-agenda { background: var(--warn); }
.allday-lb { font-size: .62rem; line-height: 1.25; }
.wg-event.ev-agenda { border-left-color: var(--warn);
                      background: color-mix(in srgb, var(--warn) 20%, var(--surface)); }
/* Bloques de un proyecto con color: manda el color del proyecto */
.wg-event.ev-plan[style*="--ev-color"], .wg-event.ev-agenda[style*="--ev-color"] {
  border-left-color: var(--ev-color);
  background: color-mix(in srgb, var(--ev-color) 20%, var(--surface));
}
.wg-slots { cursor: copy; }
.wg-event { cursor: default; }
.wg-event.is-editable { cursor: grab; touch-action: pan-y; }
.wg-event.is-editable:hover { transform: none; box-shadow: 0 0 0 2px var(--accent-ring); z-index: 4; }
.wg-event.is-editable:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 4; }
.wg-event.is-dragging { opacity: .35; }
.wg-ghost { z-index: 6; opacity: .95; box-shadow: var(--shadow); pointer-events: none; cursor: grabbing; }
body.agenda-dragging, body.agenda-dragging * { cursor: grabbing !important; user-select: none; }
.wg-resize {
  position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize;
}
.wg-resize::after {
  content: ""; position: absolute; left: 35%; right: 35%; bottom: 2px; height: 2px;
  border-radius: 2px; background: currentColor; opacity: .35;
}
.wg-now {
  position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 5;
  pointer-events: none;
}
.wg-now::before {
  content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--danger);
}

/* ---------- Estado de la IA (Ajustes) ---------- */
.ai-prov { border: 1px solid var(--border-soft); border-radius: var(--r-sm); padding: .6rem .75rem; margin-bottom: .7rem; }
.ai-prov-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .9rem; }
.ai-models { list-style: none; margin: .45rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.ai-models li { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .8rem; }
.ai-models li.is-bad code { opacity: .6; text-decoration: line-through; }
.ai-state { margin-left: auto; color: var(--muted); }

html[data-motion="0"] .chip-btn { transition: none; }
