:root {
    --bg-main: #f4f7f6;
    --bg-alt: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #333333;
    --text-secondary: #555555;
    --accent: #3498db;
    --accent-hover: #2980b9;
    --border: #cccccc;
    --nav-bg: rgba(255, 255, 255, 0.98);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

[data-theme="dark"] {
    --bg-main: #121212;
    --bg-alt: #1e1e1e;
    --bg-card: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #b3b3b3;
    --accent: #3498db;
    --accent-hover: #60a5fa;
    --border: #444444;
    --nav-bg: rgba(18, 18, 18, 0.98);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

html {
    scroll-behavior: smooth; 
    scroll-padding-top: 100px; 
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.8;
    overflow-wrap: break-word;
    word-wrap: break-word;
    transition: background-color 0.3s, color 0.3s;
    overflow-x: clip; 
    width: 100%;
    position: relative;
}

img, iframe { max-width: 100%; }

.container { width: 100%; max-width: 1250px; margin: 0 auto; padding: 0 24px; }
.bg-alt { background-color: var(--bg-alt); }

section { padding: 140px 0; position: relative; width: 100%; }

p { margin-bottom: 20px; }
p:last-child { margin-bottom: 0; }
strong { color: var(--accent); font-weight: 700; }

.section-header { text-align: center; margin-bottom: 70px; }
.section-header h2 { font-size: 2.8rem; font-weight: 800; color: var(--text-primary); margin-bottom: 15px; }
.heading-line { width: 80px; height: 5px; background-color: var(--accent); margin: 0 auto 20px auto; border-radius: 3px; }
.section-lead { font-size: 1.2rem; color: var(--text-secondary); max-width: 800px; margin: 0 auto; }

.section-header.align-left { text-align: left; margin-bottom: 30px; }
.section-header.align-left .heading-line { margin: 0 0 20px 0; }

.reveal { opacity: 0; transform: translateY(40px); transition: all 0.8s cubic-bezier(0.25, 0.8, 0.25, 1); will-change: opacity, transform; }
.reveal.fade-left { transform: translateX(-40px); }
.reveal.fade-right { transform: translateX(40px); }
.reveal.visible { opacity: 1; transform: translate(0, 0); }
.delay-1 { transition-delay: 0.15s; }
.delay-2 { transition-delay: 0.3s; }

.btn { display: inline-block; padding: 14px 36px; border-radius: 6px; font-weight: 700; text-decoration: none; font-size: 1.05rem; transition: var(--transition); cursor: pointer; border: none; }
.btn-primary { background-color: var(--accent); color: #ffffff; }
.btn-primary:hover { background-color: var(--accent-hover); transform: translateY(-3px); box-shadow: 0 8px 20px rgba(52, 152, 219, 0.3); }
.btn-outline { background-color: transparent; color: #ffffff; border: 2px solid #ffffff; }
.btn-outline:hover { background-color: #ffffff; color: #1a1a1a; transform: translateY(-3px); }
.btn-block { width: 100%; }

.status-alert { position: fixed; top: 100px; left: 50%; transform: translateX(-50%); padding: 16px 32px; border-radius: 8px; color: white; font-weight: bold; z-index: 2000; box-shadow: 0 10px 25px rgba(0,0,0,0.2); text-align: center; animation: slideDown 0.4s ease forwards; width: 90%; max-width: 500px; }
@keyframes slideDown { from { top: 0; opacity: 0; } to { top: 100px; opacity: 1; } }
.status-alert.success { background-color: #27ae60; }
.status-alert.error { background-color: #e74c3c; }

.navbar { position: fixed; top: 0; left: 0; width: 100%; background-color: var(--nav-bg); border-bottom: 1px solid var(--border); z-index: 1000; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.nav-container { display: flex; justify-content: space-between; align-items: center; padding: 15px 24px; max-width: 1400px; margin: 0 auto; }
.nav-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.nav-brand img { height: 40px; width: auto; }
.brand-text { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); letter-spacing: 0.5px; }

.nav-links { display: flex; gap: 30px; align-items: center; position: absolute; left: 50%; transform: translateX(-50%); }
.nav-links a { text-decoration: none; color: var(--text-primary); font-weight: 600; font-size: 1.05rem; transition: var(--transition); }
.nav-links a:hover { color: var(--accent); }

.nav-btn-contact { background-color: var(--text-primary); color: var(--bg-main) !important; padding: 8px 22px; border-radius: 6px; }
.nav-btn-contact:hover { background-color: var(--accent); color: #ffffff !important; transform: translateY(-2px); }

.nav-actions { display: flex; align-items: center; gap: 15px; }
.theme-toggle { background: var(--bg-card); border: 1px solid var(--border); border-radius: 50%; width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-primary); transition: var(--transition); }
.theme-toggle:hover { border-color: var(--accent); transform: scale(1.05); }

.hamburger { display: none; background: transparent; border: none; cursor: pointer; flex-direction: column; justify-content: center; gap: 6px; width: 35px; height: 35px; z-index: 1001; }
.hamburger span { display: block; width: 100%; height: 3px; background-color: var(--text-primary); border-radius: 2px; transition: var(--transition); }

.hero-section { position: relative; padding: 250px 20px 180px 20px; background-color: #1a252f; text-align: center; display: flex; align-items: center; justify-content: center; }
.hero-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%); z-index: 1; }
.hero-content { position: relative; z-index: 2; max-width: 900px; width: 100%; }
.hero-title { font-size: 3.8rem; color: #ffffff; margin-bottom: 25px; line-height: 1.2; font-weight: 800; word-break: break-word; }
.hero-subtitle { font-size: 1.4rem; color: #cbd5e1; margin-bottom: 45px; }
.hero-buttons { display: flex; gap: 20px; justify-content: center; }

.sticky-story-wrapper { display: flex; align-items: flex-start; gap: 80px; width: 100%; }
.sticky-sidebar { position: -webkit-sticky; position: sticky; top: 100px; flex: 1; max-width: 480px; }
.about-intro { font-size: 1rem; color: var(--text-secondary); line-height: 1.6; }
.about-intro p { margin-bottom: 14px; }

.story-carousel-container { flex: 1; width: 100%; min-width: 0; position: relative; }
.story-carousel-btn { display: none; }

.scrolling-cards { flex: 1; display: flex; flex-direction: column; gap: 50px; width: 100%; }
.story-card { background-color: var(--bg-card); padding: 50px 40px; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); transition: var(--transition); }
.story-card:hover { border-color: var(--accent); transform: translateY(-5px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); }
.story-card h3 { font-size: 1.8rem; color: var(--text-primary); margin-bottom: 20px; }
.story-card p { font-size: 1.1rem; color: var(--text-secondary); }

.diagram-box { 
    background-color: var(--bg-main); 
    padding: 20px 30px; 
    border-radius: 8px; 
    border: 1px dashed var(--border); 
    margin: 30px auto; 
    display: flex;
    justify-content: center;
    align-items: center;
    width: max-content;
    max-width: 100%;
}
.diagram-box p { 
    margin: 0; 
    font-size: 1.1rem; 
    white-space: nowrap; 
    font-weight: bold; 
    text-align: center;
}

#servicios { padding: 100px 0 80px 0; }
#servicios .section-header { margin-bottom: 45px; }
.services-grid-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 25px; margin-bottom: 60px; width: 100%; }
.service-box { background-color: var(--bg-card); padding: 40px 20px; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; text-align: center; transition: var(--transition); }
.service-box:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15); }
.service-emoji { font-size: 3.2rem; margin-bottom: 20px; display: block; line-height: 1; filter: drop-shadow(0px 4px 6px rgba(0,0,0,0.1)); }
.service-box h3 { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); line-height: 1.4; margin-bottom: 0; }

.maquilado-container { margin-top: 60px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 50px; box-shadow: var(--shadow); }
.m-title { font-size: 2.2rem; color: var(--heading-color); margin-bottom: 5px; text-align: center; }
.m-subtitle { font-size: 1.2rem; color: var(--text-secondary); text-align: center; margin-bottom: 40px; }
.m-main-image { width: 100%; height: 400px; border-radius: 12px; overflow: hidden; margin-bottom: 40px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); }
.m-main-image img { width: 100%; height: 100%; object-fit: cover; }
.m-content { font-size: 1.15rem; color: var(--text-primary); text-align: center; max-width: 900px; margin: 0 auto 40px auto; line-height: 1.8; }
.m-services-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 50px; }
.m-service-item { background: var(--bg-main); padding: 15px 20px; border-radius: 8px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); transition: var(--transition); }
.m-service-item:hover { border-color: var(--accent); transform: translateY(-3px); }
.m-service-item span { font-size: 1.5rem; }

