/* ═══ SIDEBAR RESPONSIVO ═══ */
@media (max-width: 768px) {
  #sidebarNav, .sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    height: 100vh !important;
    width: 280px !important;
    z-index: 500 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s ease !important;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15) !important;
    overflow-y: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #sidebarNav.open, #sidebarNav.mobile-open,
  .sidebar.open, .sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 499;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .btn-menu-toggle {
    display: flex !important;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 600;
    background: #166534;
    color: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }
}

@media (min-width: 769px) {
  .btn-menu-toggle { display: none !important; }
  .sidebar-overlay { display: none !important; }
}

/* ═══ MÉTRICAS RESPONSIVAS ═══ */
@media (max-width: 768px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  .metric-card {
    padding: 12px !important;
  }

  .metric-card .metric-number {
    font-size: 1.5rem !important;
  }
}

/* ═══ TABLAS RESPONSIVAS ═══ */
@media (max-width: 768px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-responsive table {
    min-width: 600px;
  }

  .col-hide-mobile {
    display: none !important;
  }
}

/* ═══ CHAT RESPONSIVO ═══ */
@media (max-width: 768px) {
  .chat-container {
    flex-direction: column;
  }

  .chat-header {
    padding: 8px 12px;
    font-size: 14px;
  }

  .chat-input-area {
    padding: 8px;
  }

  .chat-input-area input,
  .chat-input-area textarea {
    font-size: 16px;
  }

  .historial-drawer {
    width: 100% !important;
  }
}

/* ═══ SUPERADMIN TABLAS ═══ */
@media (max-width: 768px) {
  .superadmin-table {
    min-width: 500px;
  }

  .superadmin-table .col-schema,
  .superadmin-table .col-fecha {
    display: none;
  }

  .superadmin-table td:last-child {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 100px;
  }

  .superadmin-table td:last-child button,
  .superadmin-table td:last-child a {
    width: 100%;
    font-size: 12px;
    padding: 4px 8px;
  }

  .btn-nueva-empresa {
    width: 100%;
    text-align: center;
    margin-bottom: 12px;
  }
}

/* ═══ FORMULARIOS Y BOTONES ═══ */
@media (max-width: 768px) {
  .btn-group {
    flex-direction: column;
    gap: 8px;
  }

  .btn-group button,
  .btn-group a {
    width: 100%;
    text-align: center;
  }

  .form-row {
    flex-direction: column;
  }

  .tabs-nav {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}
