/* Bloque Responsive: experiencia móvil-first moderna, fluida y táctil. */

/* Barra de navegación inferior para móvil */
.mobile-bottom-bar {
  display: none;
}

@media(max-width: 1160px) {
  .topbar-user-name { display: none; }
  .admin-topbar { padding-inline: 18px; }
  .admin-main { padding-inline: 18px; }
}

@media(max-width: 860px) {
  .admin-workspace { display: block; }
  .admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    height: 100dvh;
    min-height: 0;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
    z-index: 90;
  }
  .nav-is-open .admin-sidebar {
    transform: translateX(0);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.35);
  }
  .nav-is-open .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 85;
  }
  .nav-is-open { overflow: hidden; }
  .nav-toggle { display: grid; margin-right: 4px; }
  .topbar-user-name { display: none; }
  .sidebar-bottom { margin-top: auto; }

  /* Mobile Bottom Navigation Bar */
  .mobile-bottom-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: 54px;
    height: calc(54px + env(safe-area-inset-bottom, 0));
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
    z-index: 50;
  }
  .mobile-bottom-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    height: 100%;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 2px 4px;
    transition: color 0.12s;
  }
  .mobile-bottom-link .ui-icon {
    width: 18px;
    height: 18px;
  }
  .mobile-bottom-link:hover, .mobile-bottom-link.is-active {
    color: var(--primary);
  }
  .mobile-bottom-link.is-active {
    font-weight: 750;
  }

  /* Offset para que la barra inferior no tape el contenido */
  .admin-main {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0));
  }
  .admin-footer {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
  }
}

@media(max-width: 760px) {
  .admin-topbar {
    min-height: 50px;
    padding: 0 14px;
  }
  .admin-main {
    padding: 16px 14px calc(72px + env(safe-area-inset-bottom, 0));
  }
  .topbar-eyebrow, .topbar-separator { display: none; }
  .topbar-title { font-size: 0.8rem; }
  .topbar-actions { gap: 6px; }
  .topbar-user { padding-left: 6px; }
  .topbar-user-name { display: none; }
  .button-logout {
    padding: 4px;
    min-width: 30px;
    width: 30px;
    min-height: 30px;
    justify-content: center;
  }
  .button-logout span { display: none; }
  
  .page-heading-modern {
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-heading-modern h1 { font-size: 1.35rem; }
  .page-heading-modern .button { width: 100%; }

  /* Filtros en móvil */
  .list-filters {
    padding: 12px 14px;
    gap: 8px;
  }
  .filter-main-bar {
    flex-direction: row;
    align-items: stretch;
  }
  .filter-search {
    flex: 1 1 180px;
  }
  .filter-select { flex: 1 1 100%; }
  .filter-page-size { flex: 1 1 100%; }
  .filter-actions {
    flex: 1 1 100%;
    justify-content: flex-end;
    margin-top: 4px;
  }
  .list-panel-divider { display: none; }

  /* Tablas adaptables en tarjetas móviles compactas */
  .table-wrap {
    overflow: visible;
    padding: 0 12px 12px;
  }
  .data-table-adaptive {
    min-width: 0;
    display: block;
  }
  .data-table-adaptive thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .data-table-adaptive tbody {
    display: grid;
    gap: 10px;
  }
  .data-table-adaptive tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--ui-radius);
    padding: 10px 14px;
    box-shadow: var(--shadow-sm);
  }
  .data-table-adaptive tbody tr:hover { background: var(--surface); }
  .data-table-adaptive tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--line-subtle);
    text-align: right;
    font-size: 0.8rem;
    min-width: 0;
  }
  .data-table-adaptive tbody tr td:last-child {
    border-bottom: 0;
    padding-top: 8px;
  }
  .data-table-adaptive tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    text-align: left;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex: 0 0 35%;
  }
  .data-table-adaptive tbody .cell-content {
    max-width: 65%;
    overflow-wrap: break-word;
  }
  .data-table-adaptive tbody .status-pill {
    margin-left: auto;
  }
  .data-table-adaptive tbody .table-actions {
    justify-content: flex-end;
  }
  .data-table-adaptive tbody .table-row-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .data-table-adaptive tbody .no-results td {
    display: block;
    text-align: center;
  }
  .data-table-adaptive tbody .no-results td::before { display: none; }

  /* Paginador móvil */
  .paginator {
    padding: 10px 14px;
    justify-content: center;
    gap: 10px;
  }
  .pagination-summary {
    width: 100%;
    text-align: center;
    font-size: 0.74rem;
  }

  /* Formularios sin tarjeta */
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .form-section { padding: 18px 0; }
  .form-sticky-actions {
    padding: 16px 0 28px;
    flex-wrap: wrap;
  }
  .form-sticky-actions .button { flex: 1; min-height: 40px; }

  /* Seguridad y auditoría */
  .security-feature-grid { grid-template-columns: 1fr; }
  .audit-details { padding: 16px 14px; }
  .audit-meta-grid { grid-template-columns: 1fr; }
}

@media(max-width: 440px) {
  .welcome-decoration { display: none; }
  .welcome-banner { padding: 18px 16px; }
  .topbar-title { max-width: 140px; }
}

@media(prefers-reduced-motion: reduce) {
  .admin-sidebar, .quick-card, [data-dropdown-menu], .tab-pane {
    transition: none !important;
    animation: none !important;
  }
}
