/* ================================================================
   CODEX · responsive.css
   Parche de responsive para TODAS las páginas.
   Cargar DESPUÉS de styles.css / cotizacion.css / tienda.css
   ================================================================ */

/* ══════════════════════════════════════════════════════════════
   1. VARIABLES Y BASE
══════════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

img,
video,
svg {
    max-width: 100%;
}

/* ══════════════════════════════════════════════════════════════
   2. NAVBAR — HAMBURGUESA (index.html)
══════════════════════════════════════════════════════════════ */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: background .15s;
    flex-shrink: 0;
    margin-left: .25rem;
}

.nav-hamburger:hover {
    background: var(--bg-2, #f5f5f7);
}

.nav-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--ink, #1d1d1f);
    border-radius: 2px;
    transition: transform .3s cubic-bezier(0.22, 1, 0.36, 1), opacity .2s;
    transform-origin: center;
}

.nav-hamburger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-hamburger.open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.nav-hamburger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Menú móvil desplegable */
.nav-mobile-menu {
    display: none;
    position: fixed;
    inset: 0;
    top: 58px;
    /* altura del header */
    z-index: 1100;
    background: var(--bg-card, #fff);
    padding: 1.5rem 1.25rem 2rem;
    flex-direction: column;
    gap: .25rem;
    overflow-y: auto;
    animation: mobileMenuIn .28s cubic-bezier(0.22, 1, 0.36, 1) both;
    border-top: 1px solid var(--line-2, #e8e8ed);
}

.nav-mobile-menu.open {
    display: flex;
}

@keyframes mobileMenuIn {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-mobile-link {
    display: block;
    padding: .9rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--ink, #1d1d1f);
    text-decoration: none;
    border-radius: 10px;
    transition: background .15s, color .15s;
}

.nav-mobile-link:hover {
    background: var(--bg-2, #f5f5f7);
    color: var(--primary, #3d0022);
}

.nav-mobile-cta {
    margin-top: .75rem;
    background: var(--primary, #3d0022) !important;
    color: white !important;
    text-align: center;
    font-weight: 600;
    border-radius: 12px !important;
}

.nav-mobile-cta:hover {
    opacity: .88;
}

[data-theme="dark"] .nav-mobile-menu {
    background: var(--bg-card, #1c1c1e);
}

[data-theme="dark"] .nav-hamburger span {
    background: var(--ink, #f5f5f7);
}

/* ══════════════════════════════════════════════════════════════
   3. INDEX — HERO Y SECCIONES
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Mostrar hamburguesa, ocultar nav-menu de escritorio */
    .nav-menu {
        display: none !important;
    }

    .nav-hamburger {
        display: flex;
    }

    /* Hero más compacto */
    .hero {
        min-height: auto;
        padding: 0;
    }

    .hero-container {
        padding: 4.5rem 1.25rem 3.5rem;
    }

    .hero h1 {
        font-size: clamp(2rem, 8vw, 2.8rem);
    }

    .hero p {
        font-size: .94rem;
    }

    .hero-buttons {
        gap: .6rem;
    }

    .btn-primary,
    .btn-secondary {
        font-size: .84rem;
        padding: .65rem 1.25rem;
    }

    .hero-stats {
        gap: 1.5rem;
        flex-wrap: wrap;
        margin-top: 2.5rem;
    }

    .hero-stat-value {
        font-size: 1.5rem;
    }

    /* Secciones */
    .section {
        padding: 3.5rem 1.25rem;
    }

    .section-header {
        margin-bottom: 2.5rem;
    }

    .section-header h2 {
        font-size: clamp(1.6rem, 6vw, 2.2rem);
    }

    /* Products grid */
    .products-grid {
        grid-template-columns: 1fr;
    }

    .products-filter {
        gap: .3rem;
    }

    .filter-btn {
        font-size: .75rem;
        padding: .3rem .75rem;
    }

    /* Tienda section en index */
    .tienda-cats {
        grid-template-columns: 1fr 1fr;
        gap: .85rem;
    }

    .tienda-cat-visual {
        height: 130px;
    }

    .tienda-benefits {
        flex-direction: column;
    }

    .tienda-benefit {
        border-right: none;
        border-bottom: 1px solid var(--line-2, #e8e8ed);
    }

    .tienda-benefit:last-child {
        border-bottom: none;
    }

    /* Contacto */
    .contact-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .contact-card {
        padding: 1.5rem 1.25rem;
    }

    /* Footer */
    .footer-container {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .hero-container {
        padding: 3.5rem 1rem 2.5rem;
    }

    .tienda-cats {
        grid-template-columns: 1fr;
    }

    .contact-grid {
        grid-template-columns: 1fr;
    }

    .values-grid {
        grid-template-columns: 1fr;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary,
    .btn-secondary {
        justify-content: center;
        width: 100%;
    }

    /* Modal de producto en index */
    .service-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .service-modal {
        border-radius: 20px 20px 0 0;
        max-height: 90vh;
    }

    .service-modal-columns {
        grid-template-columns: 1fr;
    }

    .service-modal-footer {
        flex-direction: column;
    }

    .service-modal-cta,
    .btn-secondary-outline {
        width: 100%;
        text-align: center;
    }
}

/* ══════════════════════════════════════════════════════════════
   4. COTIZACIÓN — FIX CRÍTICO
   El problema: height:100vh + overflow:hidden bloquea el scroll
   en móvil y oculta el botón "siguiente".
══════════════════════════════════════════════════════════════ */

/* ── Tablet (≤ 900px) ── */
@media (max-width: 900px) {
    :root {
        --cfg-panel-w: 340px;
    }

    .cfg-topbar {
        padding: 0 1rem;
        gap: .5rem;
    }

    .cfg-btn-summary {
        display: none;
    }

    /* se mueve al menú */
    .cfg-title-text {
        display: none;
    }
}

/* ── Móvil (≤ 700px) — FIX PRINCIPAL ── */
@media (max-width: 700px) {

    /* 1. Eliminar overflow:hidden que bloquea el scroll */
    .configurator-page {
        height: auto !important;
        overflow: visible !important;
        min-height: 100dvh;
    }

    /* 2. Layout: apilar preview arriba, panel abajo */
    .cfg-layout {
        flex-direction: column;
        height: auto !important;
        overflow: visible !important;
        min-height: calc(100dvh - var(--cfg-topbar-h, 58px));
    }

    /* 3. Preview: altura fija y compacta */
    .cfg-preview {
        height: 240px !important;
        min-height: 240px;
        max-height: 240px;
        flex-shrink: 0;
        overflow: hidden;
    }

    /* Ocultar thumbs y stepper en preview móvil — se mueven al panel */
    .cfg-preview-thumbs {
        display: none;
    }

    .cfg-steps-bar {
        position: sticky;
        top: var(--cfg-topbar-h, 58px);
        z-index: 50;
        background: var(--bg-card, #fff);
        border-bottom: 1px solid var(--line-2, #e8e8ed);
        padding: .5rem .75rem;
        gap: 0;
    }

    .cfg-step-lbl {
        display: none;
    }

    /* solo número en móvil */
    .cfg-step-num {
        width: 26px;
        height: 26px;
        font-size: .75rem;
    }

    /* 4. Panel derecho: altura auto con scroll propio */
    .cfg-panel {
        width: 100% !important;
        border-left: none !important;
        border-top: 1px solid var(--line-2, #e8e8ed);
        height: auto !important;
        overflow: visible !important;
        flex: 1;
    }

    /* 5. Cada pane: scroll interno + padding para el botón fijo */
    .cfg-pane {
        height: auto !important;
        overflow: visible !important;
    }

    /* 6. Lista de módulos: altura auto (sin overflow:hidden implícito) */
    .cfg-module-list {
        max-height: none !important;
        overflow: visible !important;
    }

    /* 7. Footer del pane: sticky al bottom de la pantalla */
    .cfg-pane-footer {
        position: sticky;
        bottom: 0;
        z-index: 40;
        background: var(--bg-card, #fff);
        border-top: 1px solid var(--line-2, #e8e8ed);
        padding: .85rem 1rem;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, .08);
    }

    .cfg-pane-footer--2col {
        display: flex;
        gap: .6rem;
    }

    /* 8. Topbar compacta */
    .cfg-topbar {
        padding: 0 .85rem;
        gap: .4rem;
        height: 52px;
    }

    .cfg-btn-contact {
        display: none;
    }

    .cfg-btn-summary {
        display: none;
    }

    .cfg-title-text {
        display: none;
    }

    .cfg-logo {
        height: 22px;
    }

    .cfg-title-sep {
        display: none;
    }

    .cfg-price-amount {
        font-size: .95rem;
    }

    .cfg-price-label {
        font-size: .6rem;
    }

    /* 9. Botones a ancho completo */
    .cfg-btn-primary,
    .cfg-btn-secondary,
    .cfg-btn-submit {
        width: 100%;
        justify-content: center;
    }

    .cfg-btn-secondary {
        flex: 0 0 auto;
        width: auto;
        min-width: 80px;
    }

    /* 10. Formulario paso 3: una columna */
    .cfg-form-row {
        grid-template-columns: 1fr !important;
    }

    .cfg-form {
        padding: 1rem;
        gap: .75rem;
        overflow: visible;
    }

    /* 11. Addons: panel scrolleable */
    .cfg-addon-sections {
        max-height: none !important;
        overflow: visible !important;
    }

    /* 12. Resumen paso 4 */
    #quoteSummaryContent {
        overflow: visible !important;
        padding: 1rem;
    }

    .cfg-summary-client {
        grid-template-columns: 1fr;
    }

    /* 13. Modal personalizado */
    .cfg-modal {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    /* 14. Dashboard compacto */
    .cfg-dashboard {
        padding: .5rem .75rem;
    }

    .cfg-browser-bar {
        height: 28px;
    }

    .cfg-browser-url {
        font-size: .58rem;
    }

    .dash-8codex {
        height: 200px;
    }

    .dash-kpis {
        gap: .3rem;
    }

    .dash-kpi-val {
        font-size: .75rem;
    }

    /* 15. Succes state */
    .cfg-success {
        padding: 1.5rem 1rem;
    }
}

/* ── Extra pequeño (≤ 400px) ── */
@media (max-width: 400px) {
    .cfg-topbar {
        padding: 0 .65rem;
    }

    .cfg-back span {
        display: none;
    }

    /* Solo ícono de volver */
    .cfg-pane-header {
        padding: 1.25rem 1rem .75rem;
    }

    .cfg-pane-header h2 {
        font-size: .95rem;
    }

    .cfg-module-row {
        padding: .75rem 1rem;
        gap: .65rem;
    }

    .cfg-module-row-name {
        font-size: .82rem;
    }

    .cfg-module-row-price {
        font-size: .78rem;
    }

    .cfg-module-row-icon {
        width: 34px;
        height: 34px;
        border-radius: 8px;
    }
}

/* ══════════════════════════════════════════════════════════════
   5. TIENDA — RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .store-topbar-inner {
        padding: 0 1rem;
        gap: .75rem;
    }

    .store-brand-label {
        display: none;
    }

    .store-search-wrap {
        flex: 1;
    }

    .store-layout {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1.25rem;
    }

    .store-sidebar {
        position: static;
    }

    .store-cat-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .25rem;
    }

    .store-products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    /* Modal producto */
    .store-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .store-modal {
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
    }

    .store-modal-body {
        grid-template-columns: 1fr;
    }

    .store-modal-visual {
        border-radius: 20px 20px 0 0;
        height: 200px;
        min-height: 200px;
    }

    .store-modal-info {
        padding: 1.25rem;
    }

    /* Cart drawer */
    .store-cart-drawer {
        width: 100%;
    }

    /* Checkout */
    .store-checkout-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .store-checkout-modal {
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
    }

    .store-checkout-layout {
        grid-template-columns: 1fr;
    }

    .store-checkout-left {
        padding: 1.25rem;
    }

    .store-checkout-right {
        padding: 1.25rem;
        border-radius: 0 0 20px 20px;
    }

    .store-pay-row2 {
        grid-template-columns: 1fr;
    }

    /* Payment error */
    .store-payment-error {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .store-hero {
        padding: 2.5rem 1rem 2rem;
        min-height: auto;
    }

    .store-hero h1 {
        font-size: 1.75rem;
    }

    .store-hero-badges {
        gap: .4rem;
    }

    .store-hero-badge {
        font-size: .72rem;
        padding: .25rem .65rem;
    }

    .store-products-grid {
        grid-template-columns: 1fr;
    }

    .store-cat-list {
        grid-template-columns: 1fr;
    }

    .store-topbar-inner {
        height: 52px;
    }

    .store-search-wrap {
        display: none;
    }

    /* ocultar en muy pequeño, búsqueda en sidebar */
}

/* ══════════════════════════════════════════════════════════════
   6. LOGIN — RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .login-layout {
        grid-template-columns: 1fr;
    }

    .login-brand {
        display: none;
    }

    .login-mobile-logo {
        display: block;
    }

    .login-form-panel {
        padding: 2rem 1.5rem;
        min-height: 100dvh;
        align-items: flex-start;
        padding-top: 3rem;
    }

    .login-form-container {
        max-width: 100%;
    }

    #toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        width: auto;
        max-width: none;
    }
}

@media (max-width: 400px) {
    .login-form-panel {
        padding: 1.5rem 1rem;
        padding-top: 2rem;
    }
}

/* ══════════════════════════════════════════════════════════════
   7. SCROLLBAR Y TOUCH
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Mejorar scroll en iOS */
    .cfg-module-list,
    .cfg-addon-sections,
    #quoteSummaryContent,
    .store-cart-items,
    .store-modal,
    .store-checkout-modal {
        -webkit-overflow-scrolling: touch;
    }

    /* Botones más fáciles de tocar */
    .cfg-btn-primary,
    .cfg-btn-secondary,
    .cfg-btn-submit,
    .store-confirm-btn,
    .store-checkout-btn,
    .store-modal-add-btn {
        min-height: 48px;
    }

    /* Inputs más grandes para touch */
    .cfg-field input,
    .cfg-field textarea,
    .store-pay-field input,
    .input-wrap input {
        font-size: 16px !important;
        /* Previene zoom en iOS */
        min-height: 44px;
    }
}

/* ══════════════════════════════════════════════════════════════
   8. BUSCADOR SPOTLIGHT — RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    #cs-overlay {
        padding: 4vh .75rem;
        align-items: flex-start;
    }

    #cs-modal {
        border-radius: 16px;
    }

    #cs-foot {
        display: none;
    }

    #cs-body {
        max-height: 58vh;
    }

    #cs-btn kbd {
        display: none;
    }

    #cs-btn {
        padding: .26rem .55rem;
        font-size: .77rem;
    }
}

/* ══════════════════════════════════════════════════════════════
   9. UTILIDADES GENERALES
══════════════════════════════════════════════════════════════ */

/* Texto no se desborde en móvil */
h1,
h2,
h3,
h4,
p,
span,
a {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Safe area para notch (iPhone X+) */
@supports (padding: max(0px)) {

    .cfg-pane-footer,
    .store-cart-footer,
    .store-checkout-modal {
        padding-bottom: max(.85rem, env(safe-area-inset-bottom));
    }

    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* dvh para navegadores móviles modernos */
@supports (height: 100dvh) {
    .configurator-page {
        min-height: 100dvh;
    }

    .login-form-panel {
        min-height: 100dvh;
    }
}