/* 🎨 GONHER RESPONSIVE CSS - Sistema Unificado de Estilos Responsive
   📱 Responsive Universal para cualquier dispositivo - Mobile First Approach
   🎯 Objetivo: Hacer todas las pantallas responsive para cualquier tamaño de dispositivo
   📱 📟 💻 🖥️ Compatible: Teléfonos, Tablets, Laptops, Monitores, Smart TVs
*/

/* ============================================
   🌐 VARIABLES CSS RESPONSIVE UNIVERSALES
   ============================================ */
:root {
  /* Breakpoints universales */
  --xs-screen: 480px;
  --sm-screen: 768px;
  --md-screen: 1024px;
  --lg-screen: 1200px;
  --xl-screen: 1440px;
  --xxl-screen: 1920px;
  
  /* Espaciado responsive */
  --spacing-xs: clamp(4px, 1vw, 8px);
  --spacing-sm: clamp(8px, 2vw, 16px);
  --spacing-md: clamp(12px, 3vw, 24px);
  --spacing-lg: clamp(16px, 4vw, 32px);
  --spacing-xl: clamp(20px, 5vw, 40px);
  --spacing-xxl: clamp(24px, 6vw, 48px);
  
  /* Tamaños de fuente responsive */
  --font-xs: clamp(0.8125rem, 2vw, 0.875rem);
  --font-sm: clamp(0.875rem, 2.5vw, 1rem);
  --font-md: clamp(1rem, 3vw, 1.125rem);
  --font-lg: clamp(1.125rem, 3.5vw, 1.25rem);
  --font-xl: clamp(1.25rem, 4vw, 1.5rem);
  --font-xxl: clamp(1.5rem, 5vw, 2rem);
  
  /* Contenedores responsive */
  --container-xs: 100%;
  --container-sm: 100%;
  --container-md: 95%;
  --container-lg: 90%;
  --container-xl: 85%;
  --container-xxl: 80%;
  
  /* Menú responsive */
  --menu-collapsed: clamp(50px, 8vw, 85px);
  --menu-expanded: clamp(220px, 25vw, 300px);
  
  /* Modal responsive */
  --modal-width-xs: 95vw;
  --modal-width-sm: 90vw;
  --modal-width-md: 80vw;
  --modal-width-lg: 70vw;
  --modal-width-xl: 60vw;
  --modal-width-xxl: 50vw;

  /* Escala de z-index normalizada */
  --z-table-header: 10;
  --z-menu: 100;
  --z-menu-toggle: 200;
  --z-connection: 300;
  --z-notification: 400;
  --z-modal: 500;
  --z-modal-overlay: 600;
  --z-confirm-modal: 700;
  --z-logout-btn: 800;
  --z-toast: 900;
  --z-logout-modal: 950;
  --z-splash: 1000;
  --z-skip-link: 1100;
  --z-debug: 1200;
}

/* ============================================
   📱 BASE STYLES - Mobile First
   ============================================ */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--font-sm);
  line-height: 1.5;
  overflow-x: hidden;
}

/* Reset responsive para elementos media */
img, svg, video, canvas, picture {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ============================================
   🏗️ LAYOUT RESPONSIVE UNIVERSAL
   ============================================ */

/* Contenedor principal */
.main-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Menú lateral responsive */
.menu {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--menu-collapsed);
  background: var(--bg-color);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: var(--z-menu, 100);
  overflow: hidden;
  border-right: 1px solid rgba(166, 160, 143, 0.2);
}

.menu.expanded {
  width: var(--menu-expanded);
}

.menu-content {
  list-style: none;
  margin: 0;
  padding: var(--spacing-sm) 0;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.menu-content::-webkit-scrollbar {
  display: none;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--text-color);
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
  border-radius: 12px;
  margin: var(--spacing-xs) var(--spacing-sm);
  position: relative;
  overflow: hidden;
}

.menu-item:hover {
  background: rgba(166, 160, 143, 0.15);
  transform: translateX(8px);
}

.menu-item.active {
  background: var(--button-gradient);
  box-shadow: 0 4px 20px rgba(82, 89, 27, 0.3);
}

.menu-icon {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  margin-right: var(--spacing-sm);
  min-width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-text {
  font-size: var(--font-sm);
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease 0.1s;
  white-space: nowrap;
}

.menu.expanded .menu-text {
  opacity: 1;
}

/* Contenido principal */
.main-content {
  margin-left: var(--menu-collapsed);
  padding: var(--spacing-md);
  width: calc(100% - var(--menu-collapsed));
  min-height: 100vh;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--bg-color);
}

