/* Fonts */
@font-face {
    font-family: 'Lato';
    src: url('../fonts/lato/Lato-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Lato';
    src: url('../fonts/lato/Lato-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Lato';
    src: url('../fonts/lato/Lato-Black.ttf') format('truetype');
    font-weight: 900;
    font-style: normal;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body,
html {
    width: 100%;
    height: 100%;
    font-family: 'Lato', sans-serif;
    background-color: #000;
    overflow-x: hidden;
    /* Prevent horizontal scroll from absolutely positioned elements */
}

/* Hero Section */
.hero-section {
    position: relative;
    width: 100%;
    height: 100vh;
    background-image: url('../images/hero_bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 30, 40, 0.45);
    /* Subtle dark teal overlay to ensure text readability */
    z-index: 1;
}

/* Header */
.header {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 50px 150px;
    width: 100%;
}

.logo img {
    height: 95px;
    filter: brightness(0) invert(1);
    /* Makes the logo white */
    transition: transform 0.3s ease;
}

.logo img:hover {
    transform: scale(1.05);
}

.nav {
    display: flex;
    gap: 40px;
    align-items: center;
}

.nav a {
    text-decoration: none;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.nav a:hover:not(.active) {
    color: #D4AF37;
}

.nav a.active {
    background-color: #D4AF37;
    /* Metallic gold/yellow */
    color: #ffffff;
    /* White text as requested */
    padding: 6px 14px;
    font-weight: 900;
}

/* Hero Content */
.hero-content {
    position: relative;
    z-index: 2;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding-bottom: 50px;
}

.hero-title {
    font-size: 130px;
    font-weight: 900;
    color: #ffffff;
    line-height: 1;
    letter-spacing: 3px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
}

.hero-subtitle-box {
    border: 3px solid #ffffff;
    padding: 12px 50px;
    display: inline-block;
    box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.2);
}

.hero-subtitle {
    color: #ffffff;
    font-size: 32px;
    font-weight: 400;
    margin: 0;
    text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.3);
}

.hero-subtitle strong {
    font-weight: 900;
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 100;
}

/* Responsive */
@media (max-width: 1024px) {
    .header {
        padding: 40px 60px;
    }

    .logo img {
        height: 85px;
    }

    .hero-title {
        font-size: 90px;
    }

    .hero-subtitle {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 20px 25px;
        flex-direction: row; /* Force side-by-side */
        justify-content: space-between;
        align-items: center;
        gap: 0;
    }

    .logo img {
        height: 55px; /* Smaller logo for mobile */
    }

    .mobile-menu-btn {
        display: block;
    }

    .nav {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: transparent;
        flex-direction: column;
        padding: 20px 0;
        gap: 20px;
        clip-path: polygon(0 0, 100% 0, 100% 0, 0 0); /* hidden */
        transition: clip-path 0.4s ease;
    }

    .nav.active {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }

    .nav a.active {
        background: transparent;
        color: #d4a32a;
        padding: 0;
    }

    .hero-title {
        font-size: 55px;
        margin-top: 40px;
    }

    .hero-subtitle-box {
        padding: 10px 15px;
    }

    .hero-subtitle {
        font-size: 16px;
    }
}

/* Generales */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

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

.relative {
    position: relative;
    z-index: 2;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

/* Píldoras de Sección */
.section-pill {
    display: inline-block;
    padding: 8px 30px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 40px;
}

.black-pill {
    border: 2px solid #000;
    color: #000;
    background-color: transparent;
}

.white-pill {
    border: 2px solid #fff;
    color: #fff;
    background-color: transparent;
}

/* Nosotros Section */
.nosotros-section {
    background-color: #f4f4f5; /* Light fallback to prevent black flash */
    background-image: url('../images/crumpled_bg.jpg');
    background-size: cover;
    background-position: center;
    padding: 30px 0;
    /* Reduced padding to make it thinner like the PDF */
}

.nosotros-text {
    font-size: 22px;
    line-height: 1.6;
    color: #1a1a1a;
    max-width: 950px;
    margin: 0 auto;
}

.nosotros-text strong {
    font-weight: 900;
}

/* Clientes Section */
.clientes-section {
    position: relative;
    background-image: url('../images/impact_bg.png');
    background-size: cover;
    background-position: center;
    padding: 100px 0;
}

.clientes-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 40, 60, 0.4);
    z-index: 1;
}

/* Swiper Clientes */
.clientes-swiper {
    padding: 20px 80px 50px 80px !important;
    /* Space for arrows and dots */
}

.swiper-slide {
    display: flex;
    justify-content: center;
    align-items: center;
}

.cliente-logo {
    max-width: 100%;
    width: 100%;
    height: 200px;
    /* Make logos much larger */
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.8;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.cliente-logo:hover {
    opacity: 1;
    transform: scale(1.05);
}

.swiper-button-next.clientes-next,
.swiper-button-prev.clientes-prev {
    color: #a0a0a0;
    /* Gray color to match PDF */
    transform: scale(1.8);
    font-weight: bold;
    width: 60px;
}

.swiper-button-prev.clientes-prev {
    left: 10px;
    transform-origin: left center;
}

.swiper-button-next.clientes-next {
    right: 10px;
    transform-origin: right center;
}

/* Pagination Dots */
.swiper-pagination.clientes-pagination {
    bottom: 0px !important;
}

.swiper-pagination.clientes-pagination .swiper-pagination-bullet {
    background: #a0a0a0;
    opacity: 0.5;
    width: 14px;
    height: 14px;
    margin: 0 8px !important;
}

.swiper-pagination.clientes-pagination .swiper-pagination-bullet-active {
    background: #ffffff;
    opacity: 1;
}

/* Scroll Animations */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s ease-out !important;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.8s ease-out !important;
}

.reveal.active:hover {
    transition: all 0.3s ease !important;
}

.reveal-delay-1 {
    transition-delay: 0.2s;
}

.reveal-delay-2 {
    transition-delay: 0.4s;
}

.reveal-delay-3 {
    transition-delay: 0.6s;
}

@media (max-width: 768px) {
    .nosotros-text {
        font-size: 18px;
        padding: 0 15px;
    }

    .clientes-swiper {
        padding: 40px 20px !important;
    }

    .clientes-pagination {
        display: none !important; /* Hide dots on mobile */
    }

    .cliente-logo {
        max-height: 120px; 
        height: 120px;
        width: 100%;
        object-fit: contain;
        transform: scale(1.3);
    }

    .lideramos-content {
        text-align: center;
        max-width: 100%;
    }

    .lideramos-title {
        font-size: 40px;
    }
}

/* Lideramos Section */
.lideramos-section {
    background-image: url('../images/lideramos_bg.png');
    background-size: cover;
    background-position: left center;
    /* Align image to keep truck visible correctly */
    padding: 220px 0 100px 0;
    /* Push content down to match PDF */
    position: relative;
}

@media (max-width: 768px) {
    .lideramos-section {
        background-image: url('../images/lideramos_bg_celu.jpg'); /* Vertical image for mobile */
        background-position: center top; /* Sky on top, truck/person below */
        background-size: cover;
        padding: 70px 0 380px 0; /* Push text to the sky area so it doesn't cover the truck */
    }
    .lideramos-section .lideramos-content {
        text-align: center;
        max-width: 100%;
        width: 100%;
        margin: 0 auto;
        padding-right: 0;
    }
    .lideramos-section .lideramos-title {
        font-size: 30px;
        line-height: 1.15;
        margin-bottom: 20px;
        word-break: normal;
        text-shadow: 2px 2px 8px rgba(0,0,0,0.9); /* Darker shadow for readability */
    }
    .lideramos-section .pill-large {
        font-size: 16px;
        padding: 8px 18px;
        white-space: nowrap; /* Keep "En Territorios Complejos" on one line */
        background: rgba(0,0,0,0.5); /* Make pill background slightly dark */
    }
}

.lideramos-content {
    text-align: right;
    margin-left: auto;
    max-width: 50%;
    padding-right: 10%;
    /* Move text away from extreme right edge */
}

.lideramos-title {
    font-size: 60px;
    font-weight: 900;
    color: #ffffff;
    line-height: 1.1;
    margin-bottom: 30px;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.4);
}

.pill-large {
    font-size: 24px;
    padding: 12px 40px;
}

.impactos-section {
    background-color: #f4f4f5;
    background-image: url('../images/crumpled_bg.jpg');
    background-size: cover;
    background-position: center;
    position: relative;
    z-index: 5;
}

.impactos-phone {
    position: absolute;
    left: 12%;
    top: -150px;
    height: 600px;
    z-index: 10;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.4));
    cursor: pointer;
}

