/* ==== Reset y Variables ==== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --secondary: #64748b;
  --dark: #0f172a;
  --light: #f8fafc;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --transition: all 0.3s ease;
  --nav-height: 70px;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ==== HTML y Body ==== */
html {
  scroll-behavior: smooth;
  font-size: 16px;
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--gray-800);
  background-color: var(--light);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  padding-top: var(--nav-height); /* ✅ Espacio para el nav fijo */
}

/* ==== Tipografía ==== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--gray-900);
  margin-bottom: 1rem;
  word-wrap: break-word;
}

h1 {
  font-size: clamp(1.875rem, 5vw, 3rem);
  letter-spacing: -0.025em;
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  letter-spacing: -0.025em;
}

h3 {
  font-size: clamp(1.25rem, 3vw, 1.875rem);
}

h4 {
  font-size: clamp(1.125rem, 2.5vw, 1.5rem);
}

h5 {
  font-size: clamp(1rem, 2vw, 1.25rem);
}

h6 {
  font-size: 1rem;
}

p {
  margin-bottom: 1rem;
  line-height: 1.75;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ==== Enlaces ==== */
a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

a:hover {
  color: var(--primary);
}

/* ==== Imágenes ==== */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ==== Botones ==== */
button,
.btn {
  display: inline-block;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  border: 1px solid transparent;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 0.5rem;
  transition: var(--transition);
  cursor: pointer;
}

button:focus,
.btn:focus {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* ==== Formularios ==== */
input,
textarea,
select {
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  width: 100%;
  max-width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: 0.5rem;
  transition: var(--transition);
  background-color: var(--white);
  color: var(--gray-800);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--gray-600);
  opacity: 0.7;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* ==== Details y Summary ==== */
details {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 100%;
}

details:hover {
  box-shadow: var(--shadow-md);
}

details[open] {
  background: var(--gray-50);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

details summary {
  position: relative;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.125rem;
  padding-right: 2.5rem;
  list-style: none;
  outline: none;
  color: var(--gray-900);
  user-select: none;
  word-wrap: break-word;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  color: var(--primary);
  transition: var(--transition);
}

details[open] summary::after {
  content: "−";
  transform: translateY(-50%) rotate(180deg);
  color: var(--primary-dark);
}

details summary:hover {
  color: var(--primary);
}

/* Contenido del details */
details > *:not(summary) {
  margin-top: 1rem;
  animation: fadeIn 0.3s ease-in-out;
  word-wrap: break-word;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== NAV Responsivo ===== */
nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  backdrop-filter: blur(10px);
  background-color: rgba(15, 23, 42, 0.95);
  padding: 1rem;
  z-index: 1000;
  min-height: var(--nav-height);
  box-shadow: var(--shadow-md);
}

nav .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  max-width: 100%;
}

nav .links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

nav a {
  position: relative;
  padding: 0.5rem 0.75rem;
  display: inline-block;
  color: var(--white);
  white-space: nowrap;
}

nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--primary-light);
  transition: width 0.3s ease;
}

nav a:hover::after {
  width: 100%;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 1001;
  position: relative;
}

/* ==== Cards ==== */
.card {
  background: var(--white);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
  width: 100%;
  max-width: 100%;
}

.card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-4px);
}

/* ==== Secciones ==== */
section {
  padding: 5rem 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

/* ==== Utilidades de texto ==== */
.text-primary {
  color: var(--primary) !important;
}

.text-secondary {
  color: var(--secondary) !important;
}

.text-muted {
  color: var(--gray-600) !important;
}

.text-white {
  color: var(--white) !important;
}

.text-center {
  text-align: center !important;
}

.text-left {
  text-align: left !important;
}

.text-right {
  text-align: right !important;
}

/* ==== Utilidades de fondo ==== */
.bg-primary {
  background-color: var(--primary) !important;
}

.bg-white {
  background-color: var(--white) !important;
}

.bg-light {
  background-color: var(--light) !important;
}

.bg-gray-50 {
  background-color: var(--gray-50) !important;
}

/* ==== Utilidades de bordes ==== */
.rounded {
  border-radius: 0.5rem !important;
}

.rounded-lg {
  border-radius: 0.75rem !important;
}

.rounded-xl {
  border-radius: 1rem !important;
}

.rounded-full {
  border-radius: 9999px !important;
}

/* ==== Utilidades de sombras ==== */
.shadow-sm {
  box-shadow: var(--shadow-sm) !important;
}

.shadow {
  box-shadow: var(--shadow) !important;
}

.shadow-md {
  box-shadow: var(--shadow-md) !important;
}

.shadow-lg {
  box-shadow: var(--shadow-lg) !important;
}

.shadow-xl {
  box-shadow: var(--shadow-xl) !important;
}

/* ==== Animaciones ==== */
.fade-in {
  animation: fadeIn 0.5s ease-in-out;
}

.slide-up {
  animation: slideUp 0.5s ease-in-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==== Transiciones suaves ==== */
.transition {
  transition: var(--transition);
}

/* ==== Hover effects ==== */
.hover-lift {
  transition: var(--transition);
}

.hover-lift:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
}

/* ==== RESPONSIVE MÓVIL ==== */
@media (max-width: 768px) {
  :root {
    --nav-height: auto;
  }

  body {
    padding-top: 60px; /* Ajuste para nav móvil */
  }

  nav {
    padding: 0.75rem 1rem;
  }

  nav .container {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  nav .links {
    display: none;
    flex-direction: column;
    width: 100%;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: rgba(15, 23, 42, 0.98);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    gap: 0;
  }

  nav .links.active {
    display: flex;
  }

  .menu-toggle {
    display: block;
  }

  nav a {
    padding: 0.75rem 1rem;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  nav a:last-child {
    border-bottom: none;
  }

  section {
    padding: 3rem 0;
  }

  .container {
    padding: 0 1rem;
  }

  details {
    padding: 1rem;
  }

  details summary {
    font-size: 1rem;
    padding-right: 2rem;
  }

  details summary::after {
    font-size: 1.25rem;
  }

  .card {
    padding: 1.25rem;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  body {
    padding-top: 55px;
  }

  nav {
    padding: 0.5rem 0.75rem;
  }

  .container {
    padding: 0 0.75rem;
  }

  section {
    padding: 2rem 0;
  }

  details {
    padding: 0.875rem;
  }

  .card {
    padding: 1rem;
  }

  button,
  .btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
  }
}

/* ==== Scrollbar personalizado ==== */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ==== Loading States ==== */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ==== Mensajes de éxito/error ==== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-weight: 500;
  word-wrap: break-word;
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--success);
  color: #065f46;
}

.alert-error {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  color: #991b1b;
}

.alert-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--warning);
  color: #92400e;
}