.carousel-container { position: relative; display: flex; align-items: center; width: 100%; gap: 15px; }
.carousel-btn { background: var(--bg-main); border: 1px solid var(--border); color: var(--text-primary); border-radius: 50%; width: 45px; height: 45px; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: var(--transition); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.carousel-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.carousel-btn:disabled { opacity: 0.3; cursor: default; pointer-events: none; background: var(--bg-main) !important; color: var(--text-secondary) !important; border-color: var(--border) !important; box-shadow: none !important; }

.carousel-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; gap: 30px; scrollbar-width: none; -ms-overflow-style: none; flex-grow: 1; padding: 15px 5px; }
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-slide { flex: 0 0 100%; scroll-snap-align: center; position: relative; border-radius: 12px; overflow: hidden; height: 300px; box-shadow: var(--shadow); }
.carousel-slide img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.carousel-slide:hover img { transform: scale(1.05); }
.slide-caption { position: absolute; bottom: 0; left: 0; width: 100%; background: linear-gradient(transparent, rgba(0,0,0,0.9)); padding: 20px 15px; color: #fff; font-weight: 700; text-align: center; font-size: 1.1rem; }

@media (min-width: 768px) { .carousel-slide { flex: 0 0 calc(50% - 15px); } }
@media (min-width: 1024px) { .carousel-slide { flex: 0 0 calc(33.333% - 20px); } }

#contacto { padding: 90px 0 80px 0; }
#contacto .section-header { margin-bottom: 40px; }
.contact-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 30px; width: 100%; }
.contact-info-card, .contact-form-card { background-color: var(--bg-card); padding: 40px 35px; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.contact-info-card h3 { font-size: 1.6rem; color: var(--text-primary); margin-bottom: 20px; position: relative; z-index: 2; }
.contact-info-card p { color: var(--text-secondary); font-size: 1.1rem; position: relative; z-index: 2; }
.contact-bg-icon { position: absolute; bottom: -20px; right: -20px; opacity: 0.05; z-index: 1; pointer-events: none; }
[data-theme="dark"] .contact-bg-icon { opacity: 0.15; }
.map-container { margin-top: 25px; border-radius: 8px; overflow: hidden; position: relative; z-index: 2; border: 1px solid var(--border); box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.map-container iframe { width: 100%; display: block; }
.form-group { margin-bottom: 20px; width: 100%; }
.form-group label { display: block; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; font-size: 1rem; }
.form-group input, .form-group textarea { width: 100%; padding: 14px; border-radius: 8px; border: 1px solid var(--border); background-color: var(--bg-main); color: var(--text-primary); font-family: inherit; font-size: 1.05rem; transition: var(--transition); }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15); }