.impactos-phone:hover {
    transform: scale(1.03) translateY(-10px) !important;
    filter: drop-shadow(0 30px 50px rgba(0, 0, 0, 0.6));
}

.impactos-container {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    min-height: 600px;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

.impactos-left {
    flex: 1;
    padding: 60px 5% 80px 42%;
    /* 42% left padding to make room for the absolute phone */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.impactos-icons {
    width: 250px;
    margin-bottom: 30px;
}

.impactos-right {
    flex: 1;
    min-width: 300px;
}

.impactos-right img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (min-width: 1025px) {
    .impactos-right {
        position: relative;
        left: max(0px, 50vw - 700px);
    }
}

.impactos-text {
    font-size: 32px;
    line-height: 1.4;
    color: #1a1a1a;
    max-width: 550px;
}

.impactos-text strong {
    font-weight: 900;
}

@media (max-width: 1024px) {
    .impactos-phone {
        position: relative;
        top: 0;
        left: 0;
        height: auto;
        width: 80%;
        max-width: 350px;
        margin: -80px auto 70px auto; /* Larger bottom gap so icons never overlap the phone on any device */
        display: block;
    }

    .impactos-left {
        padding: 40px 20px;
        align-items: center;
        text-align: center;
    }
}

.impactos-placeholder-top {
    height: 150px;
    /* Space reserved for the 3 future icons */
    margin-bottom: 20px;
}

.impactos-placeholder-bottom {
    height: 50px;
}

@media (max-width: 1024px) {
    .impactos-container {
        flex-direction: column;
    }

    .impactos-left {
        padding: 50px 20px;
    }

    .impactos-right {
        height: 400px;
    }
}

/* Logo Mitad Overlay */
.impactos-section {
    position: relative;
}

.half-logo-overlay {
    position: absolute;
    bottom: -250px;
    right: -180px;
    /* Push it much further to the right */
    height: 450px;
    z-index: 10;
    filter: brightness(0) invert(1);
    opacity: 0.9;
    pointer-events: none;
}

/* Servicios Section */
.servicios-section {
    background-image: url('../images/servicios_bg.png');
    background-size: cover;
    background-position: center;
    padding: 120px 0;
    position: relative;
}

.transparent-pill {
    border: 2px solid #fff;
    color: #fff;
    background: transparent;
    margin-bottom: 60px;
}

.servicios-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    align-items: stretch;
    padding: 0 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Desktop overrides for servicios-swiper to not act like slider */
@media (min-width: 769px) {
    .servicios-swiper .swiper-wrapper {
        transform: none !important;
    }
    .servicios-swiper .swiper-slide {
        width: auto !important;
    }
}

/* Mobile Swiper overrides */
@media (max-width: 768px) {
    .servicios-grid {
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        gap: 0 !important;
        padding: 0;
    }
    .servicios-swiper {
        padding-bottom: 50px;
    }
    .servicios-pagination .swiper-pagination-bullet {
        background: #fff;
    }
    .servicio-card {
        min-width: 100%;
        margin-bottom: 0 !important;
        transform: none !important; /* prevent reveal from hiding inside swiper */
        opacity: 1 !important;
    }
}

/* Removing old row classes CSS since we flattened HTML */

.servicio-card {
    background: url('../images/crumpled_bg.jpg') center/cover;
    padding: 10px;
    width: 260px;
    /* Reduced to fit 4 in a row within 1200px container */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.servicio-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

.servicio-img-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
    /* Much taller image */
}

.servicio-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.servicio-line {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.servicio-text {
    padding: 25px 10px 15px;
    text-align: center;
    color: #1a1a1a;
    font-size: 16px;
    line-height: 1.3;
    flex: 1;
    /* Fills remaining space */
}

.servicio-text strong {
    font-size: 20px;
    font-weight: 900;
}

@media (max-width: 1024px) {
    .half-logo-overlay {
        display: none;
    }
}

/* Frase / Thin Band Section */
.frase-section {
    background-color: #f4f4f5;
    background-image: url('../images/crumpled_bg.jpg');
    background-size: cover;
    background-position: center;
    padding: 30px 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 5;
}

.frase-text {
    font-size: 22px;
    color: #1a1a1a;
    text-align: right;
    margin-left: auto;
    max-width: 65%;
    padding-right: 50px;
    line-height: 1.4;
}

.frase-text strong {
    font-weight: 900;
}

/* Modelación Numérica Section */
.modelacion-section {
    background-image: url('../images/modelacion.jpg');
    background-size: cover;
    background-position: center;
    padding: 200px 0 250px 0;
    position: relative;
}

.modelacion-content {
    text-align: right;
    max-width: 60%;
    margin-left: auto;
    padding-right: 50px;
}

.modelacion-3d {
    position: absolute;
    left: -25%;
    top: -160px;
    height: 800px;
    width: auto;
    max-width: none;
    z-index: 20;
    pointer-events: none;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.6));
}

.modelacion-title {
    font-size: 85px;
    /* Increased from 70px to make it larger */
    font-weight: 400;
    color: #ffffff;
    line-height: 1.1;
    text-shadow: 2px 2px 15px rgba(0, 0, 0, 0.6);
}

.modelacion-title strong {
    font-weight: 900;
}

.modelacion-3d-placeholder {
    /* Prepared for the future 3D model image */
    position: absolute;
    left: -10%;
    bottom: -100px;
    width: 60%;
    height: 600px;
    pointer-events: none;
}

@media (max-width: 768px) {
    .frase-text {
        font-size: 20px;
    }

    .modelacion-title {
        font-size: 50px;
    }

    .modelacion-section .container {
        position: relative;
        z-index: 40 !important; /* Force the entire container above the image */
    }

    .modelacion-content {
        max-width: 100%;
        text-align: center;
        padding: 0 20px;
        position: relative;
        z-index: 30 !important;
    }

    .modelacion-3d {
        position: relative;
        top: -80px;
        left: 0;
        height: auto;
        width: 100%;
        margin-bottom: 20px; /* Push the title down so it sits below the 3D model, not over it */
        z-index: 1 !important; /* Force image to lowest z-index */
    }

    .equipamiento-prev,
    .equipamiento-next {
        display: none !important; /* Remove arrows on mobile */
    }

    .frase-text {
        max-width: 100%;
        text-align: center;
        padding: 0 20px;
    }
}

/* Equipamiento Section */
.equipamiento-section {
    width: 100%;
    position: relative;
}

.equipamiento-swiper {
    width: 100%;
    height: 750px;
}

.equipamiento-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.swiper-button-next.equipamiento-next,
.swiper-button-prev.equipamiento-prev {
    color: rgba(255, 255, 255, 0.5);
    transform: scale(2);
    font-weight: bold;
}

.swiper-pagination.equipamiento-pagination .swiper-pagination-bullet {
    background: #ffffff;
    opacity: 0.5;
    width: 18px;
    height: 18px;
    margin: 0 10px !important;
}

.swiper-pagination.equipamiento-pagination .swiper-pagination-bullet-active {
    opacity: 1;
}

/* Excelencia Section */
.excelencia-section {
    background-image: linear-gradient(rgba(50, 50, 50, 0.35), rgba(50, 50, 50, 0.35)), url('../images/water_sampling.png');
    background-size: cover;
    background-position: center;
    padding: 160px 0;
    position: relative;
}

.excelencia-content {
    max-width: 850px;
    margin-left: auto;
    text-align: right;
    color: #ffffff;
    padding-right: 50px;
}

.excelencia-title {
    font-size: 75px;
    font-weight: 400;
    line-height: 1.1;
    margin-bottom: 40px;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
}

.excelencia-title strong {
    font-weight: 900;
}

.excelencia-subtitle {
    font-size: 32px;
    line-height: 1.3;
    margin-bottom: 40px;
    text-shadow: 1px 1px 8px rgba(0, 0, 0, 0.5);
}

.excelencia-text {
    font-size: 22px;
    line-height: 1.5;
    text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.5);
}

