
/* RESET & BASE */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--site-ink);
    background-color: var(--site-bg);
    overflow-x: hidden;
    /* Offset para topbar fija */
    padding-top: var(--demo-topbar-offset);
    transition: background-color 0.3s, color 0.3s;
}
img, video { max-width: 100%; height: auto; display: block; }
button, input, textarea { font: inherit; }
ul { list-style: none; }
a { text-decoration: none; color: inherit; transition: opacity 0.2s; }

/* VARIABLES & TOKENS (OBLIGATORIO) */
:root {
    /* Identidad */
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --secondary: #ec4899; /* Acento vibrante */
    --site-bg: #ffffff;
    --site-ink: #0f172a;
    --site-ink-inverse: #f8fafc;
    --surface: #f1f5f9;
    --border: #e2e8f0;

    /* DEMO LAYER TOKENS (INVARIANTES) */
    --demo-accent: #22c55e;
    --demo-topbar-text: #ffffff;
    --demo-link: #86efac;
    --demo-link-shadow: 0 0 10px rgba(34,197,94,.35);
    --demo-glow: 0 0 0 3px rgba(34,197,94,.25), 0 0 12px rgba(34,197,94,.6);

    /* DEMO ADAPTATIVE */
    --demo-topbar-bg: rgba(6,24,14,.92); /* Fondo oscuro fijo */
    --demo-note-bg: rgba(34,197,94,.10);
    --demo-note-border: rgba(34,197,94,.3);
    --demo-note-text: var(--site-ink);
    --demo-shadow: 0 10px 30px rgba(0,0,0,.15);
    --demo-radius: 12px;
    --demo-font: ui-sans-serif, system-ui, sans-serif;
    --demo-z: 9999;

    /* OFFSETS CALCULADOS */
    --demo-topbar-h: 48px; /* Altura estimada inicial */
    --site-nav-h: 70px;
    --demo-safe-top: env(safe-area-inset-top, 0px);
    --demo-topbar-offset: calc(var(--demo-topbar-h) + var(--demo-safe-top));
}

/* PRESET B: MODERN GRADIENT (Modo Diseño Original) */
body.preset-modern {
    --site-bg: #f8fafc;
    background-image: radial-gradient(at top right, #e0e7ff 0%, transparent 40%),
                      radial-gradient(at bottom left, #fce7f3 0%, transparent 40%);
    background-attachment: fixed;
}

/* FOCUS VISIBLE (ACCESIBILIDAD) */
:focus-visible { outline: 3px solid rgba(34,197,94,.85); outline-offset: 3px; }

/* LAYOUT UTILS */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding-inline: 20px;
}
section {
    padding-block: 60px;
    position: relative;
    scroll-margin-top: calc(var(--demo-topbar-offset) + var(--site-nav-h) + 20px);
}

/* TYPOGRAPHY */
h1, h2, h3 { line-height: 1.2; font-weight: 800; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.5rem, 5vw, 4rem); margin-bottom: 24px; }
h2 { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: 32px; color: var(--site-ink); }
h3 { font-size: 1.5rem; margin-bottom: 12px; }
p { margin-bottom: 16px; color: #475569; font-size: 1.125rem; }

/* --- DEMO LAYER STYLES --- */
#demo-layer .demo-topbar {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: var(--demo-z);
    background: var(--demo-topbar-bg);
    color: var(--demo-topbar-text);
    box-shadow: var(--demo-shadow);
    font-family: var(--demo-font);
    backdrop-filter: blur(8px);
    height: var(--demo-topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: 20px;
    font-size: 13px;
}
#demo-layer .demo-topbar a {
    color: var(--demo-link);
    text-shadow: var(--demo-link-shadow);
    font-weight: 600;
}
#demo-layer .demo-dot {
    width: 8px; height: 8px; border-radius: 50%; display: inline-block;
    box-shadow: var(--demo-glow); background: var(--demo-accent);
    margin-right: 8px;
}
/* Mobile Topbar stack */
@media (max-width: 600px) {
    #demo-layer .demo-topbar {
        flex-direction: column; justify-content: center; gap: 4px; height: auto; padding-block: 8px; text-align: center;
    }
}

#demo-layer .demo-note {
    margin-top: 24px;
    padding: 16px;
    border-radius: var(--demo-radius);
    border: 1px solid var(--demo-note-border);
    background: var(--demo-note-bg);
    color: var(--demo-note-text);
    box-shadow: 0 0 0 1px rgba(0,0,0,.05) inset;
    backdrop-filter: blur(6px);
    font-size: 0.95rem;
    max-width: 800px;
}
#demo-layer .demo-note .demo-note-prefix {
    color: var(--demo-accent); font-weight: 800; display: block; margin-bottom: 4px;
}

/* --- COMPONENTES UI --- */

