/* ==========================================================================
   1. GLOBAL STYLES & LAYOUT
   ========================================================================== */
/* It prevents lateral movement */
html,
body {
    overflow-x: hidden;
}

body {
    font-family: 'ABC Normal', 'IBM Plex Sans';
    margin: 0;
    padding: 0;
    background-color: #ffffff;
    /* Subtle grid pattern background */
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px);
    background-size: 50px 50px;
    color: #1f2937;
    background-attachment: fixed;
}

/* Sticky footer layout: ensures footer stays at page bottom */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    /* Main content expands to fill available space */
}

/* ==========================================================================
   2. NAVBAR - Bootstrap Overrides
   ========================================================================== */

/* ==================== NAVBAR BASE ==================== */
#mainNavbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #ffffff;
    /* Fondo blanco inicial */
    transition: background-color 0.4s ease-in-out;
    font-family: 'ABC Normal', 'IBM Plex Sans';
    height: 65px;
}

.container {
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    margin-right: auto;
    margin-left: auto;

    /* El límite máximo para que no se vea "estirado" en pantallas gigantes */
    max-width: 1400px;
}

/* Opcional: Ajustes por media queries si lo haces a mano */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
        /* Ancho moderno */
    }
}

@media (min-width: 1200px) and (max-width: 1399px) {
    .container {
        max-width: 1140px;
    }
}


/* Navigation links styling */
.navbar-nav .nav-link {
    color: #000000;
    font-weight: normal;
    letter-spacing: -0.01em;
    transition: color 0.2s;
}

#mainNavbar .nav-link {
    font-weight: 500 !important;
}


/* Logos: Initial Configuration */
#mainNavbar .logo-dark,
#mainNavbar .logo-white {
    height: 30px !important;
    width: auto !important;
    transition: all 0.4s ease-in-out;
}

@media (max-width: 768px) {

    #mainNavbar .logo-dark,
    #mainNavbar .logo-white {
        height: 20px !important;
    }
}

/* Dark Logo: Visible by default */
#mainNavbar .logo-dark {
    display: block !important;
}

/* White Logo: Hidden by default */
#mainNavbar .logo-white {
    display: none !important;
}


/* ==================== NAVBAR SCROLLED ==================== */
/* Black background when scrolling */
#mainNavbar.scrolled {
    background-color: #000000 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}



/* --- LOGIC OF LOGO CHANGE (The critical part) --- */

/* When it has the .scrolled class, HIDE the dark logo */
#mainNavbar.scrolled .logo-dark {
    display: none !important;
}

/* When it has the .scrolled class, SHOW the white logo */
#mainNavbar.scrolled .logo-white {
    display: block !important;
}

/* --- RESTO DE ESTILOS (Links and Button) --- */
#mainNavbar.scrolled .nav-link {
    color: #ffffff !important;
}

#mainNavbar.scrolled .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.5) !important;
}

.btn-contact-mobile {
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    margin: 0 !important;
    width: max-content !important;
    height: auto !important;
    line-height: 1.5 !important;
    display: inline-block !important;
}

/* Shrink & Clean hamburger toggle on mobile */
@media (max-width: 991px) {
    .navbar-toggler {
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
    }

    .navbar-toggler-icon {
        width: 1.25rem !important;
        height: 1.25rem !important;
        /* Inicialmente blanco el fondo -> icono NEGRO */
        filter: brightness(0) !important;
        transition: filter 0.3s ease;
    }

    #mainNavbar.scrolled .navbar-toggler-icon {
        /* Al hacer scroll fondo negro -> icono BLANCO */
        filter: brightness(0) invert(1) !important;
    }
}