.excelencia-subtitle strong,
.excelencia-text strong {
    font-weight: 900;
}

@media (max-width: 768px) {
    .equipamiento-swiper {
        height: 400px;
    }

    .excelencia-title {
        font-size: 50px;
    }

    .excelencia-subtitle {
        font-size: 24px;
    }

    .excelencia-text {
        font-size: 18px;
    }

    .excelencia-content {
        text-align: center;
        padding: 0 20px;
    }
}

/* Footer Section */
.footer-section {
    background-image: url('../images/hero_bg_5_opt.jpg');
    background-size: cover;
    background-position: center;
    min-height: 85vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 50px 20px;
    position: relative;
    text-align: center;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.footer-title {
    font-size: 85px;
    font-weight: 900;
    color: #ffffff;
    margin-bottom: 30px;
    line-height: 1;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
}

.footer-box {
    display: inline-block;
    border: 2px solid #ffffff;
    padding: 10px 30px;
    color: #ffffff;
    font-size: 18px;
    font-weight: 900;
    text-decoration: none;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 320px;
    text-align: center;
    background: transparent;
}

.footer-box:hover {
    background: #ffffff;
    color: #000000;
}

.footer-socials {
    display: flex;
    gap: 20px;
    margin-top: 40px;
}

.social-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 50px;
    height: 50px;
    background: #ffffff;
    color: #000000;
    border-radius: 8px;
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.social-icon svg {
    width: 30px;
    height: 30px;
}

.social-icon:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
    .footer-title {
        font-size: 50px;
    }
}

