@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;800;900&family=Share+Tech+Mono&family=Inter:wght@300;400;500;600&display=swap');

/* ═══════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════ */
:root {
  --sw-font-h: 'Barlow Condensed', sans-serif;
  --sw-font-m: 'Share Tech Mono', monospace;
  --sw-font-b: 'Inter', sans-serif;

  /* Modo oscuro (default) */
  --sw-red:        #A30000;
  --sw-red-dark:   #6B0000;
  --sw-red-glow:   rgba(163, 0, 0, 0.3);
  --sw-black:      #000000;
  --sw-white:      #F5F5F5;
  --sw-dark:       #121212;
  --sw-steel:      #2A2A2A;
  --sw-border:     rgba(163, 0, 0, 0.2);
  --sw-text-muted: var(--sw-text-muted);
  --sw-nav-bg:     rgba(0, 0, 0, 0.95);
  --sw-scanline:   rgba(0, 0, 0, 0.04);
}

/* Modo claro */
:root.light-mode {
  --sw-black:      #F0EDE8;
  --sw-white:      #1a1a1a;
  --sw-dark:       #FAFAFA;
  --sw-steel:      #E5E0DA;
  --sw-border:     rgba(163, 0, 0, 0.3);
  --sw-text-muted: rgba(26, 26, 26, 0.5);
  --sw-nav-bg:     rgba(240, 237, 232, 0.97);
  --sw-scanline:   rgba(0, 0, 0, 0.02);
}

/* ═══════════════════════════════════════════
   BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

.tac-page {
  display: flex; flex-direction: column;
  font-family: var(--sw-font-b);
  background: var(--sw-black);
  color: var(--sw-white);
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
}

/* ═══════════════════════════════════════════
   NAVBAR
═══════════════════════════════════════════ */
.sw-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  border-bottom: 1px solid transparent;
  transition: background 0.3s, border-color 0.3s;
}
.sw-nav.scrolled {
  background: var(--sw-nav-bg);
  border-color: var(--sw-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.sw-nav__inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
  display: flex; align-items: center; justify-content: space-between; height: 64px;
}

/* Links de navegación */
.sw-nav__links {
  display: flex; align-items: center; gap: 0;
}
.sw-nav__link {
  font-family: var(--sw-font-m);
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--sw-text-muted);
  padding: 0.4rem 0.7rem; transition: color 0.2s;
  text-decoration: none;
}
.sw-nav__link:hover { color: var(--sw-red); }
.sw-nav__sep { width: 1px; height: 18px; background: var(--sw-border); margin: 0 0.4rem; }

/* Controles del navbar (tema + hamburguesa) */
.sw-nav__controls {
  display: flex; align-items: center; gap: 8px;
}

/* Botón de tema */
.sw-theme-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--sw-border);
  color: var(--sw-text-muted); cursor: pointer;
  transition: all 0.2s; font-size: 0.95rem;
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
}
.sw-theme-btn:hover { border-color: var(--sw-red); color: var(--sw-red); }

/* Hamburguesa */
.sw-hamburger {
  display: none; flex-direction: column; justify-content: center; align-items: center;
  width: 36px; height: 36px; gap: 5px;
  background: transparent; border: 1px solid var(--sw-border); cursor: pointer;
  transition: border-color 0.2s;
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
}
.sw-hamburger:hover { border-color: var(--sw-red); }
.sw-hamburger span {
  display: block; width: 18px; height: 1.5px;
  background: var(--sw-white); transition: all 0.25s;
}
.sw-hamburger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.sw-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.sw-hamburger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ═══════════════════════════════════════════
   BOTONES
