/*
 * efectos.css — acabado del modo facturación (MODO_FACTURACION=1): entradas, brillo, avisos, paleta Ctrl+K y gráfico.
 * Solo se carga desde partials/admin-header.php con la constante puesta. Todo respeta prefers-reduced-motion.
 * Sin el JS (efectos.js) la página se ve completa: nada se oculta salvo lo marcado con html.fx-js.
 */

/* ---------- Animaciones ---------- */
@keyframes fx-entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fx-pagina { from { opacity: 0; } to { opacity: 1; } }
@keyframes fx-crece { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes fx-brillo { from { background-position: -160% 0; } to { background-position: 160% 0; } }

/* Entrada escalonada de tarjetas y filas (--fx-i lo pone efectos.js; sin JS, todas a la vez) */
.fx-js body.modo-facturacion .stat-card,
.fx-js body.modo-facturacion .table-wrap tbody tr {
  animation: fx-entra .45s cubic-bezier(.2, .7, .2, 1) backwards;
  animation-delay: calc(var(--fx-i, 0) * 70ms);
}
.fx-js body.modo-facturacion { animation: fx-pagina .22s ease backwards; }

/* Fundido corto al cambiar de pantalla (efectos.js añade fx-salir y navega al terminar) */
body.modo-facturacion { transition: opacity .17s ease; }
body.modo-facturacion.fx-salir { opacity: 0; }

/* ---------- Tarjetas de cristal: brillo que sigue al ratón y elevación ---------- */
body.modo-facturacion .stat-card { position: relative; overflow: hidden; transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; }
body.modo-facturacion .stat-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0, 0, 0, .3), 0 0 0 1px rgba(118, 227, 255, .12); }
body.modo-facturacion .stat-card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s ease;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(118, 227, 255, .16), transparent 62%);
}
body.modo-facturacion .stat-card:hover::before { opacity: 1; }
body.modo-facturacion .stat-card > * { position: relative; }
body.modo-facturacion .stat-card .fx-texto-largo { font-size: 18px; }

/* ---------- Esqueleto (shimmer) mientras llega el gráfico ---------- */
.fx-js .fx-esqueleto { position: relative; }
.fx-js .fx-esqueleto::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(118, 227, 255, .14) 50%, transparent 70%) no-repeat;
  background-size: 200% 100%; animation: fx-brillo 1.2s linear infinite;
}
.fx-js .fx-esqueleto.fx-listo::after { display: none; }

