/* ========================================
   RESPONSIVE.CSS - Media Queries Centralizados
   ======================================== */

/* ========================================
   BREAKPOINTS:
   - Mobile: 0-767px
   - Tablet: 768-1023px
   - Desktop: 1024px+
   ======================================== */


/* ========================================
   TABLET & MOBILE (max-width: 1023px)
   ======================================== */
@media (max-width: 1023px) {
  /* Grids que colapsan a menos columnas */
  .grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Grid 2-1 (2fr 1fr) se mantiene en tablet */
  .grid-2-1 {
    grid-template-columns: 2fr 1fr;
  }

  /* Grid-fixed-flex-auto (tarjetas de estrategia) */
  .grid-fixed-flex-auto {
    grid-template-columns: auto 1fr;
    gap: 1rem;
  }

  /* Ocultar columna de acciones en tarjetas de estrategia */
  .grid-fixed-flex-auto > div:last-child {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}


/* ========================================
   MOBILE (max-width: 767px)
   ======================================== */
@media (max-width: 767px) {

  /* ===== HEADER ===== */
  .header {
    padding: 0.5rem 1rem;
  }

  /* Ajustar padding del main para header más pequeño en móvil */
  main {
    padding-top: 56px;
  }

  .header-container {
    gap: 1rem;
  }

  /* Ocultar navegación desktop en móvil */
  .header-nav {
    display: none !important;
  }

  /* Ocultar acciones desktop (notificaciones, idioma) en móvil */
  .header-actions {
    display: none !important;
  }

  /* Mostrar botón hamburguesa en móvil */
  .header-menu-btn {
    display: flex !important;
  }

  /* Animación del botón hamburguesa a X */
  .header-menu-btn[aria-expanded="true"] span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
  }

  .header-menu-btn[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }

  .header-menu-btn[aria-expanded="true"] span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
  }

  /* ===== FOOTER ===== */
  .footer-container {
    flex-direction: column;
    text-align: center;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }

  /* ===== CONTAINER ===== */
  .container {
    padding: 1rem;
  }

  /* ===== GRIDS - TODOS A 1 COLUMNA ===== */
  .grid-6,
  .grid-5,
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  /* Grid 2-1 colapsa a 1 columna */
  .grid-2-1 {
    grid-template-columns: 1fr;
  }

  /* Grid-auto-flex (auto 1fr) colapsa */
  .grid-auto-flex {
    grid-template-columns: 1fr;
  }

  /* Grid-auto-flex-auto (auto 1fr auto) colapsa */
  .grid-auto-flex-auto {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Grid-3-equal colapsa */
  .grid-3-equal {
    grid-template-columns: 1fr;
  }

  /* Grid-fixed-flex-auto (tarjetas de estrategia) */
  .grid-fixed-flex-auto {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* ===== FLEX-BETWEEN - Colapsan a columna ===== */
  .flex-between {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  /* Excepciones: mantener flex-between en algunos casos pequeños */
  .card .flex-between,
  table .flex-between {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }

  /* ===== FLEX-END - Alinear al inicio en móvil ===== */
  .flex-end {
    justify-content: flex-start;
  }

  /* ===== BUTTONS & TABS ===== */
  .btn {
    width: 100%;
    text-align: center;
  }

  /* Tabs envuelven mejor */
  .tabs {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .tab {
    flex: 1 1 auto;
    min-width: fit-content;
  }

  /* ===== CARDS ===== */
  .card {
    padding: 1rem;
  }

  /* ===== SECTION TITLES ===== */
  .section-title {
    font-size: 1.2rem;
  }

  /* ===== TABLES ===== */
  /* Mantener overflow-x-auto para scroll horizontal */
  .overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100vw;
  }

  table {
    min-width: 600px; /* Fuerza scroll horizontal */
    font-size: 0.75rem;
  }

  table th,
  table td {
    padding: 0.5rem !important;
    white-space: nowrap;
  }

  /* ===== AVATARES ===== */
  .avatar-lg {
    width: 36px;
    height: 36px;
  }

  .avatar-md {
    width: 28px;
    height: 28px;
  }

  .avatar-sm {
    width: 20px;
    height: 20px;
  }

  /* ===== UTILIDADES DE LAYOUT ===== */
  .w-100,
  .w-180 {
    width: 80px; /* Más pequeño en móvil */
  }

  .h-100,
  .h-180 {
    height: 80px;
  }

  .h-300 {
    height: 200px;
  }

  /* ===== TEXT SIZES ===== */
  .text-lg {
    font-size: 1rem;
  }

  .text-md {
    font-size: 0.85rem;
  }

  .text-sm {
    font-size: 0.75rem;
  }

  .text-xs {
    font-size: 0.7rem;
  }

  /* ===== CARD VALUES (números grandes) ===== */
  .card-value {
    font-size: 1.2rem;
  }

  /* ===== SPACING ===== */
  .gap-4 {
    gap: 1rem;
  }

  .gap-3 {
    gap: 0.75rem;
  }

  .gap-2 {
    gap: 0.5rem;
  }

  /* ===== HIDE ELEMENTS ON MOBILE ===== */
  .hide-mobile {
    display: none;
  }

  /* ===== SELECT DROPDOWN ===== */
  select.btn {
    width: 100%;
  }
}


/* ========================================
   SMALL MOBILE (max-width: 480px)
   ======================================== */
@media (max-width: 480px) {

  /* Container más pequeño */
  .container {
    padding: 0.75rem;
  }

  /* Cards más compactas */
  .card {
    padding: 0.75rem;
  }

  /* Títulos más pequeños */
  h1, .text-lg {
    font-size: 1rem;
  }

  h2 {
    font-size: 0.95rem;
  }

  h3 {
    font-size: 0.85rem;
  }

  /* Badges más pequeños */
  .badge {
    font-size: 0.6rem;
    padding: 0.2rem 0.5rem;
  }

  /* Buttons más compactos */
  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Header más compacto */
  .header {
    padding: 0.5rem;
  }

  .header-logo-img {
    height: 32px;
  }

  .header-logo-text {
    font-size: 1rem;
  }

  /* Avatares aún más pequeños */
  .avatar-lg {
    width: 32px;
    height: 32px;
  }

  .avatar-md {
    width: 24px;
    height: 24px;
  }

  /* Tablas más compactas */
  table {
    font-size: 0.7rem;
  }

  table th,
  table td {
    padding: 0.35rem !important;
  }
}


/* ========================================
   DESKTOP LARGE (min-width: 1400px)
   ======================================== */
@media (min-width: 1400px) {

  /* Mantener layout óptimo en pantallas grandes */
  .container {
    max-width: 1400px;
  }

  /* Opcionales: aumentar tamaños en pantallas muy grandes */
  .card-value {
    font-size: 2rem;
  }

  .section-title {
    font-size: 1.75rem;
  }
}


/* ========================================
   LANDSCAPE MOBILE (orientación horizontal)
   ======================================== */
@media (max-width: 767px) and (orientation: landscape) {

  /* Reducir padding vertical */
  .container {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  /* Cards más compactas verticalmente */
  .card {
    padding: 0.75rem;
  }

  /* Header sticky más compacto */
  .header {
    padding: 0.35rem 1rem;
  }
}


/* ========================================
   PRINT STYLES (para exportar/imprimir)
   ======================================== */
@media print {

  /* Ocultar navegación y acciones */
  .header,
  .btn,
  .tabs,
  .header-actions {
    display: none !important;
  }

  /* Forzar colores para impresión */
  body {
    background: white !important;
    color: black !important;
  }

  .card {
    border: 1px solid #ccc !important;
    background: white !important;
    page-break-inside: avoid;
  }

  /* Grids a una columna para impresión */
  .grid-6,
  .grid-5,
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr !important;
  }
}


/* ========================================
   UTILIDADES RESPONSIVE
   ======================================== */

/* Mostrar/Ocultar por breakpoint */
.show-mobile {
  display: none;
}

@media (max-width: 767px) {
  .show-mobile {
    display: block;
  }

  .hide-mobile {
    display: none;
  }
}

.show-tablet {
  display: none;
}

@media (min-width: 768px) and (max-width: 1023px) {
  .show-tablet {
    display: block;
  }

  .hide-tablet {
    display: none;
  }
}

.show-desktop {
  display: none;
}

@media (min-width: 1024px) {
  .show-desktop {
    display: block;
  }

  .hide-desktop {
    display: none;
  }
}


/* ========================================
   MOBILE DRAWER - MENÚ LATERAL MÓVIL
   ======================================== */

/* Overlay oscuro de fondo */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 998;
}

.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Drawer (Panel lateral) */
.mobile-drawer {
  position: fixed;
  right: 0;
  width: 85%;
  max-width: 320px;
  height: calc(100%); /* Altura completa menos el header */
  background: var(--dark);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* En desktop, ajustar para header de 60px */
@media (min-width: 768px) {
  .mobile-drawer {
    top: 60px;
    height: calc(100% - 60px);
  }
}

.mobile-drawer.active {
  transform: translateX(0);
}

/* Header del Drawer */
.mobile-drawer-header {
  background: var(--card);
  padding: 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.mobile-drawer-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.mobile-drawer-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.mobile-drawer-user-info {
  flex: 1;
  min-width: 0;
}

.mobile-drawer-user-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 0.25rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-drawer-user-email {
  font-size: 0.75rem;
  color: var(--secondary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--secondary);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.mobile-drawer-close:hover {
  background: var(--gray);
  color: var(--primary);
}

/* Navegación del Drawer */
.mobile-drawer-nav {
  padding: 1rem 0;
}

.mobile-drawer-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  color: var(--secondary);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
}

.mobile-drawer-link:hover {
  background: var(--card);
  color: var(--primary);
}

.mobile-drawer-link.active {
  background: var(--card);
  color: var(--success);
  border-left-color: var(--success);
}

/* Icono dentro del drawer link (ya no es necesario con SVG, se elimina) */

/* Sección (Idioma y Notificaciones) */
.mobile-drawer-section {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.mobile-drawer-section-title {
  padding: 0.5rem 1.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--secondary);
  margin: 0 0 0.5rem 0;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.mobile-drawer-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: transparent;
  border: none;
  color: var(--secondary);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.9rem;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.mobile-drawer-option:hover {
  background: var(--card);
  color: var(--primary);
}

.mobile-drawer-badge {
  margin-left: auto;
  background: var(--danger);
  color: var(--txt-light);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  min-width: 20px;
  text-align: center;
}

.mobile-drawer-arrow {
  margin-left: auto;
  font-size: 1.5rem;
  color: var(--secondary);
}

/* Footer del Drawer (Logout) */
.mobile-drawer-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.mobile-drawer-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  transition: all 0.2s;
}

.mobile-drawer-logout:hover {
  background: var(--danger);
  color: var(--txt-light);
  border-color: var(--danger);
}

/* Ocultar drawer en desktop */
@media (min-width: 768px) {
  .mobile-overlay,
  .mobile-drawer {
    display: none;
  }
}