/* Mobile Menu Styling */
@media (max-width: 991px) {
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 15px;
        right: 15px;
        background-color: #ffffff;
        padding: 1.5rem;
        border-radius: 1rem;
        margin-top: 1rem;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        border: 1px solid rgba(0, 0, 0, 0.05);
        z-index: 1001;

        /* Custom smooth transition */
        transition: opacity 0.30s ease, transform 0.30s cubic-bezier(0.4, 0, 0.2, 1) !important;
        opacity: 0;
        transform: translateY(-10px);
    }

    /* Shown state */
    .navbar-collapse.show {
        opacity: 1;
        transform: translateY(0);
    }

    /* Bootstrap collapsing state override for smoothness */
    .navbar-collapse.collapsing {
        opacity: 0;
        transform: translateY(-10px);
        height: auto !important;
        /* Prevent height jump on absolute overlay */
        transition: opacity 0.3s ease, transform 0.3s ease !important;
    }

    #mainNavbar.scrolled .navbar-collapse {
        background-color: #000000;
        border-color: rgba(255, 255, 255, 0.1);
    }

    #mainNavbar.scrolled .nav-link {
        color: rgba(255, 255, 255, 0.8) !important;
    }

    .navbar-nav {
        align-items: flex-start !important;
        gap: 1.5rem !important;
    }

    .navbar-nav .nav-link {
        font-size: 1.1rem;
    }
}


/* Purple CTA Button (Bootstrap override) */
.btn-purple {
    background: linear-gradient(to bottom, rgba(242, 76, 76, 1) 0%, rgba(180, 4, 4, 1) 100%) !important;
    border: none !important;
    color: white !important;
    font-weight: 500 !important;
}

.btn-purple:hover {
    background: linear-gradient(to bottom, rgba(220, 50, 50, 1) 0%, rgba(150, 0, 0, 1) 100%) !important;
}


/* ==================== HERO SECTION ==================== */
.hero-wrapper {
    position: relative;
    border-radius: 2rem;
    overflow: hidden;
    margin: 3rem auto;
    max-width: 1500px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.hero {
    position: relative;
    width: 100%;
    max-width: 1300px;
    min-height: 650px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background-color: #111827;
    color: white;
    padding: 10rem 5rem;
    border-radius: 1.5rem;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.hero-background-media {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    /* Ensure it stays behind content */
}

/* --- VIDEO CAROUSEL STYLES --- */
.hero-video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.hero-video-item {
    object-fit: cover;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    visibility: hidden;
    transition: opacity 1.5s ease-in-out, visibility 1.5s;
    z-index: 1;
}

/* The active video is on top and visible */
.hero-video-item.active {
    visibility: visible;
    z-index: 3;
}

/* The video that is fading out stays underneath and visible */
.hero-video-item.outgoing {
    visibility: visible;
    z-index: 2;
}

/* Initial state helper classes to avoid template logic in style attribute */
.hero-video {
    object-fit: cover;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.hero-video-initial-active {
    z-index: 1;
}

.hero-video-initial-inactive {
    opacity: 0;
    z-index: 0;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    z-index: 4;
}

.hero-content {
    position: relative;
    z-index: 10;
    max-width: 600px;
    text-align: left;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero p {
    font-size: 1.125rem;
    color: #e5e7eb;
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

.hero .cta-button {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(to bottom, rgba(242, 76, 76, 1) 0%, rgba(180, 4, 4, 1) 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.hero .cta-button::after {
    content: "›";
    margin-left: 0.75rem;
    font-size: 1.25rem;
    line-height: 1;
    display: inline-block;
    transform: translateY(-2px);
}

.hero .cta-button:hover {
    background: linear-gradient(to bottom, rgba(220, 50, 50, 1) 0%, rgba(150, 0, 0, 1) 100%);
    box-shadow: 0 4px 12px rgba(180, 4, 4, 0.3);
}

/* ==========================================================================
   4. RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 768px) {
    .hero {
        padding: 4rem 1.5rem;
        min-height: 50vh;
        border-radius: 0;
        margin: 0;
        max-width: 100%;
    }

    .hero-wrapper {
        padding: 0;
        margin: 0;
        border-radius: 0;
        max-width: 100%;
    }

    .hero h1 {
        font-size: 1.75rem;
        text-align: left;
    }

    .hero p {
        font-size: 1rem;
        text-align: left;
        margin-bottom: 1.5rem;
    }

    .hero-content {
        max-width: 100%;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .hero .cta-button {
        width: auto;
        justify-content: flex-start;
        padding: 0.6rem 1.25rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.5rem;
    }

    .hero {
        padding: 3.5rem 1rem;
    }
}