:root {
    --max-width:100%;
    /* Brand colors */
    --accent: #CC0000;
    --accent-dark: #990000;
    --muted:#6b6b6b;
    --bg:#ffffff;
    --card-bg:rgba(255,255,255,0.88);
    --radius:12px;
    --gap:32px;
    --container-padding:28px;
    --headline-weight:700;
    --primary-color:#1A1A1A;
    --primary-red-color: #CC0000;
    --secondary-color: #f8f9fa;
    --light-color: #E0E0E0;
    --grey-color: #343a40;
    --primary-font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    --heading-font: 'Poppins', 'Inter', ui-sans-serif, system-ui;
    --secondary-font: 'Georgia', 'Times New Roman', serif;
}

/* ===========================
   GLOBAL
   =========================== */
html,body{height:100%}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    max-width: 1600px;
    margin: 0 auto;
    background: #ccc;
}

body{
    line-height:1.30;  
    margin:0;
    font-family: var(--primary-font);
    color: var(--primary-color);
    background:var(--bg)
}

/* ===========================
   BODY PADDING
   =========================== */
body {
    padding-top: 100px;
}

.navbar.scrolled ~ * body {
    padding-top: 80px;
}

/* ===========================
   SECTION TITLES
   =========================== */
.section-title {
    position: relative;
    margin-bottom: 2.5rem;
    padding-bottom: 0.5rem;
    text-align: center;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background-color: var(--primary-red-color);
}

.section-title {
    font-size: 1.95rem!important;
    font-weight: 700;
    color: var(--grey-color);
    position: relative;
    padding-bottom: 15px;
}

.section-title:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background-color: var(--primary-red-color);
}

/* ===========================
   CARDS
   =========================== */
