/* ══════════════════════════════════════════════════════
   ROCATRANS Fleet Command — Responsive
   Breakpoints: 1200 · 960 · 768 · 480
══════════════════════════════════════════════════════ */


/* ══════════════════════════════
   1200px — Large tablets / small laptops
══════════════════════════════ */
@media (max-width: 1200px) {

  /* Charts pasan a 1 columna */
  .chart-grid-2 {
    grid-template-columns: 1fr;
  }

  /* KPI: 3 columnas fijas */
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .section-inner {
    padding: 24px 22px 40px;
  }

}


/* ══════════════════════════════
   960px — Tablets landscape
══════════════════════════════ */
@media (max-width: 960px) {

  /* KPI: 2 columnas */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Topbar: reducir padding */
  .topbar {
    padding: 0 18px 0 16px;
  }

  /* Breadcrumb: ocultar en pantallas medianas */
  .topbar-breadcrumb {
    display: none;
  }

  /* Sidebar footer: compactar */
  .sidebar-footer {
    padding: 12px 12px 16px;
  }

  .clock-time {
    font-size: 18px;
  }

  .section-inner {
    padding: 20px 18px 36px;
  }

}


/* ══════════════════════════════
   768px — Tablets portrait / Mobile landscape
══════════════════════════════ */
@media (max-width: 768px) {

  /* ── Sidebar off-canvas ── */
  .sidebar {
    transform: translateX(-260px);
    box-shadow: none;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.65);
  }

  /* ── Topbar: full width ── */
  .topbar {
    left: 0;
    padding: 0 16px;
    transition: none;
  }

  /* ── Main: sin margin de sidebar ── */
  .main-content {
    margin-left: 0;
  }

  /* ── Mostrar hamburger ── */
  .topbar-hamburger {
    display: flex;
  }

  /* ── Overlay activo ── */
  .sidebar-overlay.active {
    display: block;
  }

  /* ── Topbar right: ocultar texto de botones, solo iconos ── */
  .topbar-btn span {
    display: none;
  }

  .topbar-btn {
    padding: 0 10px;
    width: 38px;
    justify-content: center;
  }

  .topbar-btn svg {
    opacity: 1;
  }

  /* ── Ocultar avatar en mobile ── */
  .topbar-avatar {
    display: none;
  }

  /* ── Subtitle topbar oculto ── */
  .topbar-subtitle {
    display: none;
  }

  /* ── KPI: 2 columnas en tablet ── */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* ── Título de sección más pequeño ── */
  .topbar-title {
    font-size: 16px;
  }

  /* ── Section inner: menos padding ── */
  .section-inner {
    padding: 18px 16px 32px;
  }

  /* ── Placeholder: menos espacio ── */
  .section-placeholder {
    padding: 32px 20px;
    min-height: calc(100vh - var(--topbar-height) - 40px);
  }

  .placeholder-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
  }

  .placeholder-title {
    font-size: 20px;
  }

  /* ── Section header wrap ── */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* ── Chart card: menos padding ── */
  .chart-card,
  .card {
    padding: 16px;
  }

  /* ── Data table: scroll horizontal ── */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Pills row: scroll ── */
  .pills-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .pills-row::-webkit-scrollbar { display: none; }

  /* ── Bottom Nav: show on mobile ── */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    z-index: 500; /* above main, below sidebar overlay */
    background: rgba(6, 19, 24, 0.96);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    align-items: stretch;
    /* Safe area for iPhone notch / home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
  }

  .bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    padding: 8px 4px 6px;
    position: relative;
    text-decoration: none;
    color: var(--text-muted);
    transition: color var(--transition), transform var(--transition);
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    min-width: 0;
  }

  .bottom-tab:active {
    transform: scale(0.90);
  }

  .bottom-tab.active {
    color: var(--accent);
  }

  .bottom-tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    transition: color var(--transition);
  }

  .bottom-tab-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
  }

  .bottom-tab-label {
    font-family: var(--font-mono);
    font-size: 8.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: center;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    color: inherit;
  }

  /* Active top-bar indicator */
  .bottom-tab-indicator {
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: 0 1px 6px var(--accent-glow);
  }

  /* ── Add padding-bottom to main content for bottom nav ── */
  .main-content {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 8px);
  }

  /* ── Sidebar stays as overlay only, bottom-nav is primary ── */
  .sidebar-nav-label {
    /* Keep sidebar functional but not primary — no changes needed,
       sidebar is already overlay on mobile */
  }

}