.menu.expanded + .main-content {
  margin-left: var(--menu-expanded);
  width: calc(100% - var(--menu-expanded));
}

/* ============================================
   📋 FORMULARIOS RESPONSIVE
   ============================================ */

.form-container {
  max-width: 100%;
  margin: 0 auto;
  padding: var(--spacing-md);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.form-group label {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: var(--spacing-xs);
}

.form-control {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 2px solid var(--input-border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text-color);
  font-size: var(--font-sm);
  transition: all 0.3s ease;
  width: 100%;
  min-height: 44px; /* Touch target minimum */
}

.form-control:focus {
  outline: 2px solid transparent;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(166, 160, 143, 0.1);
}

/* ============================================
   🔘 BOTONES RESPONSIVE
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: 12px;
  font-size: var(--font-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 44px; /* Touch target minimum */
  gap: var(--spacing-xs);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.5s;
}

.btn:hover:before {
  left: 100%;
}

.btn-primary {
  background: var(--button-gradient);
  color: white;
}

.btn-primary:hover {
  background: var(--button-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(82, 89, 27, 0.3);
}

.btn-group {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  align-items: center;
}

/* ============================================
   📊 TABLAS RESPONSIVE
   ============================================ */

.table-container {
  background: var(--card-bg);
  border-radius: 16px;
  overflow: hidden;
  margin: var(--spacing-lg) 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(166, 160, 143, 0.1);
}

.table-header {
  padding: var(--spacing-lg);
  background: rgba(82, 89, 27, 0.1);
  border-bottom: 1px solid rgba(166, 160, 143, 0.1);
}

.table-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.table-responsive {
  overflow-x: auto;
  max-height: 70vh;
  scrollbar-width: thin;
  scrollbar-color: rgba(166, 160, 143, 0.3) transparent;
}

.table-responsive::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: rgba(166, 160, 143, 0.1);
}

.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(166, 160, 143, 0.3);
  border-radius: 4px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-sm);
}

.table th,
.table td {
  padding: var(--spacing-md);
  text-align: left;
  border-bottom: 1px solid rgba(166, 160, 143, 0.1);
  color: var(--text-color);
  vertical-align: middle;
}

.table th {
  background: rgba(82, 89, 27, 0.1);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: var(--z-table-header, 10);
}

.table tbody tr:hover {
  background: rgba(166, 160, 143, 0.05);
}

/* ============================================
   🏷️ MODALES RESPONSIVE
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-overlay, 600);
  padding: var(--spacing-md);
}

.modal-content {
  background: var(--bg-color);
  border-radius: 20px;
  border: 1px solid rgba(166, 160, 143, 0.2);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: var(--modal-width-xs);
  max-width: 600px;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid rgba(166, 160, 143, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: 8px;
  transition: background 0.3s ease;
}

.modal-close:hover {
  background: rgba(166, 160, 143, 0.1);
}

.modal-body {
  padding: var(--spacing-lg);
}

.modal-footer {
  padding: var(--spacing-lg);
  border-top: 1px solid rgba(166, 160, 143, 0.1);
  display: flex;
  gap: var(--spacing-sm);
  justify-content: flex-end;
}

/* ============================================
   🎯 BREAKPOINTS RESPONSIVE
   ============================================ */

/* 📱 EXTRA SMALL DEVICES (max-width: 479px) - Teléfonos pequeños */
@media (max-width: 479px) {
  :root {
    --menu-collapsed: 50px;
    --menu-expanded: 220px;
  }
  
  .main-content {
    margin-left: var(--menu-collapsed);
    width: calc(100% - var(--menu-collapsed));
    padding: var(--spacing-sm);
  }
  
  .form-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
  }
  
  .btn-group {
    flex-direction: column;
    width: 100%;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .table th,
  .table td {
    padding: var(--spacing-sm);
    font-size: var(--font-xs);
  }
  
  .modal-content {
    width: var(--modal-width-xs);
    margin: var(--spacing-sm);
  }
}

/* 📱 SMALL DEVICES (480px - 767px) - Teléfonos grandes */
@media (min-width: 480px) and (max-width: 767px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }
  
  .btn-group {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .modal-content {
    width: var(--modal-width-sm);
  }
}

/* 📟 MEDIUM DEVICES (768px - 1023px) - Tablets */
@media (min-width: 768px) and (max-width: 1023px) {
  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
  }
  
  .main-content {
    padding: var(--spacing-lg);
  }
  
  .modal-content {
    width: var(--modal-width-md);
  }
}