.card {
    transition: transform 0.3s, box-shadow 0.3s;
    border: none;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.card-img-top {
    height: 200px;
    object-fit: cover;
}

.card-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card .btn .btn-white {
    background: white!important;
}

.card .btn  .btn-white:hover {
    background: linear-gradient(45deg, #990000, #660000);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Fix card text spacing */
.card-text {
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

/* Fix button text spacing */
.btn {
  line-height: 1.1; /* Tighter line height for buttons */
  padding: 0.75rem 1.5rem;
}

/* Headings — Poppins */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--heading-font);
  line-height: 1.15;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

/* Specific fix for card titles */
.card-title {
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

/* Fix for buttons inside cards */
.card .btn {
  line-height: 1;
  padding: 0.6rem 1.25rem;
}

/* Additional fix for mobile */
@media (max-width: 768px) {
  body {
      line-height: 1.25; /* Slightly tighter on mobile */
  }
  
  .hero-section .lead {
      line-height: 1.15;
  }
  
  .card-text {
      line-height: 1.25;
  }
}

/* ===========================
   NOVEDADES SECTION
   =========================== */
.news-card {
    border-left: 4px solid var(--primary-red-color);
    height: 100%;
}

.news-card .badge {
    font-size: 0.8rem;
}

/* ===========================
   CATÁLOGOS SECTION
=========================== */
.catalog-card {
    background-color: var(--secondary-color);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.catalog-icon {
    font-size: 3rem;
    color: var(--primary-red-color);
    margin-bottom: 1rem;
}

.catalog-image {
    height: auto;
    object-fit: contain;
    margin-bottom: 1rem;
}

.catalog-card {
    background: var(--secondary-color);
    border-radius: 10px;
    padding: 40px 30px;
    height: 100%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #f0f0f0;
}

.catalog-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.catalog-card i {
    color: var(--primary-red-color);
}

.catalog-card h4 {
    margin: 20px 0 15px;
    color: var(--grey-color);
    font-weight: 600;
}

.catalog-card p {
    color: #666;
    line-height: 1.6;
}

.btn-outline-danger {
    border-color:var(--primary-red-color)!important;
    border-width: 2px;
    font-weight: 600;
    padding: 10px 25px;
    border-radius: 30px;
    transition: all 0.3s ease;
}

.btn-outline-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.3);
}

/* ===========================
   CAREER HIGHLIGHTS
   =========================== */
.career-highlights {
    background-color: #f8f9fa;
    border-radius: 10px;
    padding: 25px;
    margin-top: 30px;
}

.benefit-item {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.benefit-item i {
    color: #28a745;
    margin-right: 10px;
    font-size: 1.2rem;
}

/* ===========================
   MAIN CONTENT
   =========================== */
.main-content.form-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.main-content.form-page .container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.main-content.products-page {
    background-color: #f5f7fa;
}

.main-content.info-page {
    background-color: var(--secondary-color);
}

.main-content.info-page .container {
    box-shadow: none;
    background: transparent;
}

/* Fix for consistent button widths and scroll behavior */
.section-toggle {
    background: var(--bg);
    border-top: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 0;
    width: 100%;
}

/* Ensure the toggle button never disappears */
.section-toggle {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Remove the hidden/visible classes that cause disappearing */
.section-toggle.hidden,
.section-toggle.visible {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Consistent button width */
.corporate-toggle-btn {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border: 2px solid #bdc3c7;
    color: #ecf0f1;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(44, 62, 80, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 220px; /* Fixed minimum width */
    width: auto;
    justify-content: center;
    white-space: nowrap;
}

/* Make "Ver más" buttons consistent */
.btn-outline-danger,
.btn-danger {
    min-width: 120px;
    text-align: center;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
    padding: 0.5rem 1.5rem;
}

/* Ensure all buttons in cards have consistent width */
.catalog-card .btn,
.faq-item .btn,
.consejos-home-section .btn {
    min-width: 120px;
    width: auto;
}

/* Mobile responsive adjustments */
@media (max-width: 767.98px) {
    .section-toggle {
        padding: 0.75rem 1rem;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .corporate-toggle-btn {
        min-width: 200px;
        padding: 0.65rem 1.5rem;
        font-size: 0.9rem;
    }
    
    /* Ensure buttons stay visible on mobile */
    .section-toggle {
        transform: translateY(0) !important;
        opacity: 1 !important;
    }
}

/* For very small screens */
@media (max-width: 576px) {
    .corporate-toggle-btn {
        min-width: 180px;
        padding: 0.6rem 1.25rem;
        font-size: 0.85rem;
    }
    
    .btn-outline-danger,
    .btn-danger {
        min-width: 110px;
        padding: 0.45rem 1.25rem;
    }
}


/* ===========================
   VIEWPORT FIXES & MOBILE ADJUSTMENTS
   =========================== */

/* 1. Ensure proper viewport scaling */
@viewport {
    width: device-width;
    zoom: 1;
  }
  
  /* 2. Add iPhone-specific media queries */
  /* iPhone 14 Pro Max (larger screen) */
  @media screen and (device-width: 430px) and (device-height: 932px) {
    :root {
      --container-padding: 24px;
      --gap: 28px;
    }
    
    .hero-section h1 {
      font-size: 2.8rem;
    }
  }
  
  /* iPhone 15 (smaller screen) */
  @media screen and (device-width: 393px) and (device-height: 852px) {
    :root {
      --container-padding: 20px;
      --gap: 24px;
      --max-width: 95%;
    }
    
    .hero-section {
      min-height: 85vh;
    }
    
    .hero-section h1 {
      font-size: 2.4rem;
      margin-bottom: 1rem;
    }
    
    .hero-section .lead {
      font-size: 1.1rem;
      margin-bottom: 1.5rem;
    }
  }
  
  /* 3. Card improvements for consistent spacing */
  .card {
    margin-bottom: 1.5rem;
    padding: 20px;
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  /* 4. Better container for all screen sizes */
  .container {
    width: 100%;
    max-width: var(--max-width, 1200px);
    padding-right: calc(var(--container-padding, 28px) / 2);
    padding-left: calc(var(--container-padding, 28px) / 2);
    margin-right: auto;
    margin-left: auto;
    box-sizing: border-box;
  }
  
  /* 5. Improved search/results layout for mobile */
  .search-results-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    max-width: 100%;
    overflow: hidden;
  }
  
  .search-results-card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
  }
  
  .search-results-card .product-item {
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .search-results-card .product-item:last-child {
    border-bottom: none;
  }
  
  /* 6. Button consistency */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    min-width: 120px;
    box-sizing: border-box;
    transition: all 0.3s ease;
  }
  
  /* 7. Form elements for search */
  .search-container {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
  }
  
  .search-input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--light-color);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--primary-font);
    transition: border-color 0.3s ease;
  }
  
  .search-input:focus {
    outline: none;
    border-color: var(--accent);
  }
  
  .search-btn {
    background: linear-gradient(45deg, #CC0000, #990000);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    white-space: nowrap;
  }
  
  .search-btn:hover {
    background: linear-gradient(45deg, #CC0000, #990000);
  }
  
  /* 8. Responsive grid for products */
  .products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
  }
  
  /* 9. Mobile-specific adjustments */
  @media (max-width: 768px) {
    :root {
      --container-padding: 20px;
      --gap: 24px;
    }
    
    .container {
      padding-right: var(--container-padding);
      padding-left: var(--container-padding);
    }
    
    .hero-section h1 {
      font-size: 2.2rem;
    }
    
    .hero-section .lead {
      font-size: 1.05rem;
      padding: 0 1rem;
    }
    
    .section-title {
      font-size: 1.75rem !important;
    }
    
    .search-container {
      flex-direction: column;
    }
    
    .search-btn {
      width: 100%;
    }
    
    .products-grid {
      grid-template-columns: 1fr;
      gap: 1rem;
    }
    
    body {
      padding-top: 80px;
    }
  }
  
  /* 10. Very small screens (iPhone SE, smaller devices) */
  @media (max-width: 375px) {
    :root {
      --container-padding: 16px;
      --gap: 20px;
    }
    
    .hero-section h1 {
      font-size: 1.9rem;
    }
    
    .hero-section .btn {
      padding: 0.65rem 1.25rem;
      font-size: 0.9rem;
    }
    
    .card {
      padding: 1.25rem;
    }
    
    .search-results-card {
      padding: 1.25rem;
    }
  }
  
  /* 11. Prevent horizontal scrolling and overflow */
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }
  
  .container, .card, .search-results-card {
    max-width: 100%;
    overflow-wrap: break-word;
  }
  
  /* 12. Fix for Safari/iOS specific issues */
  @supports (-webkit-touch-callout: none) {
    .hero-section {
      -webkit-background-size: cover;
      background-size: cover;
      background-attachment: scroll;
    }

    .card {
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
    }
  }

  /* 13. Text overflow handling */
  .text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  /* 14. Improved spacing utilities */
  .mb-mobile {
    margin-bottom: 1rem;
  }
  
  @media (min-width: 768px) {
    .mb-mobile {
      margin-bottom: 1.5rem;
    }
  }

  /* Search Isolation CSS */
body.search-active .nav-item.dropdown,
body.search-active .desktop-mega-menu,
body.search-active .mega-menu-overlay {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Prevent mega menu from showing when search is focused */
.hero-search-input:focus ~ .desktop-mega-menu,
#hero-search-input:focus ~ .desktop-mega-menu,
.search-input-isolated:focus ~ .desktop-mega-menu {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Search elements should ignore mega menu */
[data-search-element="true"],
[data-mega-menu-ignore="true"],
.search-form-isolated,
.search-input-isolated,
.search-btn-isolated {
    pointer-events: auto !important;
    z-index: 10000 !important;
    position: relative;
}

/* Ensure search suggestions appear above mega menu */
#search-suggestions[data-search-suggestions="true"] {
    z-index: 10001 !important;
    position: absolute !important;
}


/* ===========================
   SECTION ALIGNMENT SYSTEM
   Override conflicting rules above
   =========================== */

/* Fix the root variable that breaks containers */
:root {
  --max-width: 1320px; /* was 100% - this was the main culprit */
}

/* Unified section wrapper - replaces mixed container/container-fluid */
.section-wrapper {
  width: 100%;
  max-width: 1320px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .section-wrapper {
      padding-left: 2.5rem;
      padding-right: 2.5rem;
  }
}

@media (min-width: 1200px) {
  .section-wrapper {
      padding-left: 3rem;
      padding-right: 3rem;
  }
}

@media (min-width: 1400px) {
  .section-wrapper {
      padding-left: 4rem;
      padding-right: 4rem;
  }
}

/* Restore Bootstrap container behavior (undoes your override above) */
.container {
  max-width: 1320px !important;
  padding-right: 1.5rem;
  padding-left: 1.5rem;
}

@media (max-width: 768px) {
  .container {
      padding-right: 1rem;
      padding-left: 1rem;
  }
}

/* ===========================
   VISUAL RHYTHM & MODERN FEEL
   =========================== */

/* Subtle red top-border accent — only on direct page-level sections */
main > section > .section-wrapper,
main > div > section > .section-wrapper {
    border-top: 1px solid rgba(204, 0, 0, 0.06);
}

/* Section title — Poppins */
.section-title {
    font-family: 'Poppins', ui-sans-serif, system-ui;
    font-size: clamp(1.6rem, 3vw, 2.2rem) !important;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: #1A1A1A;
}

/* Red accent divider line under section titles */
.section-title::after {
    width: 56px;
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, #CC0000, #ff4444);
}

/* Card — cleaner modern shadow */
.card {
    border: none !important;
    border-radius: 14px !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07) !important;
    transition: transform 0.3s cubic-bezier(.34,1.56,.64,1),
                box-shadow 0.3s ease !important;
}
.card:hover {
    transform: translateY(-6px) !important;
    box-shadow: 0 16px 40px rgba(0,0,0,0.12) !important;
}

/* Buttons — pill style globally */
.btn {
    border-radius: 50px !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px;
}


/* Badge — pill */
.badge {
    border-radius: 50px !important;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Tabs (home) — red active pill */
#homeTabs .nav-link.active {
    background: linear-gradient(135deg, #CC0000, #990000) !important;
    color: #fff !important;
    border-color: #CC0000 !important;
}
#homeTabs .nav-link {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
}

/* Smooth img loading */
img {
    image-rendering: auto;
}

/* ===========================
   SHARED PAGE HERO  (emapi-hero)
   Used by: Novedades, Contactos, CentrosDeDistribuciones,
            QuienesSomos/*, Puestos
   =========================== */
.emapi-hero {
    background: linear-gradient(135deg, #1a1a1a 0%, #CC0000 100%);
    color: #fff;
    padding: 3rem 1.5rem 2.5rem;
    text-align: center;
}
.emapi-hero h1 {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 800;
    margin: 0 0 .5rem;
    letter-spacing: -.01em;
}
.emapi-hero p {
    opacity: .85;
    font-size: .95rem;
    margin: 0;
}

/* ── Search result highlighting ─────────────────────────────── */
mark.srch-hl {
    background: #fff0b3;
    color: #7a5800;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: inherit;
}
.srch-variant-hint {
    font-size: .82rem;
    color: #555;
    font-style: italic;
    margin-top: .15rem;
}

/* Legacy — keep so old references don't break */
.news-hero {
    background: linear-gradient(rgba(0,0,0,0.8), rgba(0,0,0,0.9)),
                url('/images/Banner_Home_Fitaflex_ESP.png') center center/cover no-repeat;
    padding: 30px 0 20px;
    margin-top: 0;
    width: 100%;
    display: block;
}
