/* ===== Pixel One Platform — Diseño Responsive Completo ===== */

/* ===== BASE ===== */
body { 
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
  background-color: #f3f4f6; 
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ===== SIDEBAR ===== */
#sidebar {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s ease;
  z-index: 100;
}
#menuToggle { display: none; }
#sidebarOverlay { display: none; }

/* ===== BOTTOM NAV (mobile) ===== */
#mobileBottomNav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 80;
  background: white;
  border-top: 1px solid #e5e7eb;
  padding: 4px 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}

/* ===== TABLAS ===== */
.inventory-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* ===== LOGIN ===== */
.login-card {
  animation: fadeInUp 0.5s ease both;
}

/* ===== TIMELINE ===== */
.timeline-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* ===== CHIPS Y BADGES ===== */
.pill-premium { background-color: #4f46e5; color: white; font-size: 10px; padding: 2px 8px; border-radius: 9999px; font-weight: bold; }
.pill-gold { background-color: #d97706; color: white; font-size: 10px; padding: 2px 8px; border-radius: 9999px; font-weight: bold; }
.pill-standard { background-color: #6b7280; color: white; font-size: 10px; padding: 2px 8px; border-radius: 9999px; font-weight: bold; }

/* ===== ESTADOS DE FILA ===== */
.row-sold { background-color: #ecfdf5; border-left: 4px solid #10b981; }
.row-empty { border-left: 4px solid #e5e7eb; }
.row-split-am { border-left: 4px solid #f59e0b; background-color: #fffbeb; }
.row-split-pm { border-left: 4px solid #3b82f6; background-color: #eff6ff; }

/* ===== BARRAS DE PROGRESO ===== */
.progress-bar-bg { background-color: #e5e7eb; border-radius: 9999px; height: 12px; overflow: hidden; }
.progress-bar-fill { height: 100%; transition: width 0.5s ease-in-out; }

/* ===== SIDEBAR ITEMS ===== */
.sidebar-item { transition: all 0.2s; cursor: pointer; border-radius: 8px; margin-bottom: 4px; }
.sidebar-item:hover { background-color: #e5e7eb; }
.sidebar-item.active { background-color: #4f46e5; color: white; }
.sidebar-item.active .text-gray-500 { color: #a5b4fc; }

/* ===== TIMELINE CELDAS ===== */
.timeline-cell { min-width: 38px; height: 38px; border-right: 1px solid #f3f4f6; border-bottom: 1px solid #f3f4f6; position: relative; padding: 1px 0; }
.timeline-header { min-width: 38px; text-align: center; font-size: 9px; padding: 3px; border-right: 1px solid #e5e7eb; background: #f9fafb; color: #6b7280; line-height: 1.1; }
.sticky-col { position: sticky; left: 0; z-index: 50; background-color: white; border-right: 2px solid #e5e7eb; box-shadow: 2px 0 5px rgba(0,0,0,0.05); }
.sticky-header { position: sticky; left: 0; z-index: 60; background-color: #f9fafb; }
.timeline-bar { 
  border-radius: 3px; position: absolute; left: 1px; right: 1px; 
  opacity: 0.95; box-shadow: 0 1px 2px rgba(0,0,0,0.15); 
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
  padding-left: 4px; font-size: 8px; color: white; font-weight: 600; 
  transition: all 0.2s; z-index: 5; 
}
.timeline-bar-full { height: 28px; top: 5px; line-height: 28px; }
.timeline-bar-am { height: 13px; top: 3px; line-height: 13px; z-index: 10; border-bottom: 1px solid rgba(255,255,255,0.3); }
.timeline-bar-pm { height: 13px; top: 18px; line-height: 13px; z-index: 9; border-top: 1px solid rgba(255,255,255,0.3); }
.future-stripe { 
  background: repeating-linear-gradient(45deg,#9333ea,#9333ea 5px,#a855f7 5px,#a855f7 10px) !important; 
  opacity: 0.8 !important; border: 1px solid #7e22ce; 
}
.timeline-today { background-color: #fffbeb; }

/* ===== REPORTES ===== */
.report-card { border: 1px solid #e5e7eb; border-radius: 8px; padding: 1.5rem; text-align: center; }
.chart-bar-container { display: flex; align-items: flex-end; height: 100px; gap: 15px; justify-content: center; }
.chart-bar { width: 40px; border-radius: 4px 4px 0 0; position: relative; transition: height 0.5s; }
.chart-label { font-size: 10px; color: #6b7280; margin-top: 5px; text-align: center; font-weight: bold; }
.chart-val { position: absolute; top: -20px; left: 0; right: 0; text-align: center; font-size: 11px; font-weight: bold; color: #374151; }

/* ===== MODALES ===== */
#bookingModal {
  z-index: 9998 !important;
}
#adminModal {
  z-index: 9997 !important;
}
.modal-overlay { 
  background-color: rgba(0,0,0,0.5); 
  backdrop-filter: blur(2px); 
}

/* ===== SCROLL PERSONALIZADO ===== */
.custom-scroll::-webkit-scrollbar { height: 6px; width: 6px; }
.custom-scroll::-webkit-scrollbar-track { background: #f1f1f1; }
.custom-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.custom-scroll::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== TABS DE NAVEGACIÓN ===== */
.nav-tab { color: #6b7280; border-bottom: 2px solid transparent; white-space: nowrap; }
.nav-tab:hover { color: #4f46e5; }
.nav-tab.active { color: #4f46e5; border-bottom: 2px solid #4f46e5; font-weight: bold; }

/* ===== ANIMACIONES ===== */
@keyframes fadeInUp { from { opacity:0; transform:translateY(24px); } to { opacity:1; transform:translateY(0); } }
@keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.animate-slide-up { animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) both; }

/* ===== ROLES ===== */
.role-admin { background:#fef2f2; color:#dc2626; border:1px solid #fecaca; }
.role-vendedor { background:#eef2ff; color:#4f46e5; border:1px solid #c7d2fe; }
.role-contenido { background:#f0fdf4; color:#16a34a; border:1px solid #bbf7d0; }
.role-gestion { background:#faf5ff; color:#9333ea; border:1px solid #e9d5ff; }

/* ===== REQUISICIÓN ===== */
.req-row-pending { border-left: 4px solid #f59e0b; background-color: #fffbeb; }
.req-row-uploaded { border-left: 4px solid #10b981; background-color: #ecfdf5; }

/* ===== GLASS PANEL ===== */
.glass-panel { background: white; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1),0 2px 4px -1px rgba(0,0,0,0.06); }

/* ============================================================
   ===== RESPONSIVE: TABLETS Y MÓVILES (≤768px) =====
   ============================================================ */
@media (max-width: 768px) {
  /* Sidebar como drawer */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
  }
  #sidebar.open { transform: translateX(0); }
  
  #sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 90;
  }
  #sidebarOverlay.show { display: block; }
  #menuToggle { display: flex !important; }

  /* Header compacto */
  #mainHeader { 
    padding: 10px 12px !important; 
  }
  #mainHeader h2 { 
    font-size: 1.1rem !important; 
  }

  /* Ocultar texto secundario en header */
  #mainHeader .subtitle-text { 
    display: none; 
  }

  /* KPI cards más compactos */
  #kpi-section { 
    grid-template-columns: repeat(2, 1fr) !important; 
    gap: 8px !important; 
    margin-bottom: 12px !important;
  }
  #kpi-section .glass-panel { 
    padding: 10px !important; 
  }
  #kpi-section h2 { 
    font-size: 1.1rem !important; 
  }
  #kpi-section p { 
    font-size: 9px !important; 
  }

  /* Inventario: tabla scrolleable */
  .inventory-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
  }
  .inventory-table-wrapper table {
    min-width: 600px;
    font-size: 12px;
  }
  .inventory-table-wrapper th,
  .inventory-table-wrapper td {
    padding: 6px 8px !important;
    white-space: nowrap;
  }

  /* Botones más touch-friendly */
  button, .btn-like { 
    min-height: 36px; 
  }
  .nav-tab {
    font-size: 11px !important;
    padding: 8px 10px !important;
  }

  /* Timeline scrollable */
  .timeline-wrapper { 
    overflow-x: auto; 
    margin: 0 -12px;
    padding: 0 12px;
  }

  /* Modal: más ancho en mobile */
  #bookingModal .max-w-2xl,
  #adminModal .max-w-2xl { 
    max-width: 95vw !important; 
    margin: 0 8px !important;
  }

  /* Reportes: stacked */
  #report-section .grid-cols-3 { 
    grid-template-columns: 1fr 1fr !important; 
    gap: 8px !important;
  }

  /* Business Intelligence: stacked */
  #bi-section .grid-cols-2 { 
    grid-template-columns: 1fr !important; 
  }

  /* Ocultar columnas secundarias en tabla */
  .mobile-col-hide { 
    display: none !important; 
  }

  /* Ocultar botón de temas en mobile (lo tapa el bottom nav) */
  #theme-toggle-btn, #theme-selector-container {
    display: none !important;
  }

  /* Inputs más grandes para touch */
  input, select, textarea {
    font-size: 16px !important; /* evita zoom en iOS */
  }

  /* Padding general más compacto */
  #main-content-area { 
    padding: 12px !important;
    padding-bottom: 70px !important; /* espacio para bottom nav */
  }

  /* Bottom Navigation */
  #mobileBottomNav { 
    display: flex !important; 
    z-index: 999 !important; 
  }

  /* Sidebar padding para bottom nav */
  #sidebar {
    padding-bottom: 70px !important;
  }

  /* Admin modal: espacio para bottom nav */
  #adminModal .overflow-y-auto {
    padding-bottom: 20px !important;
  }

  /* Sidebar footer: no queda detrás del bottom nav */
  #sidebar > div:last-child {
    padding-bottom: 20px !important;
  }

  /* Admin modal con espacio para bottom nav */
  #adminModal > div {
    max-height: 75vh !important;
    margin-bottom: 60px !important;
  }

  /* Tabla de reportes scrolleable */
  #report-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Requisición scrolleable */
  #requisicion-container {
    margin: 0 -12px;
    padding: 0 12px;
  }

  /* Selector de ubicaciones en admin: 1 columna */
  #userLocationsSelector {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   ===== RESPONSIVE: MÓVILES PEQUEÑOS (≤480px) =====
   ============================================================ */
@media (max-width: 480px) {
  #sidebar { width: 100%; }
  
  #kpi-section { 
    grid-template-columns: repeat(2, 1fr) !important; 
    gap: 6px !important;
  }
  #kpi-section .glass-panel { 
    padding: 8px !important; 
  }
  #kpi-section h2 { 
    font-size: 0.95rem !important; 
  }

  .login-card { 
    margin: 0 8px !important; 
  }

  /* Modales casi full-screen */
  #bookingModal .max-w-2xl {
    max-width: 100vw !important;
    margin: 0 !important;
    border-radius: 0 !important;
    min-height: 100vh;
  }
  #bookingModal .rounded-t-lg {
    border-radius: 0 !important;
  }

  /* Reportes: 1 columna */
  #report-section .grid-cols-3,
  #report-section .grid-cols-2 { 
    grid-template-columns: 1fr !important; 
  }

  /* Botón nueva pauta — solo ícono */
  #btn-nueva-pauta span { 
    display: none !important; 
  }
  #btn-nueva-pauta i { 
    margin-right: 0 !important; 
  }
}

/* ===== SWIPE: cerrar sidebar con gesto ===== */
@media (pointer: coarse) {
  #sidebar {
    touch-action: pan-y;
  }
}