/* ══════════════════════════════
   480px — Mobile portrait
══════════════════════════════ */
@media (max-width: 480px) {

  /* ── KPI: 2 columnas compactas ── */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .kpi-card {
    padding: 14px 14px 12px;
  }

  .kpi-value {
    font-size: 22px;
  }

  .kpi-unit {
    font-size: 14px;
  }

  .kpi-icon {
    width: 32px;
    height: 32px;
  }

  /* ── Toasts: full width ── */
  .toast-container {
    right: 12px;
    left: 12px;
    bottom: 16px;
  }

  .toast {
    min-width: unset;
    max-width: 100%;
  }

  /* ── Topbar más compacto ── */
  .topbar {
    padding: 0 12px;
    gap: 10px;
  }

  .topbar-title {
    font-size: 15px;
  }

  .badge-live-topbar {
    display: none;
  }

  /* ── Section inner ── */
  .section-inner {
    padding: 14px 12px 28px;
  }

  /* ── Placeholder más compacto ── */
  .section-placeholder {
    padding: 24px 16px;
  }

  .placeholder-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
  }

  .placeholder-title {
    font-size: 18px;
  }

  .placeholder-desc {
    font-size: 13px;
  }

  /* ── Chart cards: sin gap lateral ── */
  .chart-card,
  .card {
    padding: 14px 12px;
  }

  /* ── Sidebar nav: texto más pequeño ── */
  .nav-item {
    font-size: 13px;
    padding: 9px 10px 9px 11px;
  }

  /* ── Topbar btn: más pequeño ── */
  .topbar-btn {
    width: 34px;
    height: 34px;
    padding: 0 9px;
  }

  /* ── Score bar: más estrecho ── */
  .score-bar {
    width: 48px;
  }

}


/* ══════════════════════════════
   375px — Small phones (iPhone SE etc.)
══════════════════════════════ */
@media (max-width: 375px) {

  /* Section padding mínimo */
  .section-inner {
    padding: 12px 10px 24px;
  }

  /* KPIs: seguir en 2 cols pero más compactos */
  .kpi-grid {
    gap: 8px;
  }

  .kpi-card {
    padding: 12px 10px 10px;
    border-radius: 10px;
  }

  .kpi-value {
    font-size: 20px;
  }

  .kpi-label {
    font-size: 8.5px;
  }

  .kpi-sublabel,
  .kpi-daily {
    display: none; /* ocultar subtexto en pantallas muy pequeñas */
  }

  /* Chart card header: apilar */
  .chart-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* Ocultar filtros de rango en charts pequeños */
  .chart-filters {
    align-self: flex-start;
  }

  /* Topbar: solo lo esencial */
  .topbar-right > *:not(.topbar-hamburger-area) {
    gap: 6px;
  }

  /* Tabla: reducir padding de celdas */
  .conductores-table td,
  .conductores-table th {
    padding: 9px 10px;
    font-size: 11.5px;
  }

  /* Ocultar columnas menos críticas en tabla ← scroll sigue disponible */
  /* No ocultamos — el scroll horizontal cubre */

  /* Dashboard header: apilar */
  .dashboard-header {
    gap: 10px;
  }

  .dashboard-title {
    font-size: 20px;
  }

  /* Mapa: chips más pequeños */
  .map-chip {
    font-size: 9.5px;
    padding: 4px 8px;
  }

  /* Insight cards: menos padding */
  .insight-card {
    padding: 12px 12px 12px 14px;
  }

  .insight-title {
    font-size: 13px;
  }

  /* Chat: reducir */
  .chat-card {
    height: 420px;
  }

  .chat-suggestion {
    font-size: 9.5px;
    padding: 4px 10px;
  }

  /* Vehículos: grid a 1 columna en teléfonos muy pequeños */
  .vehiculos-grid {
    grid-template-columns: 1fr;
  }

  .vehiculos-kpi-card {
    gap: 10px;
    padding: 11px 12px;
  }

}


/* ══════════════════════════════
   BOTTOM NAV — hidden on desktop
══════════════════════════════ */
.bottom-nav {
  display: none; /* hidden everywhere except <768px */
}


/* ══════════════════════════════
   Print styles
══════════════════════════════ */
@media print {
  .sidebar,
  .topbar,
  .toast-container,
  .topbar-btn,
  .sidebar-overlay {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding-top: 0 !important;
  }

  .section-inner {
    padding: 16px !important;
  }

  body {
    background: white !important;
    color: black !important;
  }
}
