/* ============================================
   ESTILOS RESPONSIVOS PARA MÓVIL
   Optimizado para pantallas pequeñas
   ============================================ */

/* VARIABLES CSS */
:root {
  --color-primary: #10b981;
  --color-primary-dark: #059669;
  --color-gold: #d6b25e;
  --color-dark: rgba(10, 16, 26, 0.95);
  --color-dark-lighter: rgba(10, 16, 26, 0.88);
  --sidebar-width: 260px;
  --sidebar-width-mobile: 280px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   MOBILE MENU (HAMBURGER)
   ============================================ */

.menu-toggle {
  display: none;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 200;
  background: rgba(16, 185, 129, 0.1);
  border: 2px solid var(--color-primary);
  border-radius: 12px;
  width: 50px;
  height: 50px;
  padding: 0;
  cursor: pointer;
  transition: var(--transition);
  align-items: center;
  justify-content: center;
}

.menu-toggle:hover {
  background: rgba(16, 185, 129, 0.2);
  transform: scale(1.05);
}

.menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-primary);
  margin: 5px 0;
  transition: var(--transition);
  border-radius: 2px;
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(10px, 10px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

/* ============================================
   SIDEBAR - RESPONSIVE
   ============================================ */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-dark);
  border-right: 1px solid rgba(16, 185, 129, 0.12);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  z-index: 150;
  transition: var(--transition);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
}

