/* ============================================================
   ByPertuso v2.0 — Temas (día/noche estilo shadcn), versión,
   botón flotante de avisos y efectos. Se carga después de app.css.
   ============================================================ */

/* ---- Tokens semánticos (shadcn-style). Día es el default. ---- */
:root {
  --background:   #f6f7f8;
  --surface:      #ffffff;
  --surface-2:    #fcfcfd;
  --muted:        #f0f2f4;
  --muted-2:      #eef0f2;
  --foreground:   #0f1113;
  --primary:      #0f1113;
  --primary-fg:   #ffffff;
  --topbar:       #0f1113;
  --topbar-fg:    #ffffff;
  --input-bg:     #ffffff;
  --ring:         var(--mint-soft);
  --chart-grid:   #e6e8eb;
  --chart-bar:    #0f1113;
  --chart-text:   #6b7280;
  --chart-label:  #9aa1a9;
  --font-body:    'Geist', 'Hanken Grotesk', system-ui, 'Segoe UI', Roboto, sans-serif;
  --radius:       12px;
  --radius-sm:    8px;
}

/* ---- Noche (escala zinc) ---- */
:root[data-theme="dark"] {
  --bg:           #09090b;
  --background:   #09090b;
  --surface:      #18181b;
  --surface-2:    #1c1c20;
  --muted:        #1f1f23;
  --muted-2:      #27272a;
  --line:         #27272a;
  --ink:          #fafafa;
  --ink-2:        #e4e4e7;
  --foreground:   #fafafa;
  --gray:         #a1a1aa;
  --gray-2:       #71717a;
  --primary:      #fafafa;
  --primary-fg:   #09090b;
  --topbar:       #0b0b0d;
  --topbar-fg:    #fafafa;
  --input-bg:     #18181b;
  --mint-ink:     #34d399;
  --mint-soft:    rgba(55,224,166,.14);
  --yellow-soft:  rgba(255,225,77,.14);
  --danger-soft:  rgba(229,72,77,.16);
  --ring:         rgba(55,224,166,.25);
  --chart-grid:   #27272a;
  --chart-bar:    #fafafa;
  --chart-text:   #a1a1aa;
  --chart-label:  #71717a;
  --shadow:       0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-sm:    0 1px 2px rgba(0,0,0,.35);
  color-scheme: dark;
}

/* ---- Re-map de superficies que usaban colores fijos ---- */
body { background: var(--background); color: var(--foreground); }
.topbar { background: var(--topbar); color: var(--topbar-fg); }
body.nav-open .mainnav { background: var(--topbar); }
.site-footer { background: var(--topbar); }
.btn-primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.chip.on { background: var(--primary); color: var(--primary-fg); }
input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=number], input[type=date], textarea, select { background: var(--input-bg); color: var(--foreground); }
input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 3px var(--ring); }
.item { background: var(--surface-2); }
.pl-col { background: var(--muted); }
.seg, .chip, .pl-count { background: var(--muted-2); }
.seg-btn.active { background: var(--surface); color: var(--foreground); }
.rt-toolbar button, .plc-ic { background: var(--surface); color: var(--gray); }
.it-del { background: var(--muted-2); color: var(--gray); }
.folder-head:hover { background: var(--surface-2); }
.login-card { background: var(--surface); }
.tbl th { color: var(--gray); }
.pl-vermas { border-color: var(--gray-2); }
.pl-card.moved { box-shadow: 0 0 0 2px var(--mint); }