/* Variaciones de Animación Profesionales */
.reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s ease;
}

.reveal-left.active {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s ease;
}

.reveal-right.active {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.8s ease;
}

.reveal-scale.active {
    opacity: 1;
    transform: scale(1);
}

.reveal-fade {
    opacity: 0;
    transition: opacity 1s ease;
}

.reveal-fade.active {
    opacity: 1;
}

.reveal-up {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s ease;
}

.reveal-up.active {
    opacity: 1;
    transform: translateY(0);
}

/* Continuous Carousel Ticker Effect */
.clientes-swiper .swiper-wrapper {
    transition-timing-function: linear !important;
}

/* Stats Grid (now inside Nosotros Section) */
.stats-grid {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
}
.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 250px;
}
.stat-number {
    font-size: 85px;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 10px;
    color: #000000;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}
.stat-text {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #ffffff;
    background-color: #000000;
    padding: 10px 40px;
    border-radius: 50px;
    display: inline-block;
}

/* Desktop overrides for stats-swiper to not act like slider */
@media (min-width: 769px) {
    .stats-swiper .swiper-wrapper {
        display: flex;
        justify-content: space-around;
        align-items: center;
        flex-wrap: wrap;
        gap: 40px;
        transform: none !important;
    }
    .stats-swiper .swiper-slide {
        width: auto !important;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        gap: 0;
        flex-wrap: nowrap !important; /* Critical for Swiper */
        justify-content: flex-start !important;
    }
    .stats-swiper {
        padding-bottom: 50px;
    }
    .stats-pagination .swiper-pagination-bullet {
        background: #000;
    }
    .stat-item {
        opacity: 1 !important; /* Force visibility inside swiper */
        transform: none !important;
        min-width: 100%; /* Ensure slide takes full width */
    }
    .stat-number {
        font-size: 70px; /* Slightly smaller for mobile */
    }
}

/* Preloader */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #0b131a; /* Dark Rekosol theme */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#preloader.loaded {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top: 5px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Service Modal */
.service-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.service-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.service-modal-content {
    background-color: #f4f4f5;
    background-image: url('../images/crumpled_bg.jpg');
    background-size: cover;
    background-position: center;
    width: 90%;
    max-width: 1100px;
    aspect-ratio: 16 / 9;
    max-height: 90vh;
    position: relative;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    overflow: hidden; /* Ensures no scroll from watermark */
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex;
}

.service-modal-overlay.active .service-modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.service-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    color: #1a1a1a;
    border: none;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    opacity: 0.5;
}

