/* ============================================================================
   Control de Tareas · app.css
   Estilos PROPIOS del proyecto que complementan AceUI. Se enlaza DESPUÉS de
   ace-ui.css. Usa exclusivamente tokens --ace-* (nada de colores mágicos), para
   funcionar en tema claro y oscuro.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1) Pantalla de autenticación (login/registro/2FA/reset/errores)
   Layout centrado sin app-shell. Clases usadas por views/layouts/blank.php.
   --------------------------------------------------------------------------- */
.ace-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--ace-space-6);
  background:
    radial-gradient(120% 80% at 50% -10%, var(--ace-primary-soft) 0%, transparent 55%),
    linear-gradient(180deg, var(--ace-bg) 0%, var(--ace-surface-2) 100%);
}
.ace-auth__theme {
  position: fixed;
  top: var(--ace-space-5);
  right: var(--ace-space-5);
  z-index: var(--ace-z-sticky);
}
.ace-auth__card { width: 100%; max-width: 440px; }
.ace-auth__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--ace-space-3);
  margin-bottom: var(--ace-space-5);
}
.ace-auth__logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--ace-radius-md);
  background: var(--ace-primary);
  color: var(--ace-on-primary);
  box-shadow: var(--ace-shadow-sm);
}
.ace-auth__logo svg { width: 24px; height: 24px; }
.ace-auth__brand-name {
  font-size: var(--ace-text-lg);
  font-weight: var(--ace-weight-bold);
  color: var(--ace-text);
  letter-spacing: 0.01em;
}
.ace-auth__title {
  font-size: var(--ace-text-2xl);
  font-weight: var(--ace-weight-bold);
  color: var(--ace-text);
  line-height: var(--ace-leading-tight);
  margin: 0;
}
.ace-auth__subtitle {
  margin: var(--ace-space-2) 0 var(--ace-space-6);
  font-size: var(--ace-text-base);
  color: var(--ace-text-muted);
}
.ace-auth__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ace-space-3);
  margin-bottom: var(--ace-space-4);
}
.ace-auth__link {
  font-size: var(--ace-text-sm);
  font-weight: var(--ace-weight-semibold);
  color: var(--ace-primary);
  text-decoration: none;
  border-radius: var(--ace-radius-sm);
}
.ace-auth__link:hover { text-decoration: underline; }
.ace-auth__link:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ace-focus-ring); }
.ace-auth__foot {
  margin-top: var(--ace-space-6);
  text-align: center;
  font-size: var(--ace-text-sm);
  color: var(--ace-text-muted);
}
.ace-auth__legal {
  margin-top: var(--ace-space-5);
  text-align: center;
  font-size: var(--ace-text-xs);
  color: var(--ace-text-subtle);
}
/* Conmutación de iconos sol/luna del botón de tema. */
.ace-auth__theme .ace-auth__icon-moon { display: none; }
:root[data-theme="dark"] .ace-auth__theme .ace-auth__icon-sun { display: none; }
:root[data-theme="dark"] .ace-auth__theme .ace-auth__icon-moon { display: block; }
.ace-icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ace-focus-ring); }

/* ---------------------------------------------------------------------------
   2) Semáforo de riesgo (RAG). Punto + variantes verde/ámbar/rojo.
   --------------------------------------------------------------------------- */
.ct-sem {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--ace-radius-full);
  flex: 0 0 auto;
  background: var(--ace-text-subtle);
}
.ct-sem--verde { background: var(--ace-success); }
.ct-sem--ambar { background: var(--ace-warning); }
.ct-sem--rojo  { background: var(--ace-danger); }

/* Fila de tabla resaltada según riesgo (fondo tenue). */
tr.ct-row--rojo  > td { background: var(--ace-danger-soft); }
tr.ct-row--ambar > td { background: var(--ace-warning-soft); }

/* ---------------------------------------------------------------------------
   3) Celdas numéricas / dinero: alineadas a la derecha con cifras tabulares.
   --------------------------------------------------------------------------- */