/* Pills / cabeceras del pipeline en modo noche (versión translúcida) */
:root[data-theme="dark"] .pill-borrador,    :root[data-theme="dark"] .pl-borrador    { background: rgba(255,255,255,.08); color: #d4d4d8; }
:root[data-theme="dark"] .pill-enviado,     :root[data-theme="dark"] .pl-enviado     { background: rgba(96,165,250,.16); color: #93c5fd; }
:root[data-theme="dark"] .pill-seguimiento, :root[data-theme="dark"] .pl-seguimiento { background: rgba(255,225,77,.14); color: #fde68a; }
:root[data-theme="dark"] .pill-aprobado,    :root[data-theme="dark"] .pl-aprobado    { background: rgba(55,224,166,.14); color: #6ee7b7; }
:root[data-theme="dark"] .pill-descartado,  :root[data-theme="dark"] .pl-descartado  { background: rgba(229,72,77,.16); color: #fca5a5; }
:root[data-theme="dark"] .pill-off, :root[data-theme="dark"] .pill-k-borrador { background: rgba(255,255,255,.08); color: #d4d4d8; }
:root[data-theme="dark"] .pill-k-enviado { background: rgba(96,165,250,.16); color: #93c5fd; }
:root[data-theme="dark"] .pill-k-firmado { background: rgba(55,224,166,.14); color: #6ee7b7; }
:root[data-theme="dark"] .pill-k-anulado { background: rgba(229,72,77,.16); color: #fca5a5; }
:root[data-theme="dark"] .tag { background: rgba(55,224,166,.14); color: #6ee7b7; }
:root[data-theme="dark"] .alert { background: var(--danger-soft); color: #fca5a5; border-color: rgba(229,72,77,.3); }
:root[data-theme="dark"] .sum-note { background: var(--yellow-soft); color: #fde68a; }
:root[data-theme="dark"] .ok-check { color: #09090b; }
:root[data-theme="dark"] .login-body { background: radial-gradient(120% 120% at 50% 0%, #131316 0%, #09090b 60%); }

/* Gráfica del home: colores por token para que funcione en ambos temas */
.ch-grid   { stroke: var(--chart-grid); }
.ch-bar    { fill: var(--chart-bar); }
.ch-bar-ok { fill: var(--mint); }
.ch-val    { fill: var(--chart-text); }
.ch-lbl    { fill: var(--chart-label); }
.dot-ink   { background: var(--chart-bar); }

/* ---- Refinamiento shadcn: bordes nítidos, radios consistentes, foco visible ---- */
.card, .list-row, .pl-card, .folder { box-shadow: none; border: 1px solid var(--line); }
.btn { border-radius: var(--radius-sm); font-weight: 600; }
.btn-ghost { background: var(--surface); }
.btn-ghost:hover { background: var(--muted); }
.btn:focus-visible, a:focus-visible, select:focus-visible, .plc-ic:focus-visible,
.theme-toggle:focus-visible, .fab:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.pill { font-weight: 600; letter-spacing: .01em; }

/* ---- Versión junto al logo ---- */
.brand { flex-direction: column; align-items: flex-start; gap: 1px; }
.brand-version {
  font-family: var(--font-body); font-size: .62rem; letter-spacing: .04em; text-transform: uppercase;
  color: rgba(255,255,255,.55); line-height: 1; padding-left: 2px;
}
.footer-version { opacity: .7; }
.login-version { color: var(--gray-2); font-size: .72rem; margin: 4px 0 0; letter-spacing: .04em; text-transform: uppercase; }

/* ---- Toggle de tema ---- */
.theme-toggle {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); color: #fff;
  border-radius: 999px; width: 38px; height: 38px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; font-size: 1rem; flex: 0 0 auto;
}
.theme-toggle:hover { background: rgba(255,255,255,.14); }
.theme-toggle .tt-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .tt-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .tt-moon { display: inline; }
@media (min-width: 780px) { .theme-toggle { order: 2; margin-left: 6px; } .mainnav { order: 1; } }

/* ---- Botón flotante de avisos (abajo a la derecha) ---- */
.fab-wrap { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60; }
.fab {
  width: 56px; height: 56px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--primary); color: var(--primary-fg); font-size: 1.35rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center;
  position: relative; transition: transform .12s ease;
}
.fab:active { transform: scale(.96); }
.fab-badge {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: .74rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--background);
}
.fab-panel {
  position: absolute; right: 0; bottom: 68px; width: min(340px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,.22); overflow: hidden;
}
.fab-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.fab-panel-head b { font-family: var(--font-title); font-weight: 600; }
.fab-close { background: none; border: 0; cursor: pointer; color: var(--gray); font-size: 1rem; }
.fab-empty { padding: 16px 14px; margin: 0; color: var(--gray); font-size: .9rem; }
.fab-list { max-height: 55vh; overflow-y: auto; }
.fab-item { display: flex; flex-direction: column; gap: 2px; padding: 11px 14px; text-decoration: none; color: var(--foreground); border-bottom: 1px solid var(--line); }
.fab-item:last-child { border-bottom: 0; }
.fab-item:hover { background: var(--muted); }
.fab-item-cli { font-weight: 600; }
.fab-item-meta { font-size: .76rem; color: var(--gray-2); }
.fab-item-txt { font-size: .8rem; font-weight: 700; }
.fab-pronto .fab-item-txt { color: #b45309; }
.fab-hoy .fab-item-txt { color: #c2410c; }
.fab-vencido .fab-item-txt { color: var(--danger); }
:root[data-theme="dark"] .fab-pronto .fab-item-txt { color: #fbbf24; }
:root[data-theme="dark"] .fab-hoy .fab-item-txt { color: #fb923c; }

/* Meta de tarjetas: aprobado / vence */
.meta-ok { color: var(--mint-ink); font-weight: 600; }
.meta-pronto { color: #b45309; font-weight: 600; }
.meta-vencido { color: var(--danger); font-weight: 700; }
:root[data-theme="dark"] .meta-pronto { color: #fbbf24; }

/* ---- Capa de efectos (confeti / tristeza) ---- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 80; }
.fx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.fx-toast, .fx-sad {
  position: absolute; left: 50%; top: 18%; transform: translate(-50%, 0);
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  background: var(--surface); color: var(--foreground); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px 22px; box-shadow: 0 16px 40px rgba(0,0,0,.25);
  animation: fx-in .35s cubic-bezier(.2,.9,.3,1.2) both;
}
.fx-toast b, .fx-sad b { font-family: var(--font-title); font-weight: 600; font-size: 1.1rem; }
.fx-toast span:last-child, .fx-sad span:last-child { color: var(--gray); font-size: .85rem; }
.fx-emoji { font-size: 2.2rem; animation: fx-bounce .9s ease-in-out infinite; }
.fx-sad-emoji { font-size: 3.4rem; animation: fx-drop 1.6s ease-in-out infinite; }
.fx-toast.out, .fx-sad.out { animation: fx-out .4s ease-in both; }
@keyframes fx-in  { from { opacity: 0; transform: translate(-50%, 18px) scale(.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes fx-out { to { opacity: 0; transform: translate(-50%, -12px) scale(.96); } }
@keyframes fx-bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes fx-drop { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(6px) rotate(3deg); } }

/* El FAB no debe tapar el contenido inferior en móvil */
@media (max-width: 620px) { .wrap { padding-bottom: 96px; } }
