/* ========================================
   Variables CSS - Paleta Elegante Neutra
   ======================================== */
:root {
  /* --- Functional Theme Variables (Light) --- */
  --bg-main: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  --bg-card: linear-gradient(135deg, var(--off-white), var(--lighter-gray));
  --bg-header: linear-gradient(135deg, var(--pure-white), var(--off-white));
  --text-primary: var(--dark-charcoal);
  --text-secondary: var(--slate-gray);
  --border-main: var(--border-gray);
  --border-subtle: #f1f5f9;
  --progress-track-bg: var(--lighter-gray);
  --glass-bg: rgba(255, 255, 255, 0.9);
  --card-shadow: var(--shadow-medium);

  /* Base Tokens - Light Theme */
  --dark-charcoal: #1e293b;
  --slate-gray: #64748b;
  --border-gray: #e2e8f0;
  --pure-white: #ffffff;
  --off-white: #f8fafc;
  --lighter-gray: #f1f5f9;
  --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

  /* Progress Palette - Restoration */
  --prog-coral: #FF7F50;     /* 0% - 20% */
  --prog-amber: #FFBF00;     /* 21% - 50% */
  --prog-cobalt: #2563eb;    /* 51% - 85% */
  --prog-turquoise: #00CED1; /* 86% - 99% */
  --prog-forest: #228B22;    /* 100% */
  
  /* Fallbacks */
  --accent-blue: #2563eb;
  --accent-purple: #7c3aed;
  --accent-green: #059669;

  /* Process Phase Colors */
  --mvp-color: #fbbf24;    /* Warm Amber/Yellow */
  --spiral-color: #a855f7; /* Vibrant Purple */
  --vmodel-color: #10b981; /* Fresh Emerald Green */
  --light-cream: #fdfbf7;  /* Soft cream for contrast */
}

/* ========================================
   Dark Theme - Midnight Palette
   ======================================== */
body.dark-theme {
  --bg-main: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --bg-card: linear-gradient(135deg, #1e293b, #334155);
  --bg-header: linear-gradient(135deg, #0f172a, #1e293b);
  --text-primary: #f1f5f9;  /* Blanco grisáceo fresco */
  --text-secondary: #94a3b8; /* Gris azulado suave */
  --border-main: #475569;   /* Visible grey line */
  --border-subtle: #334155; /* Hidden grey line */
  --progress-track-bg: #334155;
  --glass-bg: rgba(15, 23, 42, 0.92);
  --card-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  
  /* Overrides for specific color tokens */
  --dark-charcoal: #f1f5f9;
  --slate-gray: #94a3b8;
  --border-gray: #334155;
  --pure-white: #1e293b;
  --off-white: #0f172a;
  --lighter-gray: #334155;
  --light-cream: #1e293b; /* Dark equivalent */

  /* Process Overrides - Dark Premium */
  --mvp-color: #f59e0b;
  --spiral-color: #a855f7;
  --vmodel-color: #34d399;
}

/* ========================================
   Reset y Base
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Prevent iOS Zoom */
input,
select,
textarea {
  font-size: 16px !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Inter", sans-serif;
  color: var(--text-primary);
  background: var(--bg-main);
  transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Allow scroll on small heights/widths to prevent squashing */
@media (max-height: 700px), (max-width: 480px) {
  body {
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
  }
}

/* ========================================
   Header
   ======================================== */
.header-section {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 20px;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, transparent, #00ced1, #4c63d2, transparent) 1;
  box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.1);
  transition: background 0.4s ease, border-image 0.4s ease;
}

.header-controls-mobile {
  display: none;
}

.header-section::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 206, 209, 0.3) 20%,
    rgba(76, 99, 210, 0.3) 50%,
    rgba(0, 206, 209, 0.3) 80%,
    transparent 100%
  );
  filter: blur(4px);
  pointer-events: none;
}

/* OVERLAY PARA EL MENÚ MÓVIL */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.header-section.menu-open ~ .image-section,
.header-section.menu-open ~ .content-container {
  pointer-events: none;
  filter: blur(4px);
  transition: filter 0.4s ease;
}

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

body.menu-active {
  overflow: hidden; /* Evita el scroll cuando el menú está abierto */
}

.title {
  font-size: 2.8rem;
  font-weight: 600;
  font-family: "Playfair Display", serif;
  margin-bottom: 8px;
  letter-spacing: -0.025em;
  text-shadow:
    0 1px 2px rgba(255, 255, 255, 0.8),
    0 1px 3px rgba(0, 0, 0, 0.05);
}

.subtitle {
  font-size: 1.1rem;
  font-weight: 400;
  margin-bottom: 32px;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  transition: color 0.4s ease;
}

/* ========================================
   Menu
   ======================================== */
.menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 28px;
}

.menu-item {
  font-size: 1rem;
  font-weight: 500;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  position: relative;
  transition: var(--transition);
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  box-shadow: var(--shadow-light);
}