/* ---------- Gráfico de facturación por mes ---------- */
.fx-panel-grafico { margin: 8px 0 22px; }
.fx-grafico {
  position: relative; border-radius: 16px; padding: 14px 10px 6px; margin-bottom: 14px;
  border: 1px solid rgba(118, 227, 255, .18); background: rgba(14, 26, 46, .6);
}
.fx-grafico svg { display: block; width: 100%; height: auto; overflow: visible; }
.fx-base { stroke: rgba(118, 227, 255, .2); stroke-width: 1; }
.fx-barra { fill: #3d5f8f; transition: fill .2s ease; transform-box: fill-box; transform-origin: 50% 100%; }
.fx-barra.actual { fill: #76e3ff; }
.fx-barra-g { cursor: default; outline: none; }
.fx-barra-g:hover .fx-barra, .fx-barra-g:focus-visible .fx-barra { fill: #9e7bff; }
.fx-barra-g:hover .fx-barra.actual, .fx-barra-g:focus-visible .fx-barra.actual { fill: #bff0ff; }
.fx-barra-g:focus-visible .fx-barra { stroke: #76e3ff; stroke-width: 1.5; }
.fx-js .fx-barra { animation: fx-crece .6s cubic-bezier(.2, .7, .2, 1) backwards; animation-delay: calc(var(--i, 0) * 40ms); }
.fx-eje { fill: var(--text-muted, #8fa3bd); font-family: var(--ff-mono); font-size: 12px; }
.fx-tip {
  position: absolute; z-index: 2; pointer-events: none; transform: translate(-50%, calc(-100% - 8px));
  padding: 6px 10px; border-radius: 10px; white-space: nowrap;
  background: #0e1a2e; border: 1px solid rgba(118, 227, 255, .4); color: #e8f1fb;
  font-family: var(--ff-mono); font-size: 12px; box-shadow: 0 8px 20px rgba(0, 0, 0, .35);
}
.fx-tip[hidden] { display: none; }
.fx-resumen .stat-card strong { word-break: break-word; }

/* ---------- Avisos emergentes (window.facToast) ---------- */
.fx-toasts {
  position: fixed; top: 16px; right: 16px; z-index: 9000; display: flex; flex-direction: column; gap: 8px;
  width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.fx-toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 14px;
  background: rgba(12, 24, 44, .94); border: 1px solid rgba(118, 227, 255, .32); color: #e8f1fb;
  font: 500 14px/1.45 system-ui, 'Work Sans', sans-serif; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: fx-entra .3s ease backwards; transition: opacity .2s ease;
}
.fx-toast.ok { border-color: rgba(123, 226, 173, .6); }
.fx-toast.aviso { border-color: rgba(245, 166, 35, .65); }
.fx-toast.error { border-color: rgba(255, 107, 107, .75); }
.fx-toast.fx-saliendo { opacity: 0; }
.fx-toast-txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fx-toast-x {
  flex: 0 0 auto; min-width: 44px; min-height: 44px; margin: -10px -8px -10px 0; border: 0; background: transparent;
  color: inherit; font-size: 16px; cursor: pointer; border-radius: 10px;
}
.fx-toast-x:hover { background: rgba(118, 227, 255, .12); }

/* ---------- Botón ⌘K de la cabecera ---------- */
.fx-cmd-btn {
  min-height: 36px; padding: 0 12px; margin-right: 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(118, 227, 255, .45); background: rgba(118, 227, 255, .1); color: #76e3ff;
  font-family: var(--ff-mono); font-size: 12px; font-weight: 600; letter-spacing: .04em; vertical-align: middle;
}
.fx-cmd-btn:hover { background: rgba(118, 227, 255, .22); color: #fff; }

/* ---------- Paleta de comandos (Ctrl+K o /) ---------- */
.fx-cmd-fondo {
  position: fixed; inset: 0; z-index: 9500; display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 14px 14px; background: rgba(3, 8, 16, .58); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.fx-cmd-fondo[hidden] { display: none; }
.fx-cmd {
  position: relative; width: min(580px, 100%); max-height: 70vh; display: flex; flex-direction: column; overflow: hidden;
  border-radius: 18px; background: linear-gradient(160deg, rgba(118, 227, 255, .08), rgba(158, 123, 255, .05)), rgba(10, 20, 36, .94);
  border: 1px solid rgba(118, 227, 255, .26); box-shadow: 0 24px 60px rgba(0, 0, 0, .5); color: #e8f1fb;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.fx-cmd-cab { display: flex; align-items: center; border-bottom: 1px solid rgba(118, 227, 255, .16); }
.fx-cmd-buscar {
  flex: 1; min-width: 0; min-height: 56px; padding: 0 18px; border: 0; background: transparent; color: inherit;
  font: 500 16px system-ui, 'Work Sans', sans-serif; outline: none;
}
.fx-cmd-buscar::placeholder { color: #8fa3bd; }
.fx-cmd-cerrar {
  flex: 0 0 auto; min-width: 44px; min-height: 44px; margin-right: 6px; border: 0; background: transparent; color: #8fa3bd;
  font-size: 16px; cursor: pointer; border-radius: 10px;
}
.fx-cmd-cerrar:hover { color: #fff; background: rgba(118, 227, 255, .12); }
.fx-cmd-lista { list-style: none; margin: 0; padding: 6px; overflow-y: auto; min-height: 0; }
.fx-cmd-grupo {
  padding: 10px 12px 4px; font-family: var(--ff-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #8fa3bd;
}
.fx-cmd-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 8px 12px;
  border-radius: 12px; cursor: pointer; scroll-margin: 6px;
}
.fx-cmd-item[aria-selected="true"] { background: rgba(118, 227, 255, .14); box-shadow: inset 2px 0 0 #76e3ff; }
.fx-cmd-item-sub { font-family: var(--ff-mono); font-size: 12px; color: #8fa3bd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fx-cmd-item-txt { min-width: 0; overflow-wrap: anywhere; }
.fx-cmd-estado { margin: 0; padding: 4px 16px; font-size: 13px; color: #8fa3bd; min-height: 0; }
.fx-cmd-estado:empty { display: none; }
.fx-cmd-pie {
  padding: 8px 14px; border-top: 1px solid rgba(118, 227, 255, .14); font-family: var(--ff-mono); font-size: 11px; color: #8fa3bd;
}
.fx-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Tema claro: mismos componentes sobre fondo claro */
:root[data-theme="light"] .fx-cmd { background: rgba(255, 255, 255, .97); color: #0b1d33; border-color: rgba(30, 90, 140, .25); }
:root[data-theme="light"] .fx-cmd-buscar { color: #0b1d33; }
:root[data-theme="light"] .fx-cmd-item[aria-selected="true"] { background: rgba(30, 140, 200, .12); box-shadow: inset 2px 0 0 #1e8cc8; }
:root[data-theme="light"] .fx-toast, :root[data-theme="light"] .fx-tip { background: #fff; color: #0b1d33; }
:root[data-theme="light"] .fx-cmd-btn { color: #0a6e96; border-color: rgba(10, 110, 150, .4); background: rgba(10, 110, 150, .08); }

/* ---------- Teléfono: sin desbordes ---------- */
@media (max-width: 600px) {
  .fx-cmd-fondo { padding-top: 8vh; }
  .fx-cmd-item-sub { display: none; }
  .fx-toasts { top: auto; bottom: 88px; right: 12px; }
  .fx-cmd-btn { padding: 0 9px; margin-right: 4px; }
}

/* ---------- Movimiento reducido: nada se anima ---------- */
@media (prefers-reduced-motion: reduce) {
  .fx-js body.modo-facturacion,
  .fx-js body.modo-facturacion .stat-card,
  .fx-js body.modo-facturacion .table-wrap tbody tr,
  .fx-js .fx-barra,
  .fx-js .fx-esqueleto::after,
  .fx-toast { animation: none !important; }
  body.modo-facturacion, body.modo-facturacion .stat-card, body.modo-facturacion .stat-card::before,
  .fx-barra, .fx-toast { transition: none !important; }
  body.modo-facturacion .stat-card:hover { transform: none; }
  body.modo-facturacion .stat-card::before, .fx-js .fx-esqueleto::after { display: none; }
}
