/* ============================================
   RESPONSIVE - Breakpoints estándar
   ============================================ */

/* Tablets (1024px) */
@media (max-width: 1024px) {
  #dashboard-app .main {
    padding: 0.75rem 1rem;
  }

  #dashboard-app #content {
    padding: 1rem;
  }

  #dashboard-app .cards {
    gap: 1.25rem;
    grid-template-columns: 1fr;
  }

  #dashboard-app .header {
    padding: 0.75rem 1rem;
  }
}

/* Móviles y tablets pequeñas (768px) */
@media (max-width: 768px) {
  #dashboard-app {
    flex-direction: row;
    min-height: 100vh;
    position: relative;
  }

  /* Botón hamburguesa en header */
  #dashboard-app .header-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: #64748b;
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 8px;
  }

  #dashboard-app .header-menu-btn:hover {
    background: #f1f5f9;
    color: #7c3aed;
  }

  /* Sidebar como drawer overlay - estilo Factiliza */
  #dashboard-app .sidebar {
    position: fixed;
    top: 1rem;
    left: 1rem;
    bottom: 1rem;
    width: 280px;
    max-width: calc(100vw - 2rem);
    padding: 1.5rem 1.25rem;
    z-index: 1001;
    transform: translateX(calc(-100% - 2rem));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: none;
    border: none;
    border-radius: 16px;
    background: white;
  }

  #dashboard-app .sidebar.drawer-open {
    transform: translateX(0);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.05);
  }

  #dashboard-app .sidebar .sidebar-toggle {
    display: none;
  }

  #dashboard-app .sidebar .sidebar-close {
    display: flex;
    margin-left: auto;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
  }

  #dashboard-app .sidebar .sidebar-close:hover {
    background: #e5e7eb;
    color: #374151;
  }

  #dashboard-app .sidebar .logo {
    display: flex;
    margin-bottom: 2rem;
    align-items: center;
  }

  #dashboard-app .sidebar .logo-text {
    display: block !important;
    color: #7c3aed !important;
    font-weight: 700;
  }

  #dashboard-app .sidebar .nav {
    flex-direction: column;
    gap: 0.35rem;
  }

  #dashboard-app .sidebar .nav-item {
    flex-direction: row;
    padding: 0.8rem 1rem;
    gap: 0.75rem;
    border-radius: 12px;
  }

  #dashboard-app .sidebar .nav-item.active {
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
  }

  #dashboard-app .sidebar.collapsed,
  #dashboard-app .sidebar.collapsed:hover {
    width: 280px;
    max-width: 85vw;
    padding: 1.5rem 1rem;
  }

  #dashboard-app .sidebar.collapsed .nav-label,
  #dashboard-app .sidebar.collapsed:hover .nav-label {
    display: block !important;
  }

  /* Backdrop - solo en móvil */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .sidebar-backdrop.visible {
    display: block;
    opacity: 1;
  }

  /* Main sin padding extra */
  #dashboard-app .main {
    padding: 0.75rem 1rem;
    padding-bottom: 0;
    flex: 1;
    width: 100%;
  }

  /* Header compacto con hamburguesa */
  #dashboard-app .header {
    flex-wrap: nowrap;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  #dashboard-app .header .page-title {
    font-size: 1.1rem;
    flex: 1;
    margin: 0;
  }

  #dashboard-app .user-info {
    flex: 0;
    justify-content: flex-end;
  }

  #dashboard-app .user-details {
    display: none;
  }

  #dashboard-app .user-profile-trigger {
    padding: 0.25rem;
  }

  /* Toolbar botones apilados */
  .toolbar {
    flex-direction: column;
    gap: 0.5rem;
  }

  .toolbar .btn {
    width: 100%;
  }

  /* Tabla con scroll horizontal */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    min-width: 720px;
  }

  .table th,
  .table td {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  /* Cards y formularios */
  #dashboard-app .cards {
    gap: 1rem;
    max-width: none;
  }

  #dashboard-app .card {
    padding: 1rem;
  }

  #dashboard-app .send-form {
    padding: 1.25rem 1rem;
  }

  #dashboard-app .send-card-header {
    padding: 1.25rem 1rem;
  }

  .phone-input select,
  #dashboard-app .send-form .phone-input .form-control-select {
    min-width: 90px;
  }
}