.ct-num {
  font-family: var(--ace-font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.ct-neg { color: var(--ace-danger); }

/* ---------------------------------------------------------------------------
   4) Tabla densa → tarjetas en móvil. Aplica a <table class="ace-table ct-cards">.
   Cada <td> debe llevar data-label="Encabezado".
   --------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .ct-cards thead { display: none; }
  .ct-cards, .ct-cards tbody, .ct-cards tr, .ct-cards td { display: block; width: 100%; }
  .ct-cards tr {
    border: 1px solid var(--ace-border);
    border-radius: var(--ace-radius-md);
    margin: 0 0 var(--ace-space-3);
    padding: var(--ace-space-2) var(--ace-space-3);
    background: var(--ace-surface);
  }
  .ct-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--ace-space-4);
    padding: var(--ace-space-2) 0;
    border: 0;
    text-align: right;
  }
  .ct-cards td::before {
    content: attr(data-label);
    font-weight: var(--ace-weight-semibold);
    color: var(--ace-text-muted);
    text-align: left;
  }
  .ct-cards .ct-num { text-align: right; }
}

/* ---------------------------------------------------------------------------
   5) Utilidades menores del proyecto.
   --------------------------------------------------------------------------- */
.ct-kpi-neg .ace-stat__value { color: var(--ace-danger); }
.ct-meta { color: var(--ace-text-muted); font-size: var(--ace-text-sm); }
.ct-gap { display: inline-flex; align-items: center; gap: var(--ace-space-2); }

/* Badge campana del topbar con contador. */
.ct-bell { position: relative; }
.ct-bell__count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--ace-radius-full);
  background: var(--ace-danger);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  font-weight: var(--ace-weight-bold);
  text-align: center;
}

/* Toque cómodo en móvil: garantiza objetivos ≥ 44px. */
@media (max-width: 640px) {
  .ace-btn, .ace-icon-btn { min-height: 44px; }
}

/* ---------------------------------------------------------------------------
   8) Tarjeta-enlace (toda la tarjeta clicable, p.ej. proyecto en la lista).
   --------------------------------------------------------------------------- */
.ct-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--ace-transition) var(--ace-ease),
              transform var(--ace-transition) var(--ace-ease),
              box-shadow var(--ace-transition) var(--ace-ease);
}
.ct-card-link:hover {
  border-color: var(--ace-primary);
  transform: translateY(-2px);
  box-shadow: var(--ace-shadow-md);
}
.ct-card-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ace-focus-ring);
}

/* ---------------------------------------------------------------------------
   9) Diagrama de Gantt (línea de tiempo por tarea, CSS puro).
   --------------------------------------------------------------------------- */
.ct-gantt-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ct-gantt { min-width: 720px; }
.ct-gantt__head,
.ct-gantt__row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--ace-space-3);
  align-items: center;
}
.ct-gantt__row { padding: var(--ace-space-2) 0; border-top: 1px solid var(--ace-border); }
.ct-gantt__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--ace-text-sm); }
.ct-gantt__label a { text-decoration: none; color: var(--ace-text); font-weight: var(--ace-weight-medium); }
.ct-gantt__scale {
  display: flex; justify-content: space-between;
  font-size: var(--ace-text-xs); color: var(--ace-text-muted);
  padding-bottom: var(--ace-space-2);
}
.ct-gantt__track {
  position: relative;
  height: 24px;
  background: var(--ace-surface-2);
  border-radius: var(--ace-radius-sm);
  overflow: hidden;
}
.ct-gantt__grid { position: absolute; inset: 0; }
.ct-gantt__gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ace-border); }
.ct-gantt__bar {
  position: absolute; top: 4px; height: 16px;
  min-width: 3px;
  border-radius: var(--ace-radius-sm);
  background: var(--ace-primary);
  display: flex; align-items: center;
}
.ct-gantt__bar--rojo  { background: var(--ace-danger); }
.ct-gantt__bar--ambar { background: var(--ace-warning); }
.ct-gantt__bar--verde { background: var(--ace-success); }
.ct-gantt__today {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--ace-danger); opacity: 0.7; z-index: 2;
}
.ct-gantt__unscheduled { font-size: var(--ace-text-xs); color: var(--ace-text-subtle); }

/* ---------------------------------------------------------------------------
   10) Filas de tabla se sienten interactivas (el título y "Ver" son enlaces).
   --------------------------------------------------------------------------- */
@media (min-width: 641px) {
  .ace-table tbody tr:hover td { background: var(--ace-surface-3); }
}

/* ---------------------------------------------------------------------------
   11) Dropzone de archivo (.ace-file) — texto y nombre del archivo elegido.
   --------------------------------------------------------------------------- */