/* ==== Badges ==== */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  color: var(--white);
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.375rem;
}

.badge-primary {
  background-color: var(--primary);
}

.badge-success {
  background-color: var(--success);
}

/* ==== Accesibilidad ==== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==== Focus visible para teclado ==== */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ==== Print styles ==== */
@media print {
  nav,
  footer,
  .no-print {
    display: none !important;
  }

  body {
    color: #000;
    background: #fff;
    padding-top: 0;
  }

  a {
    text-decoration: underline;
  }
}

/* ========================================
   BOTONES RESPONSIVE - FIX
   ======================================== */

/* Grupo de botones general */
.button-group,
.text-center.space-x-4,
form .text-center {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

/* Reset de space-x en móvil */
@media (max-width: 640px) {
  .text-center.space-x-4,
  form .text-center {
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
  }
  
  .text-center.space-x-4 > *,
  form .text-center > * {
    width: 100%;
    margin: 0 !important;
  }
  
  /* Botones y enlaces ocupan todo el ancho en móvil */
  .text-center.space-x-4 button,
  .text-center.space-x-4 a,
  form .text-center button,
  form .text-center a {
    width: 100%;
    display: block;
    text-align: center;
    padding: 0.75rem 1.5rem;
  }
}

/* Tablet - 2 botones por fila */
@media (min-width: 641px) and (max-width: 768px) {
  .text-center.space-x-4,
  form .text-center {
    gap: 0.75rem;
  }
  
  .text-center.space-x-4 > *,
  form .text-center > * {
    flex: 1;
    min-width: calc(50% - 0.5rem);
  }
}

/* Desktop - Disposición horizontal */
@media (min-width: 769px) {
  .text-center.space-x-4,
  form .text-center {
    flex-direction: row;
    gap: 1rem;
  }
  
  .text-center.space-x-4 > *,
  form .text-center > * {
    flex: 0 0 auto;
    width: auto;
  }
}

/* Estilos base para botones */
button,
.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  border: 1px solid transparent;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 0.5rem;
  transition: all 0.3s ease;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px; /* Mínimo táctil para móviles */
}

/* Botón primario (azul) */
button[type="submit"],
.bg-blue-600 {
  background-color: #2563eb;
  color: white;
  border-color: #2563eb;
}

button[type="submit"]:hover,
.bg-blue-600:hover {
  background-color: #1d4ed8;
  border-color: #1d4ed8;
}

button[type="submit"]:active {
  background-color: #1e40af;
  transform: scale(0.98);
}

/* Botón reset/secundario (gris) */
button[type="reset"],
.bg-gray-200 {
  background-color: #e5e7eb;
  color: #1f2937;
  border-color: #e5e7eb;
}

button[type="reset"]:hover,
.bg-gray-200:hover {
  background-color: #d1d5db;
  border-color: #d1d5db;
}

button[type="reset"]:active {
  background-color: #cbd5e1;
  transform: scale(0.98);
}

/* Botón cancelar/outline */
a.border,
.border.border-blue-600 {
  background-color: white;
  color: #2563eb;
  border: 1px solid #2563eb;
}

a.border:hover,
.border.border-blue-600:hover {
  background-color: #f3f4f6;
  color: #1d4ed8;
  border-color: #1d4ed8;
}

a.border:active {
  background-color: #e5e7eb;
  transform: scale(0.98);
}

/* Estados de focus para accesibilidad */
button:focus,
a:focus {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

/* Botón deshabilitado */
button:disabled,
button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Transiciones suaves */
button,
a.btn,
a.border {
  transition: all 0.2s ease-in-out;
}

/* Clase helper para grupos de botones */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

@media (max-width: 640px) {
  .btn-group {
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
  }
  
  .btn-group > * {
    width: 100%;  
  }
}