/* NAV (Sticky) */
.main-nav {
    position: sticky;
    top: var(--demo-topbar-offset);
    z-index: 1000;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    height: var(--site-nav-h);
    display: flex; align-items: center;
}
.nav-container { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.logo { font-weight: 900; font-size: 1.25rem; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.nav-links { display: flex; gap: 32px; }
.nav-links a { font-weight: 500; font-size: 0.95rem; }
.nav-links a:hover, .nav-links a.active { color: var(--primary); }
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 24px; border-radius: 50px;
    font-weight: 600; text-align: center; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6); }
.mobile-toggle { display: none; background: none; border: none; font-size: 1.5rem; color: var(--site-ink); cursor: pointer; }

/* HERO */
.hero {
    min-height: 80vh; display: flex; align-items: center; color: white;
    background: #000; overflow: hidden;
}
.hero-video {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover; opacity: 0.5; z-index: 0;
}
.hero-content { position: relative; z-index: 1; text-align: center; max-width: 800px; margin: 0 auto; }
.hero p { color: rgba(255,255,255,0.9); font-size: 1.25rem; }

/* CARDS (Servicios/Beneficios) */
.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 32px;
}
.card {
    background: white; padding: 32px; border-radius: 20px;
    border: 1px solid var(--border);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex; flex-direction: column;
    height: 100%;
}
.card:hover { transform: translateY(-5px); box-shadow: 0 20px 40px rgba(0,0,0,0.05); border-color: var(--primary); }
.card-icon { font-size: 2rem; margin-bottom: 16px; color: var(--secondary); }
.card h3 { font-size: 1.25rem; }

/* GALLERY (Dark Theme Local) */
.gallery-section { background: #1e293b; color: white; }
.gallery-section h2, .gallery-section p { color: white; }
.gallery-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px;
}
.gallery-item {
    position: relative; overflow: hidden; border-radius: 12px; aspect-ratio: 4/3; cursor: pointer;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.gallery-item:hover img { transform: scale(1.1); }
.gallery-label {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.7); color: white;
    padding: 12px; transform: translateY(100%); transition: transform 0.3s;
    font-size: 0.9rem;
}
.gallery-item:hover .gallery-label { transform: translateY(0); }

/* LIGHTBOX */
.lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); z-index: 10000;
    display: none; justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.3s;
}
.lightbox.open { display: flex; opacity: 1; }
.lightbox img { max-height: 85vh; max-width: 90vw; border-radius: 8px; }
.lb-close, .lb-prev, .lb-next {
    position: absolute; color: white; font-size: 2rem; cursor: pointer;
    background: none; border: none; padding: 20px; z-index: 10001;
}
.lb-close { top: 20px; right: 20px; }
.lb-prev { left: 20px; }
.lb-next { right: 20px; }

/* FAQ ACCORDION */
.accordion-item { border-bottom: 1px solid var(--border); }
.accordion-header {
    width: 100%; text-align: left; padding: 20px 0; background: none; border: none;
    font-weight: 600; font-size: 1.1rem; cursor: pointer;
    display: flex; justify-content: space-between;
}
.accordion-content {
    max-height: 0; overflow: hidden; transition: max-height 0.3s ease; color: #475569;
}
.accordion-content.open { max-height: 200px; padding-bottom: 20px; }

/* FOOTER */
footer { background: #0f172a; color: #94a3b8; padding: 40px 0; font-size: 0.9rem; margin-top: 60px; }
footer a { color: white; }

/* WA BUTTON */
.wa-float {
    position: fixed; bottom: 24px; right: 24px;
    width: 60px; height: 60px; background: #25D366;
    border-radius: 50%; box-shadow: 0 10px 25px rgba(37, 211, 102, 0.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 9000; color: white; font-size: 32px;
}
.wa-float:hover { transform: scale(1.1); }

/* A/B TESTING */
body.ab-b .btn-primary { border-radius: 4px; text-transform: uppercase; letter-spacing: 1px; }
body.ab-b .card { border: none; box-shadow: 0 4px 6px -1px rgba(0,0,0,.1); }

/* RESPONSIVE GARANTIA < 768px (1 COLUMNA) */
@media (max-width: 768px) {
    .nav-links {
        position: fixed; top: calc(var(--demo-topbar-offset) + var(--site-nav-h));
        left: 0; width: 100%; height: calc(100vh - (var(--demo-topbar-offset) + var(--site-nav-h)));
        background: white; flex-direction: column; padding: 24px; gap: 24px;
        transform: translateX(100%); transition: transform 0.3s ease;
        overflow-y: auto; border-top: 1px solid var(--border);
    }
    .nav-links.active { transform: translateX(0); }
    .mobile-toggle { display: block; }
    
    .grid-auto, .gallery-grid { grid-template-columns: 1fr; }
    
    /* Anti-overflow */
    .hero h1 { font-size: 2.5rem; }
    section { overflow: hidden; } /* Contención local */
    
    /* Gallery Label Mobile */
    .gallery-label { transform: translateY(0); background: rgba(0,0,0,0.5); position: relative; }
}