.ace-file__text { font-size: var(--ace-text-sm); }
.ace-file__name {
  font-size: var(--ace-text-sm);
  font-weight: var(--ace-weight-semibold);
  color: var(--ace-primary);
}
.ace-file__name:empty { display: none; }

/* Miniatura de evidencia (imagen) en listas de adjuntos. */
.ct-thumb {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: var(--ace-radius-sm);
  border: 1px solid var(--ace-border);
  flex: 0 0 auto;
}

/* ---------------------------------------------------------------------------
   12) Lista de tareas estilo "app" (reemplaza la tabla ancha; SIN scroll horizontal).
   Cada fila envuelve con flex-wrap, así siempre cabe en el ancho de la página.
   --------------------------------------------------------------------------- */
.ct-tasklist { display: flex; flex-direction: column; }
.ct-taskrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ace-space-2) var(--ace-space-4);
  padding: var(--ace-space-3) var(--ace-space-4);
  border-top: 1px solid var(--ace-border);
  border-left: 3px solid transparent;
}
.ct-taskrow:hover { background: var(--ace-surface-2); }
.ct-taskrow--rojo  { border-left-color: var(--ace-danger); }
.ct-taskrow--ambar { border-left-color: var(--ace-warning); }
.ct-taskrow--verde { border-left-color: var(--ace-success); }

.ct-taskrow__main { flex: 1 1 240px; min-width: 0; display: flex; gap: var(--ace-space-3); align-items: flex-start; }
.ct-taskrow__seq {
  flex: 0 0 auto; min-width: 22px; text-align: right;
  color: var(--ace-text-subtle); font-variant-numeric: tabular-nums; font-size: var(--ace-text-sm);
  padding-top: 2px;
}
.ct-taskrow__title { font-weight: var(--ace-weight-semibold); color: var(--ace-text); text-decoration: none; display: block; }
.ct-taskrow__title:hover { color: var(--ace-primary); }

.ct-taskrow__money { display: flex; gap: var(--ace-space-4); flex-wrap: wrap; }
.ct-money { display: flex; flex-direction: column; line-height: 1.2; }
.ct-money__l { font-size: var(--ace-text-xs); color: var(--ace-text-muted); }
.ct-money__v { font-family: var(--ace-font-mono); font-variant-numeric: tabular-nums; font-size: var(--ace-text-sm); }
.ct-money__v--strong { font-weight: var(--ace-weight-semibold); }

.ct-taskrow__badges { display: flex; gap: var(--ace-space-2); flex-wrap: wrap; align-items: center; }
.ct-taskrow__actions { display: flex; gap: var(--ace-space-2); margin-left: auto; }

@media (max-width: 720px) {
  .ct-taskrow__actions { margin-left: 0; }
  .ct-taskrow__money { gap: var(--ace-space-3); }
}

/* ---------------------------------------------------------------------------
   12b) Flujo de dinero: GASTO vs INGRESO. Píldora .ct-flow + control segmentado
        .ct-seg (Gasto/Ingreso) para la captura rápida. .ct-pos = monto en verde.
   --------------------------------------------------------------------------- */
.ct-pos { color: var(--ace-success); }