═══════════════════════════════════════════ */
.sw-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  font-family: var(--sw-font-m);
  font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase;
  border: none; cursor: pointer; padding: 0.65rem 1.6rem;
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
  transition: all 0.2s ease; line-height: 1;
  text-decoration: none;
}
.sw-btn--primary { background: var(--sw-red); color: #F5F5F5; }
.sw-btn--primary:hover { background: #c40000; box-shadow: 0 0 18px var(--sw-red-glow); }
.sw-btn--ghost { background: transparent; color: var(--sw-white); border: 1px solid var(--sw-border); }
.sw-btn--ghost:hover { border-color: var(--sw-red); color: var(--sw-red); }
.sw-btn--sm { padding: 0.45rem 1.1rem; font-size: 0.68rem; }
.sw-btn--full { width: 100%; justify-content: center; }

/* ═══════════════════════════════════════════
   FORMULARIOS AUTH
═══════════════════════════════════════════ */
.sw-auth-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 5rem 1rem 2rem; position: relative; z-index: 10;
}
.sw-auth-panel {
  width: 100%; max-width: 440px;
  border: 1px solid var(--sw-border);
  background: var(--sw-dark);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
  overflow: hidden;
}
.sw-auth-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: rgba(163, 0, 0, 0.06);
  border-bottom: 1px solid var(--sw-border);
}
.sw-auth-dot { width: 9px; height: 9px; border-radius: 50%; }
.sw-auth-dot.r { background: #ff5f57; }
.sw-auth-dot.y { background: #febc2e; }
.sw-auth-dot.g { background: #28c840; }
.sw-auth-body { padding: 2rem; }

.sw-input-group { margin-bottom: 1.5rem; }
.sw-label {
  display: block; margin-bottom: 0.5rem;
  font-family: var(--sw-font-m);
  font-size: 0.6rem; letter-spacing: 0.16em;
  color: rgba(163, 0, 0, 0.85); text-transform: uppercase;
}
.sw-input {
  width: 100%;
  background: var(--sw-black);
  border: 1px solid var(--sw-border);
  color: var(--sw-white); font-family: var(--sw-font-m);
  font-size: 0.82rem; padding: 0.65rem 0.9rem; outline: none;
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
  transition: border-color 0.2s, box-shadow 0.2s;
}
.sw-input:focus { border-color: var(--sw-red); box-shadow: 0 0 0 2px var(--sw-red-glow); }
.sw-input::placeholder { color: var(--sw-text-muted); opacity: 0.5; }

.sw-alert {
  font-family: var(--sw-font-m); font-size: 0.78rem; letter-spacing: 0.06em;
  padding: 0.75rem 1rem; border: 1px solid rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.07); color: #f87171; margin-bottom: 1.25rem;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}
.sw-alert--success { border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.07); color: #4ade80; }

/* ═══════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════ */
.sw-footer {
  border-top: 1px solid var(--sw-border);
  padding: 3rem 0 1.5rem;
  background: var(--sw-black);
  position: relative; z-index: 10;
  transition: background 0.25s, border-color 0.25s;
  margin-top: auto;
}
[data-theme="light"] .sw-footer {
  background: var(--sw-white);
  border-top-color: var(--sw-border);
}
.sw-footer__inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
  display: flex; flex-direction: column; gap: 2.5rem;
}
.sw-footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
}
.sw-footer__brand {
  display: flex; flex-direction: column; gap: 0.75rem; align-items: flex-start;
}
.sw-footer__logo {
  height: 38px; object-fit: contain; transition: opacity 0.2s;
}
.sw-footer__logo:hover {
  opacity: 0.85;
}
.sw-footer__tagline {
  font-family: var(--sw-font-m);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--sw-text-muted);
  margin: 0; line-height: 1.5;
}
.sw-footer__col h4 {
  font-family: var(--sw-font-m);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  color: var(--sw-red);
  text-transform: uppercase;
  margin: 0 0 1rem 0;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--sw-border);
}
.sw-footer__links {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.sw-footer__links li {
  display: flex;
}
.sw-footer__link {
  font-family: var(--sw-font-m);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--sw-text-muted);
  text-decoration: none;
  transition: color 0.2s, transform 0.2s;
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.sw-footer__link:hover {
  color: var(--sw-red);
  transform: translateX(2px);
}
.sw-footer__link i {
  font-size: 0.7rem; color: var(--sw-red); opacity: 0.8;
}
.sw-footer__bottom {
  border-top: 1px solid var(--sw-border);
  padding-top: 1.25rem;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
}
.sw-footer__copy {
  font-family: var(--sw-font-m); font-size: 0.62rem; letter-spacing: 0.08em; color: var(--sw-text-muted);
  display: flex; align-items: center; gap: 0.5rem;
}
.sw-footer__status { display: flex; align-items: center; gap: 0.4rem; font-family: var(--sw-font-m); font-size: 0.62rem; letter-spacing: 0.08em; color: #22c55e; text-transform: uppercase; }

@media (max-width: 900px) {
  .sw-footer__grid {
    grid-template-columns: 1fr 1fr; gap: 2rem;
  }
  .sw-footer__brand {
    grid-column: 1 / -1;
  }
}
@media (max-width: 576px) {
  .sw-footer__grid {
    grid-template-columns: 1fr; gap: 1.75rem;
  }
  .sw-footer__bottom {
    flex-direction: column; align-items: flex-start;
  }
}

/* ═══════════════════════════════════════════
   EFECTOS VISUALES
═══════════════════════════════════════════ */
.sw-scanlines {
  position: fixed; inset: 0; z-index: 9990; pointer-events: none;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    var(--sw-scanline) 2px,
    var(--sw-scanline) 4px
  );
}
.noise-overlay {
  position: fixed; inset: 0; z-index: 9997; pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

.sw-pulse { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #22c55e; animation: swPulse 2s infinite; }
@keyframes swPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

.hud-corner { position: absolute; width: 40px; height: 40px; pointer-events: none; z-index: 5; }
.hud-tl { top: 80px; left: 20px; }
.hud-tr { top: 80px; right: 20px; }
.hud-bl { bottom: 60px; left: 20px; }
.hud-br { bottom: 60px; right: 20px; }
.hud-line { position: absolute; background: var(--sw-red); }
.hud-line.h { width: 100%; height: 1px; top: 0; }
.hud-line.v { width: 1px; height: 100%; left: 0; }

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
═══════════════════════════════════════════ */

/* Tablet */
@media (max-width: 900px) {
  .hud-corner { display: none; }
}

/* Mobile */
@media (max-width: 680px) {

  /* Hamburguesa visible */
  .sw-hamburger { display: flex; }

  /* Links colapsados por defecto */
  .sw-nav__links {
    display: none;
    flex-direction: column; align-items: flex-start;
    position: absolute; top: 64px; left: 0; right: 0;
    background: var(--sw-nav-bg);
    border-bottom: 1px solid var(--sw-border);
    padding: 1rem clamp(1rem, 4vw, 2.5rem) 1.5rem;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    gap: 2px;
  }
  .sw-nav__links.open { display: flex; }

  .sw-nav__link {
    width: 100%;
    padding: 0.6rem 0;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(163,0,0,0.06);
  }
  .sw-nav__sep { display: none; }

  /* Auth panel */
  .sw-auth-panel {
    clip-path: none;
    border-radius: 4px;
    margin: 0 0.5rem;
  }
  .sw-auth-body { padding: 1.5rem; }

  /* Grids */
  .dash-layout, .admin-layout { grid-template-columns: 1fr !important; }
  .form-row { grid-template-columns: 1fr !important; }

  /* Tabs en admin — scroll horizontal */
  .tac-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .tac-tab { white-space: nowrap; flex-shrink: 0; }

  /* HUD corners */
  .hud-corner { display: none; }

  /* Chat grid */
  .chat-grid { grid-template-columns: 1fr !important; }
}

/* Extra small */
@media (max-width: 420px) {
  .sw-nav__inner { height: 56px; }
  .sw-nav__links { top: 56px; }

  .sw-btn { font-size: 0.7rem; padding: 0.55rem 1rem; }
  .sw-btn--sm { padding: 0.4rem 0.8rem; font-size: 0.62rem; }
}

/* Light mode: ajustes de contraste */
:root.light-mode .sw-nav.scrolled { background: var(--sw-nav-bg); }
:root.light-mode .sw-nav__link { color: var(--sw-text-muted); }
:root.light-mode .sw-scanlines { opacity: 0.3; }
:root.light-mode .noise-overlay { opacity: 0.015; }
:root.light-mode .sw-btn--ghost { color: var(--sw-white); border-color: var(--sw-border); }
:root.light-mode .sw-btn--ghost:hover { color: var(--sw-red); }

/* Nav Logo Scroll Animation */
.sw-nav:not(.scrolled) .nav-logo { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.sw-nav.scrolled .nav-logo { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* Pegar footer al fondo */
.sw-footer { margin-top: auto; }

/* Chat Desplegable en Responsive */
.chat-mobile-icon { display: none; transition: transform 0.3s; }
.chat-mobile-icon.open { transform: rotate(180deg); }
@media (max-width: 900px) {
  .chat-mobile-icon { display: block; }
  .chat-mobile-content { display: none !important; }
  .chat-mobile-content.open { display: grid !important; }
}

/* ═══════════════════════════════════════════
   ACCESIBILIDAD — FOCUS VISIBLE & CONTRASTE (WCAG 2.1 AA)
═══════════════════════════════════════════ */
:focus-visible {
  outline: 3px solid #00d4ff !important;
  outline-offset: 2px !important;
}
.sw-btn:focus-visible, .tac-input:focus-visible, .tac-tab:focus-visible, .sw-sidebar__link:focus-visible {
  outline: 3px solid #00d4ff !important;
  outline-offset: 2px !important;
}

/* ═══════════════════════════════════════════
   ADMIN LAYOUT MODERNO CON SIDEBAR (ERGONÓMICO)
═══════════════════════════════════════════ */
.sw-admin-wrapper {
  display: flex;
  min-height: calc(100vh - 64px);
  margin-top: 64px;
  background: var(--sw-black);
}

.sw-sidebar {
  width: 260px;
  background: var(--sw-dark);
  border-right: 1px solid var(--sw-border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
  transition: transform 0.3s ease, width 0.3s ease;
  z-index: 900;
}

.sw-sidebar__header {
  font-family: var(--sw-font-m);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--sw-text-muted);
  text-transform: uppercase;
  margin-bottom: 0.8rem;
  padding-left: 0.75rem;
}

.sw-sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 0.9rem;
  font-family: var(--sw-font-b);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--sw-white);
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.sw-sidebar__link:hover {
  background: rgba(163, 0, 0, 0.08);
  border-color: var(--sw-border);
  color: var(--sw-red);
}

.sw-sidebar__link.active {
  background: var(--sw-red);
  border-color: var(--sw-red);
  color: #F5F5F5;
  font-weight: 600;
  box-shadow: 0 0 15px var(--sw-red-glow);
}

.sw-sidebar__icon {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
}

.sw-sidebar__footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--sw-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sw-main-area {
  flex: 1;
  min-width: 0;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════
   KPI CARDS & METRICS BAR
═══════════════════════════════════════════ */
.sw-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.15rem;
  margin-bottom: 1.75rem;
}

.sw-kpi-card {
  background: var(--sw-dark);
  border: 1px solid var(--sw-border);
  padding: 1.2rem 1.4rem;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  position: relative;
  transition: border-color 0.2s, transform 0.2s;
}
.sw-kpi-card:hover {
  border-color: var(--sw-red);
  transform: translateY(-2px);
}

.sw-kpi-title {
  font-family: var(--sw-font-m);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--sw-text-muted);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.sw-kpi-val {
  font-family: var(--sw-font-h);
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--sw-white);
  line-height: 1;
}

.sw-kpi-sub {
  font-family: var(--sw-font-b);
  font-size: 0.72rem;
  color: #22c55e;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ═══════════════════════════════════════════
   ACCESSIBLE & ERGONOMIC TABLES
═══════════════════════════════════════════ */
.tac-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sw-font-b);
  font-size: 0.88rem;
}

.tac-table th {
  font-family: var(--sw-font-m);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  color: var(--sw-red);
  text-transform: uppercase;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--sw-border);
  background: rgba(163, 0, 0, 0.05);
}

.tac-table td {
  padding: 0.85rem 1rem;
  color: var(--sw-white);
  border-bottom: 1px solid rgba(163, 0, 0, 0.1);
  vertical-align: middle;
  line-height: 1.4;
}

.tac-table tr:hover td {
  background: rgba(163, 0, 0, 0.06);
}

.sw-section-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--sw-border);
}

.sw-section-title {
  font-family: var(--sw-font-h);
  font-size: 1.45rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sw-white);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Responsive Sidebar Drawer on Mobile / Tablet */
@media (max-width: 900px) {
  .sw-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    width: 270px;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
  }
  .sw-sidebar.open {
    transform: translateX(0);
  }
  .sw-sidebar-toggle {
    display: inline-flex !important;
  }
}
@media (min-width: 901px) {
  .sw-sidebar-toggle {
    display: none !important;
  }
}
