/* Responsive y ajustes por tamaño de pantalla */



@media (max-width: 767px) {

  /* Sidebar oculto por defecto */
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 200;
    width: 240px;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  /* Overlay oscuro detrás del sidebar */
  #sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: oklch(0.1 0.01 80 / 0.6);
    z-index: 199;
  }

  #sidebarOverlay.open {
    display: block;
  }

  /* Botón hamburguesa superior oculto en móvil (se traslada a la barra inferior) */
  #hamburger {
    display: none !important;
  }

  /* Topbar compacto en móvil */
  #topbar {
    height: 42px;
    min-height: 42px;
    padding: 0 var(--space-3);
    gap: var(--space-2);
  }

  .page-title {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .search-box {
    min-width: 0;
    flex: 1;
    height: 32px;
    padding: 0 var(--space-2);
  }

  .search-box input {
    font-size: 13px;
  }

  .search-box i {
    width: 14px;
    height: 14px;
  }

  .theme-toggle {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
  }

  .theme-toggle i {
    width: 16px;
    height: 16px;
  }

  .page-title.centered-mobile-title {
    text-align: center;
  }

  .page-title.calendar-mobile-title {
    text-align: center;
    line-height: 1.05;
    white-space: normal;
  }

  /* Botón de añadir superior oculto en móvil (centralizado en barra inferior) */
  #addBtn {
    display: none !important;
  }

  /* Botones 'Nuevo' dentro de módulos ocultos en móvil para ganar espacio */
  .mobile-hidden-action {
    display: none !important;
  }

  /* Contenido ocupa todo el ancho */
  #main {
    width: 100vw;
  }

  #content {
    padding: var(--space-3) var(--space-3);
  }

  .module-list-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
  }

  .module-list-toolbar .filter-bar {
    width: 100%;
    justify-content: flex-start;
    margin-bottom: 0;
    flex-wrap: wrap;
  }

  .module-primary-actions {
    width: 100%;
    flex-wrap: nowrap;
  }

  .desktop-button-label {
    display: none;
  }

  .mobile-button-label {
    display: inline;
  }

  /* Tablas: scroll horizontal */
  .table-card {
    overflow-x: auto;
  }

  .data-table {
    min-width: 500px;
  }

  /* Cards de equipos: una columna */
  .cards-grid {
    grid-template-columns: 1fr;
  }

  /* Panel detalle: pantalla completa */
  .detail-panel {
    width: 100vw;
    max-width: 100vw;
  }

  /* Modal: pantalla completa */
  .modal {
    max-width: 100%;
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
  }

  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

}


/* Listados móviles en formato tarjeta para evitar scroll horizontal */
@media (max-width: 767px) {
  .mobile-card-container {
    overflow: visible !important;
    background: transparent;
    border: 0;
    border-radius: 0;
  }

  .mobile-card-table {
    min-width: 0 !important;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 var(--space-3);
  }

  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table tbody {
    display: block;
  }

  .mobile-card-table tr {
    display: grid;
    gap: var(--space-2) var(--space-3);
    align-items: center;
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }

  .mobile-card-table td {
    display: block;
    padding: 0 !important;
    border-bottom: 0 !important;
    min-width: 0;
  }

  .mobile-card-table tr:hover td {
    background: transparent;
  }

  .mobile-card-table td[style*="text-align:center"] {
    text-align: left !important;
  }

  .mobile-card-table td[style*="text-align:right"] {
    text-align: right !important;
  }
}

@media (max-width: 767px) {
  .mobile-card-table td[colspan] {
    grid-column: 1 / -1 !important;
    text-align: center !important;
  }
}




/* Menú móvil: mantener separación de grupos sin mostrar cabeceras */
@media (max-width: 767px) {
  .sidebar-nav .nav-section-label {
    height: 10px;
    margin: var(--space-1) var(--space-3);
    padding: 0;
    border-top: 1px solid var(--color-divider);
    color: transparent;
    font-size: 0;
    line-height: 0;
    overflow: hidden;
  }
}

@media (max-width: 767px) {
  .historial-table.mobile-card-table tr {
    padding: var(--space-2);
    gap: 4px;
  }

  .historial-table.mobile-card-table td {
    padding: 2px 0;
    font-size: 12px;
  }

  .historial-detail {
    font-size: 11px
  }
}

@media (max-width: 767px) {
  .modal-actions {
    flex-wrap: wrap !important;
    gap: var(--space-2) !important;
    justify-content: space-between !important;
  }

  .modal-actions button,
  .modal-actions .btn {
    flex: 1 1 calc(50% - var(--space-2)) !important;
    margin: 0 !important;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .modal-actions .btn-danger-soft,
  .modal-actions .btn-danger {
    flex: 1 1 100% !important;
    order: -1;
  }
}

/* ── Barra de Navegación Inferior en Móvil ──────────────── */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 767px) {
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: var(--color-surface, #1e1b18);
    border-top: 1px solid var(--color-border, #332f2b);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 150;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--color-text-muted, #a39c94);
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    padding: 6px 2px;
    cursor: pointer;
    border-radius: var(--radius-md, 8px);
    transition: color 0.15s ease, transform 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-item i {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
  }

  .mobile-nav-item:active {
    transform: scale(0.92);
  }

  .mobile-nav-item.active {
    color: var(--color-primary, #df7a36);
    font-weight: 600;
  }

  .mobile-nav-item.active i {
    stroke-width: 2.3px;
  }

  .mobile-nav-item--add {
    flex: 0 0 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .mobile-nav-add-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-primary, #df7a36);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(223, 122, 54, 0.45);
    margin-top: -14px;
    transition: transform 0.15s ease, background 0.15s ease;
  }

  .mobile-nav-add-btn i {
    width: 24px;
    height: 24px;
    stroke-width: 2.5px;
    color: #fff;
  }

  .mobile-nav-add-btn:active {
    transform: scale(0.92);
  }

  /* Compensar espacio inferior en el contenido principal para no tapar elementos con la barra */
  #content {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  }
}