/* 💻 LARGE DEVICES (1024px - 1199px) - Laptops pequeñas */
@media (min-width: 1024px) and (max-width: 1199px) {
  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
  }
  
  .modal-content {
    width: var(--modal-width-lg);
  }
}

/* 🖥️ EXTRA LARGE DEVICES (1200px - 1439px) - Laptops grandes */
@media (min-width: 1200px) and (max-width: 1439px) {
  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--spacing-lg);
  }
  
  .main-content {
    padding: var(--spacing-xl);
  }
  
  .modal-content {
    width: var(--modal-width-xl);
  }
}

/* 🖥️ XXL DEVICES (1440px - 1919px) - Monitores */
@media (min-width: 1440px) and (max-width: 1919px) {
  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-xl);
  }
  
  .modal-content {
    width: var(--modal-width-xxl);
  }
}

/* 📺 ULTRA WIDE DEVICES (min-width: 1920px) - Monitores grandes y Smart TVs */
@media (min-width: 1920px) {
  .main-content {
    max-width: 1800px;
    margin-left: auto;
    margin-right: auto;
    padding: var(--spacing-xxl);
  }
  
  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: var(--spacing-xxl);
  }
  
  .modal-content {
    width: 50vw;
    max-width: 800px;
  }
}

/* ============================================
   🎯 UTILIDADES RESPONSIVE
   ============================================ */

/* Clases de visibilidad */
.hide-xs { display: none !important; }
.hide-sm { display: none !important; }
.hide-md { display: none !important; }
.hide-lg { display: none !important; }
.hide-xl { display: none !important; }

@media (min-width: 480px) { .hide-xs { display: block !important; } }
@media (min-width: 768px) { .hide-sm { display: block !important; } }
@media (min-width: 1024px) { .hide-md { display: block !important; } }
@media (min-width: 1200px) { .hide-lg { display: block !important; } }
@media (min-width: 1440px) { .hide-xl { display: block !important; } }

/* Mostrar solo en dispositivos específicos */
.show-xs { display: none !important; }
.show-sm { display: none !important; }
.show-md { display: none !important; }
.show-lg { display: none !important; }
.show-xl { display: none !important; }

@media (max-width: 479px) { .show-xs { display: block !important; } }
@media (min-width: 480px) and (max-width: 767px) { .show-sm { display: block !important; } }
@media (min-width: 768px) and (max-width: 1023px) { .show-md { display: block !important; } }
@media (min-width: 1024px) and (max-width: 1199px) { .show-lg { display: block !important; } }
@media (min-width: 1200px) { .show-xl { display: block !important; } }

/* Clases de espaciado responsive */
.p-responsive { padding: var(--spacing-md); }
.m-responsive { margin: var(--spacing-md); }
.gap-responsive { gap: var(--spacing-md); }

/* Contenedores responsivos */
.container-fluid {
  width: 100%;
  padding: 0 var(--spacing-md);
}

.container {
  max-width: var(--container-lg);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* ============================================
   🏦 INDICADORES DE ESTADO RESPONSIVE
   ============================================ */

.estado-activa,
.estado-inactiva {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: 20px;
  font-size: var(--font-xs);
  font-weight: 600;
  white-space: nowrap;
}

.estado-activa {
  background: rgba(76, 175, 80, 0.15);
  color: #4CAF50;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.estado-inactiva {
  background: rgba(244, 67, 54, 0.15);
  color: #F44336;
  border: 1px solid rgba(244, 67, 54, 0.3);
}

/* ============================================
   🎨 ANIMACIONES Y TRANSICIONES
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   📱 PWA Y TOUCH OPTIMIZATIONS
   ============================================ */

/* Touch targets mínimos */
button, .btn, .menu-item, .form-control {
  min-height: 44px;
  min-width: 44px;
}

/* Optimización para PWA */
@supports (-webkit-touch-callout: none) {
  .main-content {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .menu {
    padding-top: env(safe-area-inset-top);
  }
}

/* Scroll suave */
html {
  scroll-behavior: smooth;
}

/* Optimización de scroll en iOS */
.table-responsive,
.modal-content {
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   🔍 MEJORAS DE ACCESIBILIDAD
   ============================================ */

/* Focus visible mejorado */
.btn:focus-visible,
.form-control:focus-visible,
.menu-item:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Contraste mejorado para textos pequeños */
@media (max-width: 767px) {
  .table th,
  .table td {
    font-weight: 500;
  }
}

/* Mejoras para modo oscuro */
@media (prefers-color-scheme: dark) {
  :root {
    --text-color: #FFFFFF;
    --bg-color: linear-gradient(135deg, #1E260C 0%, #34401A 50%, #52591B 100%);
  }
}
