/* ==========================================================================
   BranchOps · base.css
   Paleta navy/teal/blue — layout, responsive (desktop / tablet / mobile)
   ========================================================================== */

/* ── Google Fonts ─────────────────────────────────────────────────────────  */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&display=swap');

/* ── Variables de paleta ─────────────────────────────────────────────────── */
:root {
  /* Fondos */
  --bg:         #080f20;          /* fondo body principal */
  --bg2:        #0a1427;          /* fondo alternativo suave */
  --surface:    #0d1a35;          /* cards / paneles */
  --surface2:   #0f2040;          /* cards elevadas / hover */

  /* Marca */
  --hdr:        #0a1830;          /* sidebar background */
  --hdr2:       #0d2040;          /* sidebar hover / variante */
  --accent:     #00c2a8;          /* teal principal */
  --accent2:    #2f9bda;          /* azul secundario */
  --accent-bg:  rgba(0,194,168,0.10);
  --accent-bg2: rgba(47,155,218,0.10);

  /* Bordes */
  --border:     rgba(0,194,168,0.15);
  --border2:    rgba(255,255,255,0.07);

  /* Texto */
  --text:       #e8f4f8;           /* texto principal */
  --text2:      rgba(232,244,248,0.75);
  --text3:      rgba(232,244,248,0.45);

  /* Colores de razones sociales (se pueden personalizar) */
  --c-burger:   #00c2a8;
  --c-cool:     #2f9bda;
  --c-dean:     #7c5cfc;
  --c-green:    #f59e0b;

  /* Semáforo */
  --up:         #34d399;
  --dn:         #f87171;
  --warn:       #fbbf24;

  /* Layout */
  --sidebar-w:    224px;
  --topbar-h:     56px;
  --bottomnav-h:  0px;

  /* Tipografía */
  --font:      'DM Sans', 'General Sans', system-ui, sans-serif;
  --font-head: 'Syne', 'General Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Efectos */
  --radius:     10px;
  --radius-lg:  14px;
  --shadow:     0 4px 24px rgba(0,0,0,0.35);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.5);
  --glow-teal:  0 0 20px rgba(0,194,168,0.25);
  --glow-blue:  0 0 20px rgba(47,155,218,0.2);
}

/* ── General Sans — fuente local (fallback si no carga Google Fonts) ──────── */
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Regular.otf') format('opentype'); font-weight:400; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Italic.otf') format('opentype'); font-weight:400; font-style:italic; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Light.otf') format('opentype'); font-weight:300; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-LightItalic.otf') format('opentype'); font-weight:300; font-style:italic; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Medium.otf') format('opentype'); font-weight:500; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-MediumItalic.otf') format('opentype'); font-weight:500; font-style:italic; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Semibold.otf') format('opentype'); font-weight:600; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-SemiboldItalic.otf') format('opentype'); font-weight:600; font-style:italic; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Bold.otf') format('opentype'); font-weight:700; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-BoldItalic.otf') format('opentype'); font-weight:700; font-style:italic; }

/* ── Reset mínimo ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  /* Subtle grid overlay */
  background-image:
    linear-gradient(rgba(0,194,168,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,194,168,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--hdr);
  background-image: linear-gradient(180deg, #0a1830 0%, #07112a 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
  transition: transform 0.25s ease, width 0.2s ease;
}

/* Logo area */
.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-box {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--glow-teal);
}

/* SVG logo inline en el logo-box */
.logo-box svg { width: 18px; height: 18px; }

.logo-text {
  font-family: var(--font-head);
  font-weight: 700; font-size: 13px;
  color: #fff;
  line-height: 1.25;
  overflow: hidden;
  letter-spacing: -0.2px;
}
.logo-text .ops-color { color: var(--accent); }
.logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  font-weight: 400;
  font-family: var(--font);
}
.sidebar-close { display: none; color: rgba(255,255,255,0.5); margin-left: auto; padding: 4px; }

/* Nav items */
.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(0,194,168,0.3); }

