/* =====================================================
   VARIABLES GLOBALES
===================================================== */
:root {
    --header-height: 90px;
    --mobile-nav-timing: 0.3s;
    --primary-color: #1e3d59;
    --primary-blue: #1e3d59;
    --primary-green: #17b978;
}

/* Base Responsive Adjustments */
html {
    font-size: 16px;
}

@media (max-width: 768px) { html { font-size: 15px; } }
@media (max-width: 480px) { html { font-size: 14px; } }

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

@media (max-width: 1240px) {
    .container { max-width: 100%; }
}

/* =====================================================
   HEADER
===================================================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: #fff;
    box-shadow: 0 2px 12px rgba(30,61,89,.08);
    z-index: 1000;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
}

.header.hide {
    transform: translateY(-100%);
}

.header.scrolled {
    box-shadow: 0 4px 24px rgba(30,61,89,.14);
}

/* =====================================================
   NAV
===================================================== */
.nav {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* Logo */
.logo a { display: flex; align-items: center; }
.logo img {
    height: 72px;
    width: auto;
    display: block;
}

/* Nav links — desktop */
.nav-links {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    flex-wrap: nowrap;
}

.nav-links a {
    text-decoration: none;
    color: #1e3d59;
    font-weight: 500;
    font-size: .9rem;
    white-space: nowrap;
    transition: color .2s;
    position: relative;
}

.nav-links a:not(.btn):hover { color: #17b978; }

/* Línea verde bajo el link activo */
.nav-links a.active {
    color: #17b978;
    font-weight: 700;
}
.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: #17b978;
    border-radius: 2px;
}

/* Botón Solicitar Presupuesto */
.nav-links .btn-primary {
    background: #17b978;
    color: #fff !important;
    padding: .52rem 1.2rem;
    border-radius: 6px;
    font-size: .87rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .2s, transform .2s;
}
.nav-links .btn-primary:hover {
    background: #14a86a;
    transform: translateY(-1px);
}
.nav-links .btn-primary::after { display: none; }

/* Botón hamburguesa */
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #1e3d59;
    cursor: pointer;
    padding: .4rem .5rem;
    z-index: 1001;
    transition: color .2s;
    flex-shrink: 0;
}
.nav-toggle:hover { color: #17b978; }

/* =====================================================
   RESPONSIVE — pantallas medianas (sin hamburguesa aún)
===================================================== */
@media (max-width: 1100px) {
    .nav-links { gap: 1rem; }
    .nav-links a { font-size: .85rem; }
    .nav-links .btn-primary { padding: .5rem 1rem; font-size: .83rem; }
}

/* =====================================================
   RESPONSIVE — menú hamburguesa (≤ 992px)
===================================================== */
@media (max-width: 992px) {

    .nav-toggle { display: flex; }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 78%;
        max-width: 340px;
        height: 100vh;
        background: #fff;
        padding: calc(var(--header-height) + 1.5rem) 1.8rem 2rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        transition: right var(--mobile-nav-timing) cubic-bezier(.4,0,.2,1);
        box-shadow: -4px 0 24px rgba(30,61,89,.15);
        overflow-y: auto;
        z-index: 1000;
    }

    .nav-links.active { right: 0; }

    .nav-links a {
        width: 100%;
        font-size: 1rem;
        font-weight: 500;
        padding: .9rem 0;
        border-bottom: 1px solid #f0f0f0;
        color: #1e3d59;
    }
    .nav-links a:last-child { border-bottom: none; }
    .nav-links a.active::after { display: none; }

    .nav-links .btn-primary {
        margin-top: 1.2rem;
        width: 100%;
        text-align: center;
        padding: .8rem 1rem;
        border-radius: 8px;
        font-size: .95rem;
        border-bottom: none;
    }

    /* Overlay oscuro detrás del panel */
    .nav::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--mobile-nav-timing) ease;
        z-index: 999;
    }
    .nav.menu-open::after {
        opacity: 1;
        visibility: visible;
    }
}

/* =====================================================
   RESPONSIVE — móvil pequeño (≤ 480px)
===================================================== */
@media (max-width: 480px) {
    :root { --header-height: 72px; }
    .logo img { height: 58px; }
    .nav-links { width: 88%; max-width: none; }
}

/* Grid Systems */
.grid {
    display: grid;
    gap: 2rem;
}

@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr !important;
    }
}

/* Hero Sections */
.hero-section {
    padding: calc(var(--header-height) + 3rem) 0 5rem;
}

@media (max-width: 768px) {
    .hero-section {
        padding: calc(var(--header-height) + 2rem) 0 3rem;
        text-align: center;
    }
}

/* Services Grid */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

/* Blog Grid */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

@media (max-width: 640px) {
    .blog-grid {
        grid-template-columns: 1fr;
    }
}

/* Forms */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    input, select, textarea {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }
}

/* Footer */
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

@media (max-width: 768px) {
    .footer-grid {
        text-align: center;
    }

    .footer-info img {
        margin: 0 auto;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.animate-on-scroll {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Touch Optimizations */
@media (hover: none) {
    /* Increase touch targets */
    .nav-links a,
    .btn,
    .service-card,
    .blog-card {
        padding: 1rem 1.5rem;
    }

    /* Remove hover effects */
    .btn:hover,
    .nav-links a:hover {
        transform: none;
    }
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Performance Optimizations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Image Optimizations */
img {
    max-width: 100%;
    height: auto;
}

/* Loading States */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .nav-toggle,
    .btn {
        display: none !important;
    }

    body {
        padding: 0;
        margin: 0;
    }

    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }
}