/* ==================== TECH THEME ====================
   Utilities para darle apariencia tecnológica/profesional.
   Usar con clases utility que suman al diseño base.
   ==================================================== */

/* ===== Fondo con grid pattern sutil ===== */
.tech-grid {
  background-image:
    linear-gradient(rgba(99,102,241,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,.05) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: -1px -1px;
}
.tech-grid-dark {
  background-image:
    linear-gradient(rgba(129,140,248,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(129,140,248,.08) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: -1px -1px;
}

/* ===== Mesh gradient — fondo con múltiples manchas de color suaves ===== */
.tech-mesh {
  background-color: #0f172a !important;
  background-image:
    radial-gradient(at 20% 10%, rgba(99,102,241,.35) 0px, transparent 50%),
    radial-gradient(at 80% 20%, rgba(236,72,153,.25) 0px, transparent 50%),
    radial-gradient(at 40% 90%, rgba(16,185,129,.22) 0px, transparent 50%),
    radial-gradient(at 90% 80%, rgba(245,158,11,.18) 0px, transparent 50%) !important;
  color: white;
}

/* ===== Partículas flotantes decorativas ===== */
.tech-particles {
  position: relative;
  overflow: hidden;
}
.tech-particles::before,
.tech-particles::after {
  content: ''; position: absolute; border-radius: 50%;
  pointer-events: none; filter: blur(60px); opacity: .4;
}
.tech-particles::before {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #6366f1, transparent);
  top: -100px; left: -100px;
  animation: particleFloat1 20s ease-in-out infinite;
}
.tech-particles::after {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #ec4899, transparent);
  bottom: -150px; right: -100px;
  animation: particleFloat2 25s ease-in-out infinite;
}
@keyframes particleFloat1 {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(40px, 60px) scale(1.15); }
}
@keyframes particleFloat2 {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(-60px, -40px) scale(.9); }
}

/* ===== Glass card (glassmorphism) ===== */
.tech-glass {
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 8px 32px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.1);
}
.tech-glass-light {
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid rgba(255,255,255,.8);
  box-shadow: 0 8px 32px rgba(15,23,42,.08), inset 0 1px 0 rgba(255,255,255,.9);
}

