/* =============================================================
   responsive.css — AutoTaller Pro
   Breakpoints: 768px (tablet), 480px (móvil)
   ============================================================= */

/* ── TEMA CLARO (alternativa al esquema oscuro por defecto) ──
   Se activa poniendo data-theme="light" en <html> (ver theme.js).
   Sobreescribe las mismas variables que ya usa cada página, así
   que no hay que tocar el resto del CSS. */
html[data-theme="light"] {
  --bg:#f4f5f7; --bg2:#ffffff; --bg3:#eceef2;
  --line:rgba(15,18,24,0.10); --line2:rgba(15,18,24,0.16);
  --text:#1a1d24; --muted:#5b6373;
}
html[data-theme="light"] .sidebar-logo span,
html[data-theme="light"] .nav-item:hover { color:#1a1d24; }
html[data-theme="light"] .tuercas-chip,
html[data-theme="light"] .nav-item.active { background:rgba(240,180,41,.14); }

/* ── BOTÓN FLOTANTE DE CAMBIO DE TEMA (inyectado por theme.js) ── */
.theme-toggle-btn {
  position: fixed; right: 16px; bottom: 16px; z-index: 200;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line2); background: var(--bg2); color: var(--text);
  font-size: 20px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
@media (max-width: 768px) {
  .theme-toggle-btn { bottom: 78px; }
}

/* ── ÍCONOS DEL MENÚ más grandes y visibles (todas las pantallas) ── */
.nav-item > span:first-child,
.nav-item > .nav-icon {
  font-size: 19px;
  width: 26px;
  text-align: center;
  line-height: 1;
}

/* ── BARRA INFERIOR DE NAVEGACIÓN (estilo app, solo móvil) ── */
.mobnav { display: none; }
@media (max-width: 768px) {
  .mobnav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 150;
    background: var(--bg2);
    border-top: 1px solid var(--line2);
    justify-content: space-around;
    align-items: stretch;
    padding: 6px 2px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(0,0,0,.35);
  }
  .mobnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--muted);
    text-decoration: none;
    font-family: var(--display);
    font-size: 10.5px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 0;
  }
  .mobnav-ico { font-size: 24px; line-height: 1; }
  .mobnav-item.active { color: var(--accent); }
  .mobnav-item.active .mobnav-ico { transform: translateY(-1px); }
  /* Respuesta al tocar (se siente reactivo) */
  .mobnav-item:active { background: rgba(240,180,41,.12); border-radius: 10px; }
  .mobnav-item:active .mobnav-ico { transform: scale(.88); }
  .mobnav-ico { transition: transform .12s; }
  /* Espacio para que el contenido no quede tapado por la barra */
  .has-mobnav .main { padding-bottom: 76px; }
}

