/* ═══════════════════════════════════════════════════════════════════
   MIIA Design System v4 - fuente unica de diseno cross-proyecto
   ═══════════════════════════════════════════════════════════════════
   IMPORTABLE DESDE:
     - miia-frontend/owner-dashboard.html (y resto de paginas frontend)
     - miia-frontend/admin-dashboard.html, login.html, index.html, etc.
     - JUEGA MIIA/MIIADT (paneles fantasy ARQ)
     - JUEGA MIIA/LUDOMIIA (web Next.js TEC) via CSS modules o global
   USO HTML:
     <link rel="stylesheet" href="/assets/v2-design-system.css">
   USO Next.js / React:
     import 'miia-frontend/assets/v2-design-system.css';
     o copia el archivo a tu /public/ y referencia.
   CONTIENE:
     - Tokens (paleta, radii, transition, sombras, fonts)
     - Themes light/dark via [data-theme]
     - Reset universal
     - Layout base (.miia-app, .miia-body, .miia-main, .miia-section)
     - Componentes core: .btn (primary/secondary/sm), .input, .card,
       .section-header/title/subtitle, .toast, .badge, .modal, .table,
       .stat-card, .empty-state, .tooltip
     - Sidebar colapsable: .miia-sidebar + .sidebar-grp/-item/mobile drawer
     - WhatsApp widget (.wa-widget) y badges (.wa-badge, .wa-dot)
   NO CONTIENE (especifico por proyecto):
     - Layouts de seccion del owner-dashboard (timeline, hero, gestionar tabs,
       wizard onboarding, F1 dashboard, feed lateral, nav-bottom)
     - Componentes MIIADT fantasy (los define ARQ encima de este sistema)
     - Componentes LudoMIIA (los define TEC encima)
   PALETA OFICIAL:
     gradient: #00E5FF -> #7C3AED -> #FF1744
     verde:    #22c55e   rojo:     #ef4444   ambar:    #f59e0b
   FIRMA: 2026-05-02 - Vi (Tecnica MIIA) - F4.0 PASO 4 orden Wi unificado #275
   Aprobado: Mariano firma viva 2026-05-02 ~10:25 COT
   ═══════════════════════════════════════════════════════════════════ */

/* === TOKENS_THEMES === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Shared tokens ── */
:root {
  --miia-gradient: linear-gradient(135deg, #00E5FF 0%, #7C3AED 50%, #FF1744 100%);
  --miia-cyan:   #00E5FF;
  --miia-violet: #7C3AED;
  --miia-rose:   #FF1744;

  --green-500:  #22c55e;
  --red-500:    #ef4444;
  --amber-500:  #f59e0b;

  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-full: 9999px;

  --transition: 200ms ease;
}

/* ── DARK THEME (default) ── */
[data-theme="dark"], :root:not([data-theme]) {
  --bg-primary:   #05050A;
  --bg-card:      #0A0A12;
  --bg-elevated:  #0F0F1A;
  --bg-hover:     #151520;
  --border:       rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text-1:       #FFFFFF;
  --text-2:       rgba(255, 255, 255, 0.55);
  --text-3:       rgba(255, 255, 255, 0.22);
  --accent:       #00E5FF;
  --accent-bg:    rgba(0, 229, 255, 0.08);
  --overlay:      rgba(5, 5, 10, 0.85);
  --shadow-card:  0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg:    0 8px 32px rgba(0, 0, 0, 0.6);
  --nav-active:   #FFFFFF;
  --nav-inactive: rgba(255, 255, 255, 0.55);
  --nav-border:   rgba(255, 255, 255, 0.15);
  --toggle-bg:    #1a1a28;
  --toggle-active:#0F0F1A;
  --feed-miia-bg: rgba(0, 229, 255, 0.06);
}

/* ── LIGHT THEME ── */
[data-theme="light"] {
  --bg-primary:   #F5F5F7;
  --bg-card:      #FFFFFF;
  --bg-elevated:  #ECECF0;
  --bg-hover:     #E2E2E8;
  --border:       rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.20);
  --text-1:       #111111;
  --text-2:       rgba(0, 0, 0, 0.60);
  --text-3:       rgba(0, 0, 0, 0.32);
  --accent:       #008FA8;
  --accent-bg:    rgba(0, 143, 168, 0.08);
  --overlay:      rgba(0, 0, 0, 0.5);
  --shadow-card:  0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-lg:    0 4px 16px rgba(0, 0, 0, 0.15);
  --nav-active:   #111111;
  --nav-inactive: rgba(0, 0, 0, 0.60);
  --nav-border:   rgba(0, 0, 0, 0.20);
  --toggle-bg:    #E0E0E8;
  --toggle-active:#FFFFFF;
  --feed-miia-bg: rgba(0, 143, 168, 0.06);
}