.nav-section-label {
  padding: 14px 16px 4px;
  font-size: 10px; font-weight: 600;
  color: rgba(255,255,255,0.28);
  letter-spacing: 0.1em; text-transform: uppercase;
  font-family: var(--font);
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; margin: 1px 8px;
  border-radius: 8px;
  font-size: 13px; color: rgba(255,255,255,0.6);
  transition: background 0.14s, color 0.14s;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover {
  background: rgba(0,194,168,0.1);
  color: rgba(255,255,255,0.9);
}
.nav-item.active {
  background: rgba(0,194,168,0.18);
  color: var(--accent);
  font-weight: 600;
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}
.nav-ico { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }
.nav-item.active .nav-ico { opacity: 1; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }

/* Razones sociales */
.sidebar-razones {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.razones-label {
  font-size: 10px; font-weight: 600;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.razon-item {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0; font-size: 11px;
  color: rgba(255,255,255,0.5);
}
.razon-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 190;
  backdrop-filter: blur(2px);
}

/* ==========================================================================
   MAIN WRAPPER
   ========================================================================== */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: var(--bottomnav-h);
}

/* TOPBAR */
.topbar {
  height: var(--topbar-h);
  background: rgba(13,26,53,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky; top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.hamburger {
  display: none;
  flex-direction: column; gap: 4px;
  padding: 6px; border-radius: 6px;
  flex-shrink: 0;
}
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: var(--accent); border-radius: 1px;
}
.hamburger:hover { background: var(--accent-bg); }

/* Botón de menú toggle (alternativa) */
.menu-toggle {
  display: none;
  padding: 6px;
  border-radius: 6px;
  color: var(--accent);
  transition: background 0.12s;
  flex-shrink: 0;
}
.menu-toggle:hover { background: var(--accent-bg); }

.topbar-title {
  font-family: var(--font-head);
  font-weight: 700; font-size: 15px;
  color: var(--text); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.2px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.btn-upload {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 8px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--border);
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}
.btn-upload:hover {
  background: var(--accent);
  color: #000;
  box-shadow: var(--glow-teal);
}

.cc-toggle {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3); font-size: 11px; font-weight: 500;
  font-family: var(--font); cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.cc-toggle:hover  { border-color: var(--accent); color: var(--accent); }
.cc-toggle.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.cc-label { font-size: 11px; }
@media (max-width: 767px) { .cc-label { display: none; } }

.topbar-rol-badge {
  font-size: 11px; font-weight: 600;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* ==========================================================================
   PAGE CONTENT
   ========================================================================== */
.page-content {
  padding: 20px;
  flex: 1;
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kpi-card:hover {
  border-color: rgba(0,194,168,0.3);
  transform: translateY(-2px);
}

.kpi-label  { font-size: 11px; color: var(--text3); font-weight: 500; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value  { font-family: var(--font-head); font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -1px; }
.kpi-delta  { font-size: 12px; margin-top: 6px; }
.delta-up   { color: var(--up); }
.delta-dn   { color: var(--dn); }
.kpi-sub    { font-size: 10px; color: var(--text3); margin-top: 4px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: border-color 0.2s;
}
.card:hover { border-color: rgba(0,194,168,0.25); }

.card-title {
  font-family: var(--font-head);
  font-size: 13px; font-weight: 700; color: var(--text);
  margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between;
  letter-spacing: -0.2px;
}
.card-link { font-size: 11px; color: var(--accent); font-weight: 500; font-family: var(--font); }
.card-link:hover { color: var(--accent2); }

/* Filter bar */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { height: 3px; }
.filter-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.filter-label { font-size: 12px; color: var(--text3); font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.filter-btn {
  padding: 5px 12px; border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent; font-size: 12px; color: var(--text3);
  white-space: nowrap; flex-shrink: 0;
  font-family: var(--font);
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.filter-btn:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }

/* Badges / pills */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.3px;
}
.pill-up   { background: rgba(52,211,153,0.15); color: var(--up); }
.pill-dn   { background: rgba(248,113,113,0.15); color: var(--dn); }
.pill-warn { background: rgba(251,191,36,0.15);  color: var(--warn); }
.pill-info { background: rgba(47,155,218,0.15);  color: var(--accent2); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; color: var(--text3); font-size: 11px; font-weight: 600;
  padding: 0 12px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap; text-transform: uppercase; letter-spacing: 0.5px;
}
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border2); color: var(--text2);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(0,194,168,0.05); }

/* Buttons */
.btn-primary {
  padding: 8px 18px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 13px; font-weight: 600; font-family: var(--font);
  transition: opacity 0.14s, transform 0.14s, box-shadow 0.14s;
  box-shadow: 0 4px 14px rgba(0,194,168,0.25);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,194,168,0.35); }

.btn-secondary {
  padding: 8px 16px; border-radius: 8px;
  background: transparent; color: var(--text2);
  border: 1px solid var(--border);
  font-size: 13px; font-family: var(--font);
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.btn-secondary:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

.btn-danger {
  padding: 6px 14px; border-radius: 7px;
  background: rgba(248,113,113,0.1); color: var(--dn);
  border: 1px solid rgba(248,113,113,0.25);
  font-size: 12px; font-family: var(--font);
  transition: background 0.14s;
}
.btn-danger:hover { background: rgba(248,113,113,0.2); }

/* Forms */
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 5px; }
.form-input, .form-select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: var(--font); color: var(--text);
  background: var(--surface2);
  transition: border-color 0.14s, box-shadow 0.14s;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,194,168,0.12);
}
.form-file {
  width: 100%; padding: 8px;
  border: 1px dashed var(--border); border-radius: 8px;
  font-size: 12px; color: var(--text3);
  background: var(--accent-bg);
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 440px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { font-family: var(--font-head); font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
.modal-close { font-size: 20px; color: var(--text3); padding: 2px 6px; transition: color 0.12s; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 16px 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.upload-msg   { margin-top: 10px; font-size: 12px; padding: 8px 12px; border-radius: 8px; }
.upload-msg.ok  { background: rgba(52,211,153,0.12); color: var(--up); border: 1px solid rgba(52,211,153,0.2); }
.upload-msg.err { background: rgba(248,113,113,0.12); color: var(--dn); border: 1px solid rgba(248,113,113,0.2); }

/* Bottom nav — hidden by default */
.bottom-nav { display: none; }

/* ==========================================================================
   RESPONSIVE — TABLET  (768px – 1023px)
   ========================================================================== */
@media (max-width: 1023px) {
  :root { --sidebar-w: 52px; }

  .nav-label,
  .nav-section-label,
  .logo-text,
  .sidebar-razones { display: none; }

  .nav-item { justify-content: center; padding: 10px; margin: 2px 6px; }
  .nav-item.active { border-left: none; padding-left: 10px; border-bottom: 2px solid var(--accent); }
  .nav-ico  { opacity: 1; }

  .sidebar-logo { justify-content: center; padding: 0; }
  .logo-box { width: 30px; height: 30px; }

  .hamburger, .menu-toggle { display: flex; }

  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }

  .btn-upload .btn-label { display: none; }
  .btn-upload { padding: 6px 8px; }
}

/* ==========================================================================
   RESPONSIVE — MOBILE  (<768px)
   ========================================================================== */
@media (max-width: 767px) {
  :root {
    --sidebar-w:    270px;
    --bottomnav-h:  60px;
  }

  body { background-image: none; }

  /* Sidebar se convierte en drawer lateral */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    height: 100%;
    z-index: 200;
    box-shadow: 6px 0 30px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }

  /* En mobile el sidebar muestra etiquetas completas */
  .nav-label,
  .nav-section-label,
  .logo-text,
  .sidebar-razones { display: revert; }
  .nav-item { justify-content: flex-start; padding: 8px 12px; margin: 1px 8px; }
  .nav-item.active { border-left: 2px solid var(--accent); padding-left: 10px; border-bottom: none; }
  .sidebar-logo { justify-content: flex-start; padding: 0 16px; }
  .logo-box { width: 32px; height: 32px; }
  .sidebar-close { display: flex; }

  /* Topbar */
  .hamburger, .menu-toggle { display: flex; }
  .topbar-rol-badge { display: none; }
  .topbar { padding: 0 14px; }

  /* KPIs */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .kpi-value { font-size: 22px; }

  /* Content */
  .page-content { padding: 14px; }

  /* Bottom nav */
  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 150;
    align-items: stretch;
  }
  .bn-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px;
    font-size: 10px; color: var(--text3);
    background: none; border: none;
    font-family: var(--font);
    padding: 0;
    transition: color 0.14s;
  }
  .bn-item.active, .bn-item:hover { color: var(--accent); }

  /* Tables scroll horizontal */
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
}

/* ==========================================================================
   PANTALLAS MUY PEQUEÑAS  (<380px)
   ========================================================================== */
@media (max-width: 379px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 20px; }
}

/* ==========================================================================
   UTILIDADES EXTRA BranchOps
   ========================================================================== */

/* Gradiente de texto */
.text-gradient {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Glow badge */
.badge-teal {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-bg); color: var(--accent);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 3px 10px; font-size: 11px; font-weight: 600;
}
.badge-blue {
  background: var(--accent-bg2); color: var(--accent2);
  border-color: rgba(47,155,218,0.2);
}
.badge-warn {
  background: rgba(251,191,36,0.12); color: var(--warn);
  border-color: rgba(251,191,36,0.2);
}
.badge-danger {
  background: rgba(248,113,113,0.12); color: var(--dn);
  border-color: rgba(248,113,113,0.2);
}

/* Separador con degradado */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 16px 0;
}

/* Scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,194,168,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,194,168,0.4); }