/* ── HAMBURGER BUTTON (solo visible en móvil) ─────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 6px;
  background: none;
  border: none;
  z-index: 201;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all .25s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── OVERLAY para cerrar el sidebar en móvil ─────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 199;
}
.sidebar-overlay.active { display: block; }

/* ══════════════════════════════════════════════════════════
   TABLET  ≤ 1024px
══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .stats-grid                           { grid-template-columns: repeat(2, 1fr); }
  .form-grid.col4                       { grid-template-columns: repeat(2, 1fr); }
  .hero-stats                           { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════════════════
   MÓVIL  ≤ 768px
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Layout principal */
  .shell { grid-template-columns: 1fr; }

  /* Sidebar se convierte en drawer lateral */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar { width: 280px; }

  /* Ítems del menú más grandes y fáciles de tocar en el celular */
  .nav-item { padding: 14px 22px; font-size: 15px; gap: 14px; }
  .nav-item > span:first-child,
  .nav-item > .nav-icon { font-size: 24px; width: 30px; }
  .sidebar-logo h1 { font-size: 19px; }

  /* Topbar con hamburguesa */
  .topbar { padding: 14px 16px; gap: 10px; }
  .topbar-title { font-size: 16px; }
  .hamburger { display: flex; }

  /* Contenido principal */
  .view { padding: 16px; }
  .main { padding-bottom: 24px; }

  /* Grids → columna única */
  .stats-grid                           { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .form-grid, .form-grid.col2,
  .form-grid.col4                       { grid-template-columns: 1fr; gap: 12px; }
  .field-full                           { grid-column: 1; }
  .hero-stats                           { grid-template-columns: repeat(2, 1fr); }

  /* Reportes: KPIs y resúmenes en 2 columnas; gráficos apilados */
  .kpi-grid, .resumen-grid              { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .charts-grid, .charts-grid-3          { grid-template-columns: 1fr !important; }
  .chart-wrap, .chart-card canvas       { max-width: 100% !important; }
  /* Pestañas de reportes desplazables si no caben */
  .tabs-bar                             { padding: 12px 16px 0 !important; }
  .tabs                                 { width: auto !important; max-width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab                                  { white-space: nowrap; flex-shrink: 0; }
  .contactos-grid                       { grid-template-columns: 1fr; }
  .photo-grid                           { grid-template-columns: repeat(2, 1fr); }

  /* Tablas dentro de .table-wrap → TARJETAS apiladas (caben en móvil) */
  .table-wrap { overflow: visible; }
  .table-wrap table { min-width: 0; width: 100%; display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tbody { display: block; }
  .table-wrap tbody tr {
    display: block;
    border: 1px solid var(--line2);
    border-radius: 12px;
    background: var(--bg2);
    margin: 0 0 10px;
    padding: 6px 14px;
  }
  .table-wrap tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid var(--line);
    text-align: right;
    font-size: 13px;
    min-width: 0;
  }
  .table-wrap tbody tr td:last-child { border-bottom: none; }
  .table-wrap tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-align: left;
    flex-shrink: 0;
    white-space: nowrap;
  }
  /* celdas sin etiqueta (acciones) ocupan todo el ancho, centradas */
  .table-wrap tbody td:not([data-label]) { justify-content: center; }
  .table-wrap tbody td:not([data-label])::before { content: ''; }

  /* Table header en columna */
  .table-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .table-filters { flex-wrap: wrap; width: 100%; }
  .search-input  { width: 100%; }

  /* Topbar actions en una fila más compacta */
  .topbar-actions { gap: 6px; flex-wrap: wrap; }
  .topbar-actions .btn { font-size: 12px; padding: 6px 12px; }

  /* Kanban → scroll horizontal */
  .kanban { overflow-x: auto; padding-bottom: 16px; }
  .kanban-col { min-width: 260px; }

  /* Modales → hoja inferior, SIEMPRE por encima de la barra inferior */
  .modal-overlay, .modal-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 300 !important;                 /* > .mobnav (150) */
    padding: 0 !important;
    align-items: flex-end !important;
    justify-content: center !important;
    background: rgba(0,0,0,.65) !important;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 16px 16px 0 0 !important;
    margin-top: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }
  /* El cuerpo del modal se desplaza; el pie con los botones queda fijo y visible */
  .modal-body { overflow-y: auto; }
  .modal-footer, .modal-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg2);
    padding-bottom: calc(14px + env(safe-area-inset-bottom)) !important;
    flex-wrap: wrap;
  }
  /* Ocultar la barra inferior cuando hay un modal abierto (no tapa botones) */
  body:has(.modal-overlay.open) .mobnav,
  body:has(.modal-backdrop.open) .mobnav { display: none; }

  /* Más aire al final para que las acciones en página (detalle OT) no queden tapadas */
  .has-mobnav .main { padding-bottom: 92px; }
}

/* ══════════════════════════════════════════════════════════
   MÓVIL PEQUEÑO  ≤ 480px
══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }
  .topbar-title { font-size: 14px; }
  .btn { font-size: 12px; padding: 6px 10px; }

  /* En pantallas muy pequeñas los tabs se hacen scrollables */
  .tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .tab  { white-space: nowrap; flex-shrink: 0; }
}

/* =============================================================
   ESTABILIDAD DEL LOGO DEL SIDEBAR  (aplica a TODAS las páginas)
   -------------------------------------------------------------
   El nombre "AutoTaller Pro" se dibuja primero con una fuente de
   reserva y luego con la fuente web (Syne). Como ambas tienen anchos
   distintos, en la de reserva el texto podía partirse en 2 líneas y
   al cargar Syne volvía a 1 línea, cambiando la altura del bloque y
   haciendo "saltar" el menú al navegar entre páginas.

   Aquí fijamos una sola línea y alturas deterministas, de modo que el
   bloque del logo mida SIEMPRE lo mismo sin importar qué fuente esté
   activa. Así todas las ventanas se sienten igual de estables (como
   Gastos / Activos fijos / Órdenes). Esta hoja se carga después del
   <style> interno de cada página, por lo que prevalece.
   ============================================================= */
.sidebar-logo span,
.sidebar-logo h1 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.sidebar-logo span { line-height: 16px; min-height: 16px; }
.sidebar-logo h1   { line-height: 24px; min-height: 24px; }