/* Móviles pequeños (480px) */
@media (max-width: 480px) {
  #dashboard-app .main {
    padding: 0.5rem 0.75rem;
    padding-bottom: 5.25rem;
  }

  #dashboard-app .header {
    padding: 0.5rem 0.75rem;
  }

  #dashboard-app #content {
    padding: 0.75rem;
  }

  #dashboard-app .card {
    padding: 0.875rem;
  }

  #dashboard-app .card h3 {
    font-size: 0.95rem;
  }

  #dashboard-app .send-card-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
  }

  #dashboard-app .send-form {
    padding: 1rem;
  }

  #dashboard-app .send-form .phone-input {
    flex-direction: column;
  }

  #dashboard-app .send-form .phone-input .form-control-select {
    width: 100%;
  }

  .page-title {
    font-size: 1rem;
  }

  .token-box {
    flex-direction: column;
  }

  .token-box code {
    font-size: 0.7rem;
    padding: 0.5rem;
  }

  #dashboard-app .sidebar .nav-label {
    font-size: 0.65rem;
  }
}

/* Auth screen responsive - permitir pull-to-refresh en móvil */
@media (max-width: 768px) {
  body.auth-visible {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .auth-screen {
    padding: 0.75rem;
    align-items: flex-start;
    padding-top: 3.5rem;
    min-height: 100vh;
    max-height: none;
    overflow-y: visible;
    overflow-x: hidden;
    padding-bottom: 2rem;
  }

  .auth-box {
    max-width: 100%;
    padding: 1.25rem 1rem;
    max-height: none;
    overflow: visible;
  }

  .auth-box.auth-box--register {
    max-width: 100%;
    padding: 1rem;
    max-height: none;
    overflow: visible;
  }

  .register-card {
    overflow: visible;
  }

  .doc-row {
    flex-direction: column;
    align-items: stretch;
  }

  .doc-type-group,
  .doc-options {
    width: 100%;
    min-width: unset;
  }

  .doc-options.active {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .auth-screen {
    padding: 0.5rem;
    padding-bottom: 2rem;
  }

  .auth-box {
    padding: 1rem 0.75rem;
  }

  .auth-form .form-group {
    margin-bottom: 0.6rem;
  }

  .form-row,
  .form-row-2 {
    grid-template-columns: 1fr;
  }

  .doc-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .doc-type-group,
  .doc-options {
    width: 100%;
    min-width: unset;
  }

  .doc-options.active {
    width: 100%;
  }
}

/* Admin panel responsive - Drawer móvil como dashboard */
@media (max-width: 768px) {
  .admin-app {
    flex-direction: row;
    position: relative;
  }

  .admin-app .sidebar {
    position: fixed;
    top: 1rem;
    left: 1rem;
    bottom: 1rem;
    width: 280px;
    max-width: calc(100vw - 2rem);
    padding: 1.5rem 1.25rem;
    z-index: 1001;
    transform: translateX(calc(-100% - 2rem));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: none;
    border: none;
    border-radius: 16px;
    background: white;
  }

  .admin-app .sidebar.drawer-open {
    transform: translateX(0);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  }

  .admin-app .sidebar .sidebar-toggle {
    display: none;
  }

  .admin-app .sidebar .sidebar-close {
    display: flex;
    margin-left: auto;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
  }

  .admin-app .sidebar .sidebar-close:hover {
    background: #e5e7eb;
  }

  .admin-app .header-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: #64748b;
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 8px;
  }

  .admin-app .header-menu-btn:hover {
    background: #f1f5f9;
    color: #7c3aed;
  }

  .admin-app .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .admin-app .sidebar-backdrop.visible {
    display: block;
    opacity: 1;
  }

  .admin-app .main {
    padding: 0.75rem 1rem;
    padding-bottom: 2rem;
  }

  .admin-app #admin-content {
    padding: 1rem;
  }

  .admin-app .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-app .table {
    min-width: 720px;
  }

  .admin-app .toolbar .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}