.service-modal-close svg {
    width: 25px;
    height: 25px;
}

.service-modal-close:hover {
    transform: rotate(90deg);
    opacity: 1;
}

.service-modal-body {
    padding: 60px 80px;
    position: relative;
    width: 100%;
    height: 100%;
    box-sizing: border-box; /* THIS IS THE FIX: prevents padding from adding 120px to height, causing fake scroll */
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll from absolutely positioned elements */
    display: flex;
    align-items: center;
}

/* Custom Scrollbar for Modal */
.service-modal-body::-webkit-scrollbar {
    width: 6px;
}
.service-modal-body::-webkit-scrollbar-track {
    background: transparent; 
}
.service-modal-body::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2); 
    border-radius: 4px;
}

.service-modal-watermark {
    position: absolute;
    top: 50%;
    right: 0; /* Changed from -5% to stop overflowing */
    transform: translateY(-50%);
    height: 80%; /* Reduced from 100% so it's not giant on PC */
    opacity: 0.8;
    pointer-events: none;
    filter: brightness(0) invert(1);
    z-index: 1;
}

.service-modal-text {
    position: relative;
    z-index: 2;
    max-width: 50%; /* Only take up left half */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.service-modal-title {
    font-size: 38px;
    color: #000;
    font-weight: 400;
    line-height: 1.1;
    margin-bottom: 30px;
    word-break: break-word; /* Prevent long words from causing horizontal scroll */
}

.service-modal-title strong {
    font-weight: 900;
    display: block; /* Forces "Recursos Hídricos" to new line if needed, matches image structure */
}

.service-modal-p {
    font-size: 15px;
    color: #000;
    line-height: 1.5;
    margin-bottom: 15px;
    font-weight: 700; /* making it slightly bold to match the dark text in the image */
}

.service-modal-p:last-of-type {
    margin-bottom: 40px;
}

.service-modal-logo-bottom {
    height: 45px;
    width: auto;
    display: block;
    align-self: flex-start; /* Keep to the left */
}

@media (max-width: 1024px) {
    .service-modal-content {
        aspect-ratio: auto;
        height: auto;
        max-height: 85vh;
        display: flex;
        flex-direction: column;
    }
    
    .service-modal-body {
        padding: 40px;
        flex: 1;
        min-height: 0; /* allows flex item to shrink and scroll */
    }

    .service-modal-text {
        max-width: 60%;
    }
}

@media (max-width: 768px) {
    .service-modal-content {
        height: 85vh; /* Set explicit height on mobile so body can scroll */
        width: 95%; /* Make it slightly wider on mobile for better text fit */
        box-sizing: border-box;
    }
    
    .service-modal-body {
        padding: 40px 20px;
        display: block; /* Prevents flexbox from cropping overflowing content, enabling scroll */
        height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        box-sizing: border-box; /* Crucial: stops padding from expanding width beyond 100% */
        width: 100%;
    }
    
    .service-modal-text {
        max-width: 100%;
    }
    
    .service-modal-watermark {
        height: 60%;
        right: -20%;
        opacity: 0.1; /* more transparent on mobile to not hide text */
    }
    
    .service-modal-title {
        font-size: 28px;
    }
    
    .service-modal-p {
        font-size: 14px;
    }
}