/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-1);
  background: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }



/* === LAYOUT_BASE === */
/* ═══ LAYOUT ═══ */
.miia-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.miia-body {
  display: flex;
  flex: 1;
  padding-top: 60px; /* nav height */
}

.miia-main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}



/* === SECTIONS === */
/* ═══ SECTIONS ═══ */
.miia-section { display: none; }
.miia-section.active { display: block; }



/* === CARDS_GENERIC === */
/* ═══ CARDS (generic) ═══ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  transition: border-color var(--transition);
}

.card:hover { border-color: var(--border-hover); }

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 16px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 12px;
}



/* === BUTTONS === */
/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--miia-gradient);
  color: #FFFFFF;
  border: none;
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--text-1);
  border: 1px solid var(--nav-border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: var(--text-1);
  background: var(--bg-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}



/* === TOOLTIP === */
/* ═══ TOOLTIP SYSTEM ═══ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease;
  z-index: 9999;
  box-shadow: var(--shadow-card);
  max-width: 240px;
  white-space: normal;
  text-align: center;
  line-height: 1.4;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* Tooltip arriba para nav-bottom */
[data-tooltip-pos="top"]::after {
  top: auto;
  bottom: calc(100% + 8px);
}



/* === SECTION_HEADERS === */
/* ═══ SECTION HEADERS ═══ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-1);
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}



/* === TABLES === */
/* ═══ TABLES ═══ */
.miia-table {
  width: 100%;
  border-collapse: collapse;
}

.miia-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}

.miia-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}

.miia-table tr:hover td {
  background: var(--bg-hover);
  color: var(--text-1);
}



/* === FORMS === */
/* ═══ FORMS ═══ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-1);
  font-size: 14px;
  transition: border-color var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-input::placeholder { color: var(--text-3); }



/* === BADGES === */
/* ═══ BADGES ═══ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-green {
  background: rgba(34, 197, 94, 0.12);
  color: var(--green-500);
}

.badge-red {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red-500);
}

.badge-amber {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber-500);
}



/* === MODALS === */
/* ═══ MODALS ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 8px;
}

.modal-text {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}



/* === TOAST === */
/* ═══ TOAST ═══ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-1);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: all 300ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}



/* === SCROLLBAR === */
/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }



/* === UTILITY === */
/* ═══ UTILITY ═══ */
.hidden { display: none !important; }
.text-gradient {
  background: var(--miia-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }



/* === THEME_WA_AVATAR === */
.theme-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: all var(--transition);
  border: 1px solid transparent;
}

.theme-btn:hover {
  color: var(--text-1);
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

/* WA status badge */
.wa-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  transition: all var(--transition);
}

.wa-badge:hover {
  border-color: var(--border-hover);
  color: var(--text-1);
}

.wa-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red-500);
  flex-shrink: 0;
}

.wa-dot.connected {
  background: var(--green-500);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

/* Avatar */
.nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--transition);
}

.nav-avatar:hover { border-color: var(--accent); }


