/* =====================================================================
   ESTILOS OPTIMIZADOS EXCLUSIVOS PARA MÓVILES Y TABLETS (≤ 1180px)
   ===================================================================== */

@media screen and (max-width: 1180px) {
  /* 1. Shell y Layout */
  .app {
    grid-template-columns: 1fr !important;
    padding-top: 60px; /* Espacio para el header fijo */
  }

  main {
    width: 100%;
    overflow-x: hidden;
  }

  /* 2. Header móvil superior fijo */
  .mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(6, 17, 29, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 9999;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-brand .logo {
    width: 32px;
    height: 32px;
    font-size: 18px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(154, 85, 255, 0.3);
  }

  .mobile-brand strong {
    font-size: 15px;
    letter-spacing: 0.5px;
    color: #ffffff;
  }

  .menu-open-btn {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 24px;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
  }

  .menu-open-btn:hover {
    background: rgba(255, 255, 255, 0.08);
  }

  /* 3. Sidebar estilo cajón lateral (Drawer) */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 290px !important;
    height: 100vh !important;
    z-index: 100000 !important;
    background: rgba(5, 15, 27, 0.96) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    transform: translateX(-100%) !important;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 15px 0 40px rgba(0, 0, 0, 0.6) !important;
    padding: 24px 20px !important;
    border-right: 1px solid rgba(148, 163, 184, 0.18) !important;
  }

  .sidebar.open {
    transform: translateX(0) !important;
  }

  /* Botón de cerrar sidebar */
  .sidebar-close-btn {
    position: absolute;
    top: 18px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
  }

  .sidebar-close-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
  }

  /* Overlay de fondo */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* 4. Topbar y acciones */
  .topbar {
    min-height: auto !important;
    padding: 16px 20px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 14px !important;
    background: transparent !important;
    border-bottom: none !important;
    backdrop-filter: none !important;
  }

  .topbar h1 {
    font-size: 22px !important;
  }

  .topbar .subtitle {
    font-size: 13px !important;
  }

  /* Fila horizontal deslizable de acciones */
  .top-actions {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    width: 100% !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    padding-bottom: 8px !important;
    scrollbar-width: none; /* Firefox */
    -webkit-overflow-scrolling: touch;
  }

  .top-actions::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }

  .top-actions .button {
    flex: 0 0 auto !important;
    font-size: 13px !important;
    padding: 8px 12px !important;
    min-height: 36px !important;
  }

  /* 5. Métricas deslizables (Swiper-like) */
  .metrics {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 12px !important;
    width: 100% !important;
    padding-bottom: 8px !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .metrics::-webkit-scrollbar {
    display: none;
  }

  .metric {
    flex: 0 0 165px !important;
    min-height: 94px !important;
    padding: 12px !important;
    gap: 12px !important;
    border-radius: 12px !important;
  }

  .metric-icon {
    width: 44px !important;
    height: 44px !important;
    font-size: 20px !important;
    border-radius: 10px !important;
  }

  .metric strong {
    font-size: 22px !important;
  }

  .metric small {
    font-size: 11px !important;
    margin-bottom: 2px !important;
  }

  .metric span {
    font-size: 10px !important;
    margin-top: 3px !important;
  }

  /* 6. Dashboard Grid y Vista General */
  .dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .product-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .inventory-card {
    min-height: auto !important;
    padding: 14px !important;
  }

  .donut-wrap {
    grid-template-columns: 1fr !important;
    justify-items: center;
    gap: 20px !important;
  }

  .chart-legend {
    width: 100%;
  }

  /* 7. Vista de Cuentas y Formulario de Edición */
  .accounts-layout {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .account-list {
    max-height: 280px !important;
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.01);
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Rediseño completo de filas de perfiles a tarjetas compactas */
  .profiles {
    gap: 14px !important;
  }

  .profile-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px 10px !important;
    padding: 16px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
    border-radius: 12px !important;
    align-items: start !important;
  }

  /* El primer campo (Nombre) toma el 100% de la fila */
  .profile-row label:nth-child(1) {
    grid-column: span 2 !important;
  }

  /* El campo "En tienda" y "Estado" se acomodan a la par */
  .profile-row label:nth-child(8) {
    grid-column: span 1 !important;
  }

  .profile-row label:nth-child(9) {
    grid-column: span 1 !important;
  }

  .profile-row label {
    font-size: 11px !important;
  }

  .profile-row input,
  .profile-row select {
    min-height: 36px !important;
    font-size: 13px !important;
  }
}

@media screen and (max-width: 600px) {
  .login-box {
    padding: 30px 24px 24px 24px !important;
    gap: 20px !important;
  }

  .login-logo {
    font-size: 44px !important;
  }

  .login-header h1 {
    font-size: 21px !important;
  }
}