.menu-item:hover {
  color: var(--medium-gray);
  transform: translateY(-1px);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.06),
    0 2px 4px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.menu-item::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 16px;
  width: calc(100% - 32px);
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  border-radius: 2px;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left center;
  transition:
    opacity 0.3s ease-out,
    transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.menu-item:hover::after,
.menu-item.active::after {
  opacity: 1;
  transform: scaleX(1);
}

.menu-item.active {
  color: var(--dark-charcoal);
  font-weight: 600;
}

.cv-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 15px;
  background-color: var(--dark-charcoal);
  color: var(--pure-white) !important;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.3s ease;
  margin-left: 20px;
  border: 1px solid transparent;
}

.cv-button:hover {
  background-color: transparent;
  color: var(--dark-charcoal) !important;
  border-color: var(--dark-charcoal);
  transform: translateY(-2px);
}

/* ========================================
   Common Content Containers
   ======================================== */
.image-section {
  background: linear-gradient(
    135deg,
    var(--lighter-gray) 0%,
    var(--border-gray) 100%
  );
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
}

.image-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(
      circle at 20% 80%,
      rgba(102, 126, 234, 0.04) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(118, 75, 162, 0.04) 0%,
      transparent 50%
    );
  pointer-events: none;
}

.image-section::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  pointer-events: none;
}

.content-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.content-section {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100%;
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.5s ease,
    transform 0.5s ease;
  pointer-events: none;

  display: flex;
  justify-content: center;
  align-items: center;
}

.content-section.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* ========================================
   Common Components (Impact Cards)
   ======================================== */
.impact-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.impact-card {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 12px;
  padding: 22px 20px 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: background 0.4s ease, border-color 0.4s ease, transform 0.25s ease;
}

.impact-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.impact-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  border-color: rgba(76, 99, 210, 0.25);
}

.impact-card:hover::before {
  opacity: 1;
}

.impact-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.impact-icon-wrap i {
  color: var(--pure-white);
  font-size: 1.1rem;
}

.impact-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark-charcoal);
  margin-bottom: 10px;
  line-height: 1.3;
}

.impact-card-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
  transition: color 0.4s ease;
}

.impact-card-text strong {
  color: var(--dark-charcoal);
  font-weight: 600;
}

.tag-active,
.badge {
  display: inline-block;
  padding: 6px 14px; /* Standardize specific to some badges */
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.tag-active {
  padding: 3px 10px; /* From about section override */
}

/* ========================================
   Common Responsive
   ======================================== */
@media (max-width: 768px) {
  .title {
    font-size: 2.2rem;
  }
  .subtitle {
    font-size: 1rem;
    margin-bottom: 24px;
  }
  .menu {
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .menu-item {
    font-size: 1.05rem;
    padding: 10px 14px;
  }
  .impact-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

@media (max-width: 480px) {
  .header-section {
    height: auto;
    padding: 24px 16px;
  }
  .image-section {
    height: auto;
    flex: 1; /* Take remaining space */
  }
  .title {
    font-size: 1.8rem;
  }
  .subtitle {
    font-size: 0.9rem;
    margin-bottom: 24px;
  }
  .header-controls-mobile {
    display: flex;
    justify-content: flex-start;
    width: auto;
    position: absolute;
    top: 80px;
    left: 10px;
  }
  .menu-toggle-btn {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-main);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    box-shadow: var(--shadow-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    z-index: 1001;
  }
  .menu-toggle-btn:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    transform: scale(1.05);
  }
  .menu {
    display: none; /* Hide by default on mobile */
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 60px;
    padding: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid var(--border-main);
    box-shadow: var(--shadow-strong);
    position: absolute;
    top: 110px;
    left: 0;
    z-index: 1000;
  }
  .header-section.menu-open .menu {
    display: flex;
    animation: slideDown 0.3s ease-out forwards;
  }
  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .menu-item {
    font-size: 1rem;
    padding: 14px 16px;
    width: 100%;
    justify-content: flex-start;
  }
  .cv-button {
    margin: 10px 0 0 0;
    justify-content: center;
    width: 100%;
    min-height: 48px;
  }

  .image-section {
    height: auto;
    min-height: 85vh; /* Ensure content area is tall enough */
    padding: 20px 0;
  }
  .content-section {
    align-items: flex-start; /* Prevent top cut-off on scroll */
    padding-top: 20px; /* Add some breathing room */
    height: auto; /* Let it grow */
    min-height: 100%;
    position: relative; /* Change from absolute to relative to stack? No, keeping absolute but letting it be tall */
    /* If absolute, strict 100% height clips it if parent is smaller than content? 
           But parent .image-section grows with content? No, .image-section has min-height.
           If content is taller than .image-section min-height, .image-section needs to grow.
           If .content-section is absolute, .image-section won't grow based on .content-section size.
           
           CRITICAL FIX: Change .content-section to position: relative on mobile so it pushes .image-section height! 
           But we have multiple .content-sections. Only the active one should be displayed relative?
           The others are hidden/opacity 0.
           If all are relative, they stack.
           We need only the active one to be relative (in flow) and others absolute (or hidden).
        */
  }
  .content-section.active {
    position: relative; /* Takes space in flow */
  }
  .content-section:not(.active) {
    display: none; /* Hide others to prevent stacking/spacing issues */
  }

  .contact-link {
    font-size: 0.9rem;
    padding: 10px 16px;
  }
  .impact-card {
    padding: 18px 16px 16px;
  }
}

/* ========================================
   PDF Viewer Modal
   ======================================== */
.pdf-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: none; /* Hidden by default */
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.pdf-modal-overlay.active {
  display: flex;
  opacity: 1;
}

.pdf-modal-content {
  position: relative;
  width: 90%;
  height: 90%;
  max-width: 1200px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.pdf-modal-overlay.active .pdf-modal-content {
  transform: scale(1);
}

.pdf-close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: rgba(255, 255, 255, 0.7);
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: #333;
  z-index: 10;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.pdf-close-btn:hover {
  background: rgba(255, 255, 255, 1);
}

#pdf-frame {
  width: 100%;
  height: 100%;
}

/* ========================================
   FIX DEFINITIVO: Espaciado Estandarizado Profesional
   Agregar al FINAL de css/global.css
   ======================================== */

/* Variables de Espaciado Profesional */
:root {
  --section-gap-desktop: 40px;
  --section-gap-tablet: 30px;
  --section-gap-mobile: 20px;
}

/* SOLUCIÓN BASE: Layout consistente */
.content-section {
  position: relative;
  width: 100%;
  height: auto;
  opacity: 0;
  display: none;
  transform: translateY(20px);
  transition:
    opacity 0.5s ease,
    transform 0.5s ease;
  pointer-events: none;
  padding: 0;
}

.content-section.active {
  opacity: 1;
  display: flex !important;
  justify-content: center;
  align-items: flex-start;
  transform: translateY(0);
  pointer-events: all;
}

/* Espaciado estandarizado para TODOS los paneles */
.home-panel,
.services-panel,
.contact-panel,
.about-container,
.process-container {
  margin: var(--section-gap-desktop) auto;
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--section-gap-desktop);
}

/* Asegurar centrado perfecto en desktop */
@media (min-width: 769px) {
  .image-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--section-gap-desktop) 0;
  }

  .content-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .content-section:not(.active) {
    display: none;
  }

  /* Ajuste específico para paneles con altura fija */
  .home-panel,
  .services-panel {
    width: 78%;
    max-width: 1200px;
  }

  .about-container,
  .process-container {
    width: 85%;
    max-width: 1200px;
  }
}