/* === STATS === */
/* ═══ STATS ROW ═══ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--border-hover); }

.stat-number {
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 8px;
  color: var(--text-1);
}

.stat-number.gradient {
  background: var(--miia-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.stat-delta {
  font-size: 11px;
  font-weight: 500;
  margin-top: 4px;
}
.stat-delta.up { color: var(--green-500); }
.stat-delta.down { color: var(--red-500); }



/* === EMPTY_STATE === */
/* ═══ STATE: NO WHATSAPP ═══ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
}

.empty-state-logo {
  opacity: 0.15;
  margin-bottom: 24px;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-2);
  max-width: 360px;
  margin-bottom: 24px;
  line-height: 1.5;
}



/* === SIDEBAR === */
/* ═══════════════════════════════════════════════════════
   SIDEBAR — Layout vertical colapsible (Firebase/VSCode style)
   Construido sobre variables V2: --bg-card, --border, --text-1, --text-2, --accent
   ═══════════════════════════════════════════════════════ */

.miia-body { display: flex; flex: 1; padding-top: 60px; }

.miia-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  z-index: 50;
}

.miia-sidebar.collapsed {
  width: 56px;
}

.miia-sidebar.collapsed .sidebar-grp-hdr,
.miia-sidebar.collapsed .sidebar-label {
  display: none;
}

.miia-sidebar.collapsed .sidebar-item {
  justify-content: center;
  padding: 10px 0;
}

.miia-sidebar.collapsed .sidebar-item .sidebar-icon {
  margin-right: 0;
}

.sidebar-toggle {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: all var(--transition);
}

.sidebar-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar-grp {
  margin-bottom: 8px;
}

.sidebar-grp-hdr {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color var(--transition);
}

.sidebar-grp-hdr:hover { color: var(--text-2); }

.sidebar-grp-hdr::after {
  content: "\25BE";
  font-size: 10px;
  margin-left: 6px;
  transition: transform var(--transition);
  display: inline-block;
}

.sidebar-grp.collapsed .sidebar-grp-hdr::after {
  transform: rotate(-90deg);
}

.sidebar-grp.collapsed .sidebar-grp-items {
  display: none;
}

.sidebar-grp-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border-left: 2px solid transparent;
  transition: all var(--transition);
  text-align: left;
  width: 100%;
}

.sidebar-item:hover {
  color: var(--text-1);
  background: var(--bg-hover);
}

.sidebar-item.active {
  color: var(--accent);
  background: var(--accent-bg);
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-icon {
  width: 16px;
  height: 16px;
  margin-right: 10px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-icon svg { width: 16px; height: 16px; }

/* Main aligned next to sidebar */
.miia-body > .miia-main {
  flex: 1;
  margin: 0;
  max-width: none;
  padding: 32px 40px;
}

/* Mobile: sidebar como drawer */
@media (max-width: 768px) {
  .miia-sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }
  .miia-sidebar.mobile-open {
    transform: translateX(0);
  }
  .miia-sidebar.collapsed { width: 240px; }
  .sidebar-mobile-btn {
    display: inline-flex !important;
  }
  .miia-body > .miia-main {
    padding: 16px 16px;
  }
}

.sidebar-mobile-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  margin-right: 8px;
}




/* === WA_WIDGET === */
/* ─── WIDGET WhatsApp en sec-home (T158) ─────────────────── */
.wa-widget {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  padding: 16px 20px;
  margin: 12px 0 24px;
  box-shadow: 0 0 0 4px var(--accent-bg);
  transition: all var(--transition);
}

.wa-widget.connected {
  border-color: var(--green-500);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.10);
}

.wa-widget-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-widget.connected .wa-widget-icon {
  background: rgba(34, 197, 94, 0.12);
  color: var(--green-500);
}

.wa-widget-body { flex: 1; min-width: 200px; }

.wa-widget-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.wa-widget-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}

.wa-widget-detail {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
}

@media (max-width: 600px) {
  .wa-widget { flex-direction: column; align-items: stretch; text-align: left; }
  .wa-widget .btn { width: 100%; }
}