.site-footer { background-color: #0f172a; color: #94a3b8; text-align: center; padding: 15px 0; }
.site-footer p { margin: 0; font-size: 14px; white-space: nowrap; }

@media (max-width: 992px) {
    .sticky-story-wrapper { flex-direction: column; gap: 40px; align-items: stretch; }
    .sticky-sidebar { position: relative; top: 0; max-width: 100%; }
    .section-header.align-left { text-align: center; margin-bottom: 50px; }
    .section-header.align-left .heading-line { margin: 0 auto 20px auto; }
    .about-intro { text-align: center; font-size: 1.15rem; }
    
    .nav-links { position: static; transform: none; margin-left: auto; margin-right: 20px; }
    .contact-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .hamburger { display: flex; }
    .nav-links { position: fixed; top: 73px; left: -100%; width: 100vw; height: calc(100vh - 73px); background-color: var(--bg-card); flex-direction: column; justify-content: center; gap: 35px; transition: var(--transition); border-top: 1px solid var(--border); z-index: 999; }
    .nav-links.active { left: 0; }
    .nav-links a { font-size: 1.4rem; }
    .nav-btn-contact { width: 80%; text-align: center; padding: 15px; font-size: 1.2rem !important; }
    .hamburger.open span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
    .hamburger.open span:nth-child(2) { opacity: 0; }
    .hamburger.open span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

    section { padding: 80px 0; } 
    section.hero-section { padding: 180px 20px 80px 20px; }

    .section-header h2 { font-size: 2.2rem; }
    .hero-title { font-size: 2.5rem; word-break: break-word; }
    .hero-subtitle { font-size: 1.2rem; }
    .hero-buttons { flex-direction: column; gap: 15px; width: 100%; }
    
    .story-carousel-container {
        position: relative;
        display: flex;
        align-items: center;
        width: 100%;
        padding: 0 45px; 
        box-sizing: border-box;
    }
    .story-carousel-btn {
        display: flex;
        position: absolute;
        z-index: 10;
        top: 50%;
        transform: translateY(-50%);
        background: var(--bg-main);
        border: 1px solid var(--border);
        color: var(--text-primary);
        border-radius: 50%;
        width: 35px;
        height: 35px;
        font-size: 1.1rem;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
    .story-carousel-btn.prev-btn { left: 0; }
    .story-carousel-btn.next-btn { right: 0; }
    .story-carousel-btn:disabled { opacity: 0.3; cursor: default; pointer-events: none; background: var(--bg-main) !important; color: var(--text-secondary) !important; border-color: var(--border) !important; box-shadow: none !important; }

    .scrolling-cards { 
        display: flex; 
        flex-direction: row; 
        overflow-x: auto; 
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory; 
        gap: 15px; 
        padding-bottom: 10px; 
        scrollbar-width: none; 
        align-items: stretch; 
        scroll-behavior: smooth;
        width: 100%;
    }
    .scrolling-cards::-webkit-scrollbar { display: none; }
    .scrolling-cards::after { content: ''; flex: 0 0 1px; }

    .story-card { 
        flex: 0 0 auto;
        min-width: 100%; 
        width: 100%;
        max-width: 100%;
        scroll-snap-align: center; 
        padding: 25px 20px; 
        margin: 0;
        height: auto; 
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    .story-card h3 { font-size: 1.3rem; margin-bottom: 12px; text-align: center; }
    .story-card p { font-size: 0.85rem; margin-bottom: 10px; text-align: justify; }

    .valores-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .valores-grid p { font-size: 0.75rem !important; line-height: 1.3; margin-bottom: 0; text-align: left; }

    .diagram-box { 
        background-color: var(--bg-main);
        padding: 12px 10px;
        border-radius: 8px;
        border: 1px dashed var(--border);
        margin: 15px 0 0 0;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        min-width: 0;
    }

    .services-grid-row { grid-template-columns: repeat(2, 1fr); gap: 15px; }
    .service-box { padding: 25px 15px; }
    .service-emoji { font-size: 2.5rem; }
    .service-box h3 { font-size: 0.95rem; }
    
    .maquilado-container { padding: 30px 20px; margin-top: 40px; }
    .m-title { font-size: 2rem; }
    .m-main-image { height: 200px; margin-bottom: 25px; }
    
    .m-services-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .m-service-item { flex-direction: column; text-align: center; padding: 15px 5px; gap: 5px; font-size: clamp(0.65rem, 2.5vw, 0.9rem); }
    .m-service-item span { font-size: 1.8rem; margin: 0; }

    .carousel-btn { display: none; }
    .carousel-track { gap: 15px; padding: 10px 0; }
    .carousel-slide { 
        height: 220px; 
        flex: 0 0 85%; 
        scroll-snap-align: start; 
    }
    .slide-caption { font-size: 0.95rem; padding: 15px 10px; }
    
    .contact-info-card, .contact-form-card { padding: 30px 20px; width: 100%; min-width: 0; margin-left: 0; margin-right: 0; }

    .site-footer { padding: 12px 0; }
    .site-footer p { font-size: 12px; white-space: nowrap; margin: 0; text-align: center; }
}