/* Tablet - Espaciado intermedio */
@media (max-width: 768px) {
  :root {
    --section-gap-desktop: var(--section-gap-tablet);
  }

  .image-section {
    padding: var(--section-gap-tablet) 0;
  }

  .home-panel,
  .services-panel,
  .about-container,
  .process-container {
    margin: var(--section-gap-tablet) auto;
  }
}

/* Mobile - Espaciado mínimo */
@media (max-width: 480px) {
  :root {
    --section-gap-desktop: var(--section-gap-mobile);
  }

  .image-section {
    min-height: 85vh;
    padding: var(--section-gap-mobile) 0;
  }

  .content-section.active {
    display: flex !important;
  }

  .content-section:not(.active) {
    display: none;
  }

  .home-panel,
  .services-panel,
  .about-container,
  .process-container {
    margin: var(--section-gap-mobile) auto;
    width: 95%;
  }
}

/* Fix específico para Contact que tenía padding-bottom problemático */
.contact-panel {
  padding-bottom: 0 !important;
  margin: var(--section-gap-desktop) auto;
}

/* Asegurar que Projects no se vea afectado */
.projects-wrapper {
  margin: var(--section-gap-desktop) auto;
}

/* ========================================
   Language Toggle Styles (Fixed Top Right)
   ======================================== */
.lang-toggle-fixed {
    position: absolute;
    top: 20px;
    right: 20px;
}

.lang-btn {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-main);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: var(--transition);
    box-shadow: var(--shadow-medium);
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-btn:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
}

.lang-btn i {
    font-size: 1rem;
}

.lang-btn.active {
  background: var(--dark-charcoal);
  color: var(--pure-white);
  border-color: var(--dark-charcoal);
}

@media (max-width: 480px) {
    .lang-toggle-fixed {
        top: 95px;
        right: 15px;
    }
    .lang-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

/* ========================================
   Theme Toggle Styles (Fixed Bottom Left)
   ======================================== */
.theme-toggle-fixed {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 48px;
    height: 48px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-main);
    color: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--card-shadow);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1001;
}

.theme-toggle-fixed:hover {
    transform: scale(1.1) rotate(15deg);
    background: var(--bg-card);
}

.theme-toggle-fixed:active {
    transform: scale(0.9);
}

@media (max-width: 480px) {
    .theme-toggle-fixed {
        bottom: 20px;
        left: 20px;
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }
}