.ct-flow {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: var(--ace-text-xs); font-weight: var(--ace-weight-semibold);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.ct-flow--gasto   { background: var(--ace-danger-soft);  color: var(--ace-danger); }
.ct-flow--ingreso { background: var(--ace-success-soft); color: var(--ace-success); }

/* Control segmentado (radios ocultos + labels tipo botón). */
.ct-seg {
  display: inline-flex; border: 1px solid var(--ace-border);
  border-radius: var(--ace-radius); overflow: hidden; background: var(--ace-surface);
}
.ct-seg input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ct-seg label {
  margin: 0; padding: 0.5rem 0.8rem; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 0.35rem;
  font-size: var(--ace-text-sm); font-weight: var(--ace-weight-medium);
  color: var(--ace-text-muted); transition: background 0.12s ease, color 0.12s ease;
}
.ct-seg .ct-seg__ingreso { border-left: 1px solid var(--ace-border); }
.ct-seg label:hover { color: var(--ace-text); }
.ct-seg input:checked + label.ct-seg__gasto   { background: var(--ace-danger-soft);  color: var(--ace-danger);  font-weight: var(--ace-weight-semibold); }
.ct-seg input:checked + label.ct-seg__ingreso { background: var(--ace-success-soft); color: var(--ace-success); font-weight: var(--ace-weight-semibold); }
/* Foco accesible por teclado en el label del radio seleccionado. */
.ct-seg input:focus-visible + label { outline: 2px solid var(--ace-primary); outline-offset: -2px; }

/* Tarea estratégica (sin dinero) y chip de meta en las filas. */
.ct-flow--estrategica { background: var(--ace-surface-3); color: var(--ace-text-muted); }
.ct-goalchip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: var(--ace-text-xs); color: var(--ace-text-muted);
  background: var(--ace-surface-2); border: 1px solid var(--ace-border);
  padding: 0.1rem 0.5rem; border-radius: 999px;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ace-select--sm { padding: 0.28rem 1.6rem 0.28rem 0.55rem; font-size: var(--ace-text-xs); max-width: 170px; }

/* Navegación tipo app: barra de progreso superior + transición suave de contenido. */
#ct-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 9999;
  background: var(--ace-primary); box-shadow: 0 0 8px var(--ace-primary);
  opacity: 0; pointer-events: none;
  transition: width 0.2s ease, opacity 0.3s ease;
}
#ct-progress.is-active { opacity: 1; }
/* Crossfade con la View Transitions API (navegación misma-página del turbo-lite). */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: ct-fade-out 0.12s ease both; }
  ::view-transition-new(root) { animation: ct-fade-in 0.18s ease both; }
}
@keyframes ct-fade-out { to { opacity: 0; } }
@keyframes ct-fade-in { from { opacity: 0; } }
/* Fades también en navegaciones completas (login, etc.) donde el navegador lo soporte. */
@view-transition { navigation: auto; }

/* Píldora de tarea recurrente (nómina, renta, pagos fijos). */
.ct-recur {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: var(--ace-text-xs); font-weight: var(--ace-weight-semibold);
  padding: 0.15rem 0.5rem; border-radius: 999px;
  background: var(--ace-primary-soft); color: var(--ace-primary); white-space: nowrap;
}

/* Tarjeta de presupuesto: acento y color de barra según estado. */
.ct-budget { border-left: 3px solid var(--ace-border); }
.ct-budget--danger  { border-left-color: var(--ace-danger); }
.ct-budget--warning { border-left-color: var(--ace-warning); }
.ct-budget--success { border-left-color: var(--ace-success); }
.ct-budget--danger  .ace-progress__bar { background: var(--ace-danger); }
.ct-budget--warning .ace-progress__bar { background: var(--ace-warning); }
.ct-budget--success .ace-progress__bar { background: var(--ace-success); }

/* ---------------------------------------------------------------------------
   13) Metas (hitos que agrupan tareas).
   --------------------------------------------------------------------------- */
.ct-goal--done { opacity: 0.9; }
.ct-goal-tasks { display: flex; flex-direction: column; }
.ct-goal-task {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--ace-space-3); padding: var(--ace-space-2) 0;
  border-top: 1px solid var(--ace-border); flex-wrap: wrap;
}
.ct-goal-task:first-child { border-top: 0; }
.ct-goal-task__title { font-weight: var(--ace-weight-medium); color: var(--ace-text); text-decoration: none; min-width: 0; }
.ct-goal-task__title:hover { color: var(--ace-primary); }
.ct-goal-edit > summary { display: inline-flex; cursor: pointer; list-style: none; }
.ct-goal-edit > summary::-webkit-details-marker { display: none; }

/* ---------------------------------------------------------------------------
   14) Calendario mensual (rejilla lunes→domingo).
   --------------------------------------------------------------------------- */
