/* ── Theme ────────────────────────────────────────────────────────────── */
body { background: #f5f7fa; }
h2, h5, h6 { font-weight: 600; color: #1a1a2e; }

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 220px;
  height: 100vh;
  background: #fff;
  border-right: 1px solid #dee2e6;
  padding: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1a2e;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid #dee2e6;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.25rem;
  color: #495057;
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 0 24px 24px 0;
  margin-right: 1rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: #f8f9fa; color: #1a1a2e; }
.sidebar-link.active { background: #e8f0fe; color: #0d47a1; font-weight: 600; }
.sidebar-link i { font-size: 1rem; }

/* ── Main content ─────────────────────────────────────────────────────── */
.main-content {
  margin-left: 220px;
  padding: 1.5rem;
  min-height: 100vh;
}

/* ── Cards ────────────────────────────────────────────────────────────── */
.card { border: none; box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ── KPI cards ────────────────────────────────────────────────────────── */
.kpi-card .card-title { font-size: 2rem; font-weight: 700; margin-bottom: 2px; }
.kpi-card .card-text  { font-size: 0.82rem; color: #6c757d; }
.kpi-yoy              { font-size: 0.78rem; font-weight: 600; margin-top: 3px; }
.kpi-yoy.up     { color: #198754; }
.kpi-yoy.down   { color: #dc3545; }
.kpi-yoy.flat   { color: #6c757d; }
.kpi-border-blue   { border-top: 3px solid #0d6efd !important; }
.kpi-border-green  { border-top: 3px solid #198754 !important; }
.kpi-border-purple { border-top: 3px solid #6f42c1 !important; }
.kpi-border-orange { border-top: 3px solid #fd7e14 !important; }

/* ── Charts ───────────────────────────────────────────────────────────── */
.chart-container { position: relative; height: 300px; }

/* ── Detail panels ────────────────────────────────────────────────────── */
.detail-panel { min-height: 280px; }
.detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 220px;
  color: #adb5bd;
  font-size: 0.85rem;
  gap: 0.5rem;
}
.detail-empty i { font-size: 2rem; }

/* ── Score colors ─────────────────────────────────────────────────────── */
.score-high   { color: #198754; font-weight: 600; }
.score-medium { color: #fd7e14; font-weight: 600; }
.score-low    { color: #dc3545; font-weight: 600; }

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.nav-tabs { border-bottom: 2px solid #dee2e6; margin-bottom: 1rem; }
.nav-tabs .nav-link { color: #6c757d; border: none; padding: 0.5rem 1rem; }
.nav-tabs .nav-link.active { color: #0d47a1; border-bottom: 2px solid #0d47a1;
  margin-bottom: -2px; font-weight: 600; background: none; }
.tab-content > .tab-pane { display: none; }
.tab-content > .tab-pane.active { display: block; }

/* ── Filter bar ───────────────────────────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin-bottom: 1rem; }
.filter-bar label { font-size: 0.8rem; color: #6c757d; margin-bottom: 0; }

/* ── Mobile responsive (≤768px) ──────────────────────────────────────── */
@media (max-width: 768px) {

  /* Ocultar sidebar lateral */
  .sidebar {
    display: none;
  }

  /* Contenido ocupa pantalla completa */
  .main-content {
    margin-left: 0;
    padding: 1rem 0.75rem 80px; /* padding-bottom para bottom nav */
  }

  /* Bottom navigation bar */
  body::after {
    content: '';
    display: block;
    height: 64px;
  }

  .sidebar-nav-mobile {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: #fff;
    border-top: 1px solid #dee2e6;
    z-index: 200;
    justify-content: space-around;
    align-items: center;
    padding: 0 0.5rem;
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
  }

  .sidebar-nav-mobile a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: #6c757d;
    text-decoration: none;
    font-size: 0.62rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
    min-width: 60px;
  }

  .sidebar-nav-mobile a i {
    font-size: 1.3rem;
  }

  .sidebar-nav-mobile a.active {
    color: #0d47a1;
    background: #e8f0fe;
  }

  /* KPI cards: números más pequeños para que no se partan */
  .kpi-card .card-title {
    font-size: 1.4rem;
  }

  /* Gráficas más cortas en mobile */
  .chart-container {
    height: 220px;
  }

  /* Tablas con scroll horizontal */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Título de página más compacto */
  h2 { font-size: 1.2rem; }
  h5 { font-size: 0.95rem; }

  /* Filter bar vertical en mobile */
  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .filter-bar select {
    width: 100%;
  }
}

/* Bottom nav oculto en desktop */
.sidebar-nav-mobile {
  display: none;
}

/* ── Loading states ──────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #e9ecef 25%, #f8f9fa 50%, #e9ecef 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.4s ease infinite;
  border-radius: 4px;
  display: inline-block;
}
@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.chart-loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.82);
  z-index: 10;
  border-radius: 4px;
}
.chart-loading-overlay::after {
  content: '';
  width: 28px; height: 28px;
  border: 3px solid #dee2e6;
  border-top-color: #0d6efd;
  border-radius: 50%;
  animation: chart-spin 0.7s linear infinite;
}
@keyframes chart-spin { to { transform: rotate(360deg); } }

/* ── Filter feedback ─────────────────────────────────────────────────── */
.charts-updating {
  opacity: 0.45;
  transition: opacity 0.1s ease;
  pointer-events: none;
}

/* ── Jerarquía visual ────────────────────────────────────────────────── */
.card-primary {
  border-top: 2px solid #0d6efd !important;
}
.card-secondary {
  box-shadow: 0 1px 2px rgba(0,0,0,.05) !important;
}

/* ── Affordance de tabla ─────────────────────────────────────────────── */
.row-chevron { color: #dee2e6; transition: color 0.15s; }
tr:hover .row-chevron { color: #0d47a1; }

/* ── KPI skeleton ────────────────────────────────────────────────────── */
.kpi-skeleton { width: 80px; height: 2rem; margin-bottom: 2px; }