/* ===== Gradient text (números grandes) — colores saturados para contraste en modo claro ===== */
.tech-gradient-text {
  background: linear-gradient(135deg, #4338ca 0%, #7c3aed 50%, #c026d3 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.tech-gradient-text-emerald {
  background: linear-gradient(135deg, #047857 0%, #059669 50%, #10b981 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
.tech-gradient-text-amber {
  background: linear-gradient(135deg, #b45309 0%, #d97706 50%, #ea580c 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
.tech-gradient-text-rose {
  background: linear-gradient(135deg, #be185d 0%, #db2777 50%, #e11d48 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
.tech-gradient-text-blue {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
/* Fallback de seguridad — si el browser no soporta background-clip:text (muy viejo),
   que al menos el texto se vea con color oscuro visible */
@supports not (background-clip: text) {
  .tech-gradient-text { color: #4338ca; -webkit-text-fill-color: #4338ca; }
  .tech-gradient-text-emerald { color: #059669; -webkit-text-fill-color: #059669; }
  .tech-gradient-text-amber { color: #d97706; -webkit-text-fill-color: #d97706; }
  .tech-gradient-text-rose { color: #db2777; -webkit-text-fill-color: #db2777; }
  .tech-gradient-text-blue { color: #2563eb; -webkit-text-fill-color: #2563eb; }
}
/* En modo oscuro: los gradients MÁS BRILLANTES para que se vean sobre fondo oscuro */
html.dark .tech-gradient-text {
  background: linear-gradient(135deg, #818cf8 0%, #c084fc 50%, #f0abfc 100%);
  -webkit-background-clip: text; background-clip: text;
}
html.dark .tech-gradient-text-emerald {
  background: linear-gradient(135deg, #34d399 0%, #6ee7b7 50%, #a7f3d0 100%);
  -webkit-background-clip: text; background-clip: text;
}
html.dark .tech-gradient-text-amber {
  background: linear-gradient(135deg, #fbbf24 0%, #fcd34d 50%, #fde68a 100%);
  -webkit-background-clip: text; background-clip: text;
}
html.dark .tech-gradient-text-rose {
  background: linear-gradient(135deg, #f472b6 0%, #fb7185 50%, #fda4af 100%);
  -webkit-background-clip: text; background-clip: text;
}
html.dark .tech-gradient-text-blue {
  background: linear-gradient(135deg, #60a5fa 0%, #93c5fd 50%, #bfdbfe 100%);
  -webkit-background-clip: text; background-clip: text;
}

/* ===== Neon glow en hover ===== */
.tech-neon {
  transition: box-shadow .25s, transform .25s, border-color .25s;
}
.tech-neon:hover {
  box-shadow:
    0 0 20px rgba(99,102,241,.4),
    0 0 40px rgba(99,102,241,.2),
    0 8px 24px rgba(0,0,0,.15);
  transform: translateY(-2px);
}

/* ===== Borde animado (running border) ===== */
.tech-border-glow {
  position: relative;
  background: white;
  border-radius: 16px;
}
.tech-border-glow::before {
  content: '';
  position: absolute; inset: -2px;
  border-radius: 18px;
  background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899, #f59e0b, #10b981, #6366f1);
  background-size: 300% 300%;
  z-index: -1;
  animation: borderGlowMove 4s linear infinite;
  opacity: .6;
}
@keyframes borderGlowMove {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* ===== Live indicator tipo osciloscopio (4 barras) ===== */
.tech-live {
  display: inline-flex; align-items: flex-end;
  gap: 2px; height: 16px;
}
.tech-live span {
  display: block; width: 3px; background: #10b981; border-radius: 1px;
  animation: liveBars 1s ease-in-out infinite;
}
.tech-live span:nth-child(1) { height: 30%; animation-delay: 0s; }
.tech-live span:nth-child(2) { height: 60%; animation-delay: .15s; }
.tech-live span:nth-child(3) { height: 100%; animation-delay: .3s; }
.tech-live span:nth-child(4) { height: 50%; animation-delay: .45s; }
@keyframes liveBars {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(.35); }
}

/* ===== Stat card premium ===== */
.tech-stat {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 18px; padding: 20px;
  transition: all .25s;
}
.tech-stat::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle at top right, rgba(99,102,241,.15) 0%, transparent 70%);
  pointer-events: none;
}
.tech-stat:hover {
  border-color: #818cf8;
  box-shadow: 0 20px 40px -10px rgba(99,102,241,.25);
  transform: translateY(-3px);
}
.tech-stat-label {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: #64748b;
}
.tech-stat-value {
  font-size: 38px; font-weight: 900; line-height: 1; margin-top: 6px;
  font-feature-settings: 'tnum'; letter-spacing: -0.02em;
}
.tech-stat-sub {
  font-size: 12px; color: #94a3b8; margin-top: 6px;
}

/* ===== Nav link con indicador activo ===== */
.tech-nav-link {
  position: relative;
  transition: color .2s;
}
.tech-nav-link::after {
  content: ''; position: absolute; left: 50%; bottom: -2px;
  width: 0; height: 2px;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border-radius: 2px;
  transition: width .25s, left .25s;
}
.tech-nav-link:hover::after,
.tech-nav-link.activo::after {
  width: 80%; left: 10%;
}
.tech-nav-link.activo {
  color: #4f46e5 !important;
}

/* ===== Dot decorativo para títulos ===== */
.tech-dot {
  display: inline-block; width: 8px; height: 8px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(99,102,241,.6);
  animation: dotPulse 2s ease-in-out infinite;
  margin-right: 10px; vertical-align: middle;
}
@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: .7; }
}

/* ===== Divisor con animación ===== */
.tech-divider {
  height: 1px; border: 0;
  background: linear-gradient(90deg, transparent, #6366f1, transparent);
  margin: 24px 0;
  position: relative; overflow: hidden;
}
.tech-divider::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.8), transparent);
  animation: dividerShine 3s linear infinite;
}
@keyframes dividerShine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ===== Badge tecnológico ===== */
.tech-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: linear-gradient(135deg, rgba(99,102,241,.15), rgba(168,85,247,.15));
  border: 1px solid rgba(99,102,241,.3);
  font-size: 11px; font-weight: 700;
  color: #4f46e5;
  text-transform: uppercase; letter-spacing: .08em;
}

/* ===== Scroll custom ===== */
.tech-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.tech-scroll::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.tech-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6366f1, #a855f7);
  border-radius: 4px;
}

/* ===== Page transition ===== */
body { animation: pageIn .35s cubic-bezier(.2,.8,.2,1); }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Mobile: aliviar animaciones pesadas ===== */
@media (max-width: 640px) {
  .tech-particles::before,
  .tech-particles::after { display: none; }
}

/* ======================================================
   MEJORAS GLOBALES DE DISEÑO — se aplican a TODAS las pantallas
   ====================================================== */

/* ===== Tipografía jerárquica profesional ===== */
h1 {
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
}
h1.tech-title, h1[class*="text-2xl"], h1[class*="text-3xl"], h1[class*="text-4xl"] {
  font-weight: 900;
  letter-spacing: -0.03em;
}
h2 {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #1e293b;
}

/* ===== Cards globales — elevación pro ===== */
.card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(15,23,42,.04), 0 1px 2px rgba(15,23,42,.04);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.card:hover { box-shadow: 0 10px 30px -8px rgba(15,23,42,.1), 0 4px 10px -2px rgba(15,23,42,.05); }

/* ===== Tablas globales ===== */
table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13px;
}
table.data thead tr {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}
table.data thead th {
  text-align: left; font-weight: 700; font-size: 10px;
  text-transform: uppercase; letter-spacing: .08em;
  color: #64748b; padding: 14px 12px;
  border-bottom: 2px solid #e2e8f0;
}
table.data tbody tr {
  transition: background .15s ease;
  border-bottom: 1px solid #f1f5f9;
}
table.data tbody tr:nth-child(even) { background: #fafbfc; }
table.data tbody tr:hover { background: #eef2ff !important; }
table.data tbody td { padding: 10px 12px; color: #1e293b; }
table.data tbody tr:last-child { border-bottom: 0; }

/* ===== Botones estandarizados ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px;
  font-weight: 600; font-size: 14px; line-height: 1;
  transition: all .2s cubic-bezier(.2,.8,.2,1);
  cursor: pointer; border: none; user-select: none;
}
.btn-secondary {
  background: white; color: #334155;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.btn-secondary:hover { background: #f8fafc; border-color: #818cf8; color: #4f46e5; transform: translateY(-1px); }

/* ===== Inputs y selects más pro ===== */
input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="date"], input[type="search"], textarea, select {
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus,
input[type="password"]:focus, input[type="date"]:focus, input[type="search"]:focus,
textarea:focus, select:focus {
  outline: none;
  border-color: #818cf8 !important;
  box-shadow: 0 0 0 4px rgba(99,102,241,.12);
}

/* ===== Links con subrayado animado ===== */
.link-tech {
  position: relative; color: #4f46e5; font-weight: 500;
  text-decoration: none;
}
.link-tech::after {
  content: ''; position: absolute; bottom: -2px; left: 0;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  transform: scaleX(0); transform-origin: right;
  transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
.link-tech:hover::after { transform: scaleX(1); transform-origin: left; }

/* ===== Headings con punto animado ===== */
.tech-heading {
  display: flex; align-items: center; gap: 12px;
  font-weight: 900; letter-spacing: -.02em;
}
.tech-heading::before {
  content: ''; width: 6px; height: 28px;
  background: linear-gradient(180deg, #6366f1, #a855f7);
  border-radius: 3px;
  box-shadow: 0 0 12px rgba(99,102,241,.5);
}

/* ===== Empty states más pro ===== */
.empty-state {
  text-align: center; padding: 48px 24px;
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
}
.empty-state-icon {
  font-size: 48px; margin-bottom: 12px;
  filter: grayscale(.3);
}

/* ===== Tags / chips ===== */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: #f1f5f9; color: #475569;
}
.chip-indigo { background: #eef2ff; color: #4338ca; }
.chip-emerald { background: #d1fae5; color: #047857; }
.chip-amber { background: #fef3c7; color: #92400e; }
.chip-rose { background: #fce7f3; color: #9d174d; }
.chip-red { background: #fee2e2; color: #991b1b; }

/* ===== Section divider con label ===== */
.section-title {
  display: flex; align-items: center; gap: 12px;
  margin: 32px 0 16px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, #e2e8f0, transparent);
}
.section-title-text {
  font-size: 11px; text-transform: uppercase; letter-spacing: .15em;
  font-weight: 800; color: #64748b;
}

/* ===== Mejor scroll global ===== */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 #f1f5f9; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: #f1f5f9; }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #cbd5e1, #94a3b8);
  border-radius: 5px; border: 2px solid #f1f5f9;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #6366f1, #4f46e5);
}

/* ===== Focus ring accesible en botones ===== */
button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

/* ===== Cards con acento superior ===== */
.card-accent {
  position: relative; overflow: hidden;
}
.card-accent::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
}

/* ===== Badge "NUEVO" ===== */
.badge-nuevo {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9px; font-weight: 900;
  padding: 2px 6px; border-radius: 4px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white; letter-spacing: .1em; text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(16,185,129,.4);
  vertical-align: middle;
}

/* ===== Modo oscuro mejorado para .card ===== */
html.dark .card {
  background: rgba(30,41,59,.7);
  border-color: rgba(71,85,105,.5);
  color: #e2e8f0;
}
html.dark table.data thead tr {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}
html.dark table.data thead th { color: #94a3b8; border-color: #334155; }
html.dark table.data tbody tr:nth-child(even) { background: rgba(30,41,59,.4); }
html.dark table.data tbody tr:hover { background: rgba(99,102,241,.15) !important; }
html.dark table.data tbody td { color: #e2e8f0; }

/* ===== PWA installed — slight different bg (tip: indica que estás en la app) ===== */
@media (display-mode: standalone) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ===== Highlight cuando se llega a una sección por anchor (#...) ===== */
:target {
  animation: targetPulse 2s ease-out;
  scroll-margin-top: 80px;
}
@keyframes targetPulse {
  0% { box-shadow: 0 0 0 0 rgba(99,102,241,.5); transform: scale(1); }
  30% { box-shadow: 0 0 0 10px rgba(99,102,241,.3); transform: scale(1.01); }
  100% { box-shadow: 0 0 0 0 transparent; transform: scale(1); }
}

/* ===== Widgets de chat/alertas SOLO para usuarios logueados =====
   Si el body no tiene data-yo (usuario logueado), ocultar TODO.
   Esto es defensa en profundidad por si el SW cacheó scripts viejos. */
body:not([data-yo]) #chat-widget,
body:not([data-yo]) #alertas-widget,
body:not([data-yo]) .chat-panel,
body:not([data-yo]) .alerta-fab,
body:not([data-yo]) .alerta-banner {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