.ct-cal { display: flex; flex-direction: column; gap: var(--ace-space-2); }
.ct-cal__toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--ace-space-3); flex-wrap: wrap; margin-bottom: var(--ace-space-2); }
.ct-cal__title { font-size: var(--ace-text-lg); font-weight: var(--ace-weight-semibold); margin: 0; min-width: 150px; text-align: center; }
.ct-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.ct-cal__dow { text-align: center; font-size: var(--ace-text-xs); color: var(--ace-text-muted); font-weight: var(--ace-weight-semibold); text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 0; }
.ct-cal__cell {
  min-height: 96px; border: 1px solid var(--ace-border); border-radius: var(--ace-radius);
  padding: 4px; display: flex; flex-direction: column; gap: 3px; background: var(--ace-surface); overflow: hidden;
}
.ct-cal__cell--out { background: var(--ace-surface-2); opacity: 0.6; }
.ct-cal__cell--today { border-color: var(--ace-primary); box-shadow: inset 0 0 0 1px var(--ace-primary); }
.ct-cal__daynum { font-size: var(--ace-text-xs); font-weight: var(--ace-weight-semibold); color: var(--ace-text-muted); }
.ct-cal__cell--today .ct-cal__daynum { color: var(--ace-primary); }
.ct-cal__task {
  display: block; font-size: var(--ace-text-xs); line-height: 1.25; padding: 2px 6px;
  border-radius: 6px; text-decoration: none; color: var(--ace-text);
  background: var(--ace-surface-2); border-left: 3px solid var(--ace-success);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ct-cal__task--rojo  { border-left-color: var(--ace-danger); }
.ct-cal__task--ambar { border-left-color: var(--ace-warning); }
.ct-cal__task--verde { border-left-color: var(--ace-success); }
.ct-cal__task--done { opacity: 0.55; text-decoration: line-through; }
.ct-cal__task:hover { background: var(--ace-primary-soft); }
@media (max-width: 720px) {
  .ct-cal__cell { min-height: 60px; }
  .ct-cal__task { font-size: 10px; padding: 1px 4px; }
  .ct-cal__dow { font-size: 10px; }
}

/* ---------------------------------------------------------------------------
   6) Gráfica de barras en CSS puro (dashboard). Altura por --ct-bar (0-100%).
   --------------------------------------------------------------------------- */
.ct-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: var(--ace-space-3);
  height: 180px;
  padding-top: var(--ace-space-2);
}
.ct-chart__col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ace-space-2);
  min-width: 0;
}
.ct-chart__bar {
  width: 100%;
  max-width: 48px;
  height: var(--ct-bar, 0%);
  min-height: 4px;
  border-radius: var(--ace-radius-sm) var(--ace-radius-sm) 0 0;
  background: var(--ace-primary);
  transition: height var(--ace-transition-slow) var(--ace-ease-out);
}
.ct-chart__bar--warning { background: var(--ace-warning); }
.ct-chart__bar--info    { background: var(--ace-info); }
.ct-chart__bar--success { background: var(--ace-success); }
.ct-chart__bar--muted   { background: var(--ace-text-subtle); }
.ct-chart__tag {
  font-size: var(--ace-text-xs);
  color: var(--ace-text-muted);
  text-align: center;
}
.ct-chart__val { font-weight: var(--ace-weight-semibold); color: var(--ace-text); }

/* ---------------------------------------------------------------------------
   7) Tablero Kanban (columnas por estatus).
   --------------------------------------------------------------------------- */
.ct-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: var(--ace-space-4);
  overflow-x: auto;
  padding-bottom: var(--ace-space-2);
}
.ct-board__col {
  background: var(--ace-surface-2);
  border: 1px solid var(--ace-border);
  border-radius: var(--ace-radius-md);
  padding: var(--ace-space-3);
  min-width: 0;
}
.ct-board__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ace-space-2);
  margin-bottom: var(--ace-space-3);
  font-weight: var(--ace-weight-semibold);
}
.ct-board__count {
  font-size: var(--ace-text-xs);
  color: var(--ace-text-muted);
  background: var(--ace-surface-3);
  border-radius: var(--ace-radius-full);
  padding: 0 var(--ace-space-2);
}
.ct-card {
  background: var(--ace-surface);
  border: 1px solid var(--ace-border);
  border-left: 3px solid var(--ace-border);
  border-radius: var(--ace-radius);
  padding: var(--ace-space-3);
  margin-bottom: var(--ace-space-3);
}
.ct-card--rojo  { border-left-color: var(--ace-danger); }
.ct-card--ambar { border-left-color: var(--ace-warning); }
.ct-card--verde { border-left-color: var(--ace-success); }
.ct-card__title { font-weight: var(--ace-weight-medium); text-decoration: none; color: var(--ace-text); display: block; }
.ct-card__meta { font-size: var(--ace-text-xs); color: var(--ace-text-muted); margin-top: var(--ace-space-1); }
@media (max-width: 640px) {
  .ct-board { grid-template-columns: repeat(4, 78vw); }
}