.sidebar-overlay.active {
  opacity: 1;
  display: block;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content,
.dashboard-page {
  margin-left: var(--sidebar-width);
  transition: var(--transition);
}

/* ============================================
   CONTAINERS & GRIDS - RESPONSIVE
   ============================================ */

.container {
  width: 100%;
  padding: 16px;
  margin: 0 auto;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

/* Grid responsivo: 3 columnas en escritorio, 2 en tablet, 1 en móvil */
.grid-col-3 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Grid responsivo: 2 columnas en escritorio, 1 en tablet/móvil */
.grid-col-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card {
  background: rgba(30, 40, 60, 0.4);
  border: 1px solid rgba(16, 185, 129, 0.1);
  border-radius: 16px;
  padding: 16px;
  transition: var(--transition);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(16, 185, 129, 0.3);
}

/* ============================================
   TYPOGRAPHY - RESPONSIVE
   ============================================ */

h1 {
  font-size: clamp(24px, 5vw, 36px);
  line-height: 1.2;
  margin-bottom: 16px;
}

h2 {
  font-size: clamp(20px, 4vw, 28px);
  line-height: 1.3;
  margin-bottom: 12px;
}

h3 {
  font-size: clamp(16px, 3vw, 22px);
  line-height: 1.4;
  margin-bottom: 10px;
}

p, span, label {
  font-size: clamp(13px, 2vw, 16px);
  line-height: 1.5;
}

/* ============================================
   BUTTONS - RESPONSIVE
   ============================================ */

.btn {
  padding: 12px 20px !important;
  border-radius: 10px;
  font-size: clamp(12px, 2vw, 14px);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px; /* iOS touch target */
  font-weight: 600;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(16, 185, 129, 0.2);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-small {
  padding: 8px 12px !important;
  font-size: 12px;
  min-height: auto;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* ============================================
   FORMS - RESPONSIVE
   ============================================ */

input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(16, 185, 129, 0.2);
  background: rgba(243, 245, 255, 0.05);
  color: rgb(243, 245, 255);
  font-size: 16px; /* Previene zoom en iOS */
  transition: var(--transition);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  background: rgba(243, 245, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-right: 8px;
  cursor: pointer;
}

/* ============================================
   TABLES - RESPONSIVE
   ============================================ */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scroll en iOS */
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(12px, 2vw, 14px);
}

th {
  background: rgba(16, 185, 129, 0.1);
  padding: 12px;
  text-align: left;
  border-bottom: 2px solid rgba(16, 185, 129, 0.2);
  font-weight: 600;
}

td {
  padding: 12px;
  border-bottom: 1px solid rgba(16, 185, 129, 0.1);
}

tr:hover {
  background: rgba(16, 185, 129, 0.05);
}

/* ============================================
   MODALS - RESPONSIVE
   ============================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 300;
  animation: slideUp 0.3s ease-out;
}

.modal-content {
  background: var(--color-dark);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  max-width: 600px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(16, 185, 129, 0.1);
  padding-bottom: 12px;
}

.modal-close {
  background: none;
  border: none;
  color: rgba(243, 245, 255, 0.7);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-primary);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================
   FLEX & SPACING - RESPONSIVE
   ============================================ */

.flex {
  display: flex;
  gap: 12px;
}

.flex-center {
  justify-content: center;
  align-items: center;
}

.flex-between {
  justify-content: space-between;
  align-items: center;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }

.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }

.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

.px-12 { padding-left: 12px; padding-right: 12px; }
.px-16 { padding-left: 16px; padding-right: 16px; }

/* ============================================
   MEDIA QUERIES
   ============================================ */

/* TABLET: 768px y menos */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0;
  }

  .menu-toggle {
    display: flex;
  }

  .sidebar {
    width: var(--sidebar-width-mobile);
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-content,
  .dashboard-page {
    margin-left: 0;
  }

  .container {
    padding: 12px;
  }

  .grid {
    gap: 12px;
  }

  .grid-col-3 {
    grid-template-columns: 1fr;
  }

  .grid-col-2 {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 12px;
  }

  h1 {
    font-size: 22px;
    margin-bottom: 12px;
  }

  h2 {
    font-size: 18px;
    margin-bottom: 10px;
  }

  h3 {
    font-size: 16px;
    margin-bottom: 8px;
  }

  .btn {
    padding: 10px 16px !important;
    font-size: 13px;
    min-height: 42px;
  }

  .modal-content {
    border-radius: 16px 16px 0 0;
    padding: 16px;
  }

  /* Esconder columnas menos importantes en tablas */
  table thead th:nth-child(n+4),
  table tbody td:nth-child(n+4) {
    display: none;
  }
}

/* MÓVIL PEQUEÑO: 480px y menos */
@media (max-width: 480px) {
  :root {
    --sidebar-width-mobile: 100vw;
  }

  .sidebar {
    width: 100vw;
  }

  .menu-toggle {
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
  }

  .container {
    padding: 10px;
  }

  .btn {
    padding: 10px 14px !important;
    font-size: 12px;
    min-height: 40px;
  }

  .btn-small {
    padding: 6px 10px !important;
    font-size: 11px;
  }

  h1 {
    font-size: 20px;
  }

  h2 {
    font-size: 16px;
  }

  input, textarea, select {
    font-size: 16px; /* Importante: previene zoom en iOS */
    padding: 10px 12px;
  }

  .flex {
    gap: 8px;
  }

  .card {
    padding: 10px;
  }

  th, td {
    padding: 8px;
  }

  .modal-content {
    padding: 12px;
    border-radius: 12px 12px 0 0;
  }

  .modal-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  /* Mostrar solo 2 columnas en móvil */
  table thead th:nth-child(n+3),
  table tbody td:nth-child(n+3) {
    display: none;
  }

  /* Stack todos los elementos flex */
  .flex:not(.flex-col) {
    flex-direction: column;
  }

  /* Botones a ancho completo */
  .btn-block,
  .btn:last-child {
    width: 100%;
  }
}

/* LANDSCAPE: Ajustes para modo horizontal */
@media (max-height: 600px) and (orientation: landscape) {
  .sidebar {
    width: 180px;
  }

  .main-content,
  .dashboard-page {
    margin-left: 180px;
  }

  .container {
    padding: 8px;
  }

  .card {
    padding: 8px;
  }

  h1, h2, h3 {
    margin-bottom: 4px;
  }

  .btn {
    padding: 6px 12px !important;
    font-size: 12px;
    min-height: 36px;
  }
}

/* PRINT STYLES */
@media print {
  .menu-toggle,
  .sidebar,
  .sidebar-overlay {
    display: none !important;
  }

  .main-content,
  .dashboard-page {
    margin-left: 0;
  }

  .card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
