/* Modo oscuro compartido — páginas con body.icasa-theme-enabled (inicio, servicios, nosotros, etc.) */

html[data-theme="dark"] body.icasa-theme-enabled {
    color-scheme: dark;
    --home-dark-bg: #0c1014;
    --home-dark-surface: #161d26;
    --home-dark-surface-2: #1e2833;
    --home-dark-border: rgba(255, 255, 255, 0.1);
    --home-dark-text: #e8eef4;
    --home-dark-muted: #9eb0c0;
    --home-dark-green: #3dd68c;
    --home-dark-green-soft: rgba(61, 214, 140, 0.15);
    background-color: var(--home-dark-bg);
}

/* —— Barra de navegación —— */
html[data-theme="dark"] body.icasa-theme-enabled .nav-shell-icasa.navbar,
html[data-theme="dark"] body.icasa-theme-enabled .nav-shell-icasa.navbar-transparent,
html[data-theme="dark"] body.icasa-theme-enabled .nav-shell-icasa.navbar-transparent.scrolled {
    background: rgba(12, 16, 20, 0.94) !important;
    background-color: rgba(12, 16, 20, 0.94) !important;
    background-image: none !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--home-dark-border) !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35) !important;
}

/* —— Nav desktop (≥992px): pastilla + redes —— */
@media (min-width: 992px) {
    html[data-theme="dark"] body.icasa-theme-enabled .nav-shell-icasa .nav-pill-row {
        background: rgba(255, 255, 255, 0.07);
        border: 1px solid rgba(255, 255, 255, 0.14);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.08),
            0 2px 12px rgba(0, 0, 0, 0.25);
    }

    html[data-theme="dark"] body.icasa-theme-enabled .nav-shell-icasa .nav-pill-row .nav-link {
        color: rgba(255, 255, 255, 0.7) !important;
    }

    html[data-theme="dark"] body.icasa-theme-enabled .nav-shell-icasa .nav-pill-row .nav-link:hover {
        color: #ffffff !important;
        background: rgba(255, 255, 255, 0.12);
        transform: translateY(-1px);
    }

    html[data-theme="dark"] body.icasa-theme-enabled .nav-shell-icasa .nav-pill-row .nav-link.active {
        color: #0c1014 !important;
        background: #ffffff;
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    }

    html[data-theme="dark"] body.icasa-theme-enabled .nav-shell-icasa .nav-pill-row .nav-link:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.55);
        outline-offset: 2px;
    }

    html[data-theme="dark"] body.icasa-theme-enabled .nav-social-link {
        color: rgba(255, 255, 255, 0.62);
    }

    html[data-theme="dark"] body.icasa-theme-enabled .nav-social-link:hover {
        color: #ffffff;
        background: rgba(255, 255, 255, 0.1);
    }

    html[data-theme="dark"] body.icasa-theme-enabled .nav-social-link:focus-visible {
        outline-color: rgba(255, 255, 255, 0.45);
    }

    html[data-theme="dark"] body.icasa-theme-enabled .nav-social-link--whatsapp:hover {
        color: #ffffff;
        background: rgba(255, 255, 255, 0.12);
    }
}

/* Logo cargo del pie (sin globo) */
html[data-theme="dark"] body.icasa-theme-enabled .navbar-brand .logo-icon,
html[data-theme="dark"] body.icasa-theme-enabled .icasa-nav-offcanvas__logo-icon {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    visibility: hidden;
}

html[data-theme="dark"] body.icasa-theme-enabled .navbar-brand {
    overflow: visible;
}

html[data-theme="dark"] body.icasa-theme-enabled .navbar-brand .logo-container {
    height: auto;
    min-height: 0;
    gap: 0;
    align-items: center;
    overflow: visible;
}

/* Logo cargo modo oscuro (más grande que modo claro; sin globo) */
html[data-theme="dark"] body.icasa-theme-enabled .navbar-brand .logo-wordmark--dark {
    height: clamp(4.5rem, 14vw, 7.5rem);
    width: auto;
    max-width: min(38rem, 92vw);
    object-fit: contain;
    object-position: left center;
    filter: brightness(0) invert(1) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

html[data-theme="dark"] body.icasa-theme-enabled .logo-container:hover .logo-wordmark--dark {
    filter: brightness(0) invert(1) drop-shadow(0 3px 10px rgba(0, 0, 0, 0.4));
    transform: scale(1.02);
}

html[data-theme="dark"] body.icasa-theme-enabled .icasa-nav-offcanvas__logo-wordmark--dark {
    height: clamp(4.25rem, 16vw, 6.75rem);
    width: auto;
    max-width: min(34rem, 92vw);
    object-fit: contain;
    object-position: left center;
    opacity: 1;
    filter: brightness(0) invert(1) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

@media (max-width: 991.98px) {
    html[data-theme="dark"] body.icasa-theme-enabled .navbar-brand .logo-wordmark--dark {
        height: clamp(4.15rem, 16vw, 6.5rem);
        max-width: min(32rem, 92vw);
    }
}

@media (min-width: 1200px) {
    html[data-theme="dark"] body.icasa-theme-enabled .navbar-brand .logo-wordmark--dark {
        height: clamp(5.25rem, 7.5vw, 8.5rem);
        max-width: min(40rem, 48vw);
    }
}

/* —— Botón alternar tema —— */
body.icasa-theme-enabled {
    --icasa-theme-toggle-size: 2.5rem;
    --icasa-theme-toggle-edge: max(1rem, env(safe-area-inset-right, 0px));
    --icasa-theme-toggle-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
}

body:not(.icasa-theme-enabled) .icasa-theme-toggle {
    display: none !important;
}

.icasa-theme-toggle,
.home-theme-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        opacity 0.22s ease,
        background 0.22s ease,
        color 0.22s ease,
        border-color 0.22s ease,
        box-shadow 0.22s ease,
        transform 0.18s ease;
}

/* Escritorio: fijo abajo-derecha, sutil */
@media (min-width: 769px) {
    body.icasa-theme-enabled .icasa-theme-toggle--desktop-fab {
        display: flex;
        position: fixed;
        z-index: 1039;
        top: auto;
        left: auto;
        right: var(--icasa-theme-toggle-edge);
        bottom: var(--icasa-theme-toggle-bottom);
        width: var(--icasa-theme-toggle-size);
        height: var(--icasa-theme-toggle-size);
        border: 1px solid rgba(15, 23, 42, 0.1);
        background: rgba(255, 255, 255, 0.88);
        color: #0f2d4a;
        box-shadow: 0 2px 10px rgba(15, 23, 42, 0.1);
        opacity: 0.82;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

/* Móvil: en barra, a la izquierda del menú ☰ */
@media (max-width: 768px) {
    body.icasa-theme-enabled .nav-mobile-end {
        order: 2;
        margin-left: auto;
        align-self: center;
    }

    body.icasa-theme-enabled .icasa-theme-toggle--mobile-nav {
        display: flex;
        position: static;
        flex-shrink: 0;
        width: 2.1rem;
        height: 2.1rem;
        border: 1px solid rgba(15, 23, 42, 0.08);
        background: rgba(255, 255, 255, 0.5);
        color: #0f2d4a;
        box-shadow: none;
        opacity: 0.62;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }

    body.icasa-theme-enabled .nav-mobile-end .nav-toggler-modern {
        margin-left: 0;
    }
}

body.icasa-theme-enabled .icasa-theme-toggle--desktop-fab:hover,
body.icasa-theme-enabled .icasa-theme-toggle--mobile-nav:hover,
.home-theme-toggle:hover {
    opacity: 1;
    border-color: rgba(0, 104, 55, 0.35);
}

body.icasa-theme-enabled .icasa-theme-toggle--desktop-fab:hover {
    box-shadow: 0 4px 14px rgba(0, 104, 55, 0.12);
}

.icasa-theme-toggle:active,
.home-theme-toggle:active {
    transform: scale(0.96);
}

.icasa-theme-toggle--mobile-nav .icasa-theme-toggle__icon {
    font-size: 0.95rem;
}

.icasa-theme-toggle__icon,
.home-theme-toggle__icon {
    font-size: 1.15rem;
    line-height: 1;
    position: absolute;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.icasa-theme-toggle__icon--light,
.home-theme-toggle__icon--light {
    opacity: 0;
    transform: scale(0.6) rotate(-20deg);
}

html[data-theme="dark"] body.icasa-theme-enabled .icasa-theme-toggle--desktop-fab,
html[data-theme="dark"] .home-theme-toggle {
    background: rgba(22, 29, 38, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f5d76e;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .icasa-theme-toggle--desktop-fab:hover,
html[data-theme="dark"] .home-theme-toggle:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] body.icasa-theme-enabled .icasa-theme-toggle--mobile-nav {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.12);
    color: #f5d76e;
    box-shadow: none;
}

html[data-theme="dark"] body.icasa-theme-enabled .icasa-theme-toggle--mobile-nav:hover {
    opacity: 0.92;
    background: rgba(255, 255, 255, 0.16);
}

html[data-theme="dark"] .icasa-theme-toggle__icon--dark,
html[data-theme="dark"] .home-theme-toggle__icon--dark {
    opacity: 0;
    transform: scale(0.6) rotate(20deg);
}

html[data-theme="dark"] .icasa-theme-toggle__icon--light,
html[data-theme="dark"] .home-theme-toggle__icon--light {
    opacity: 1;
    transform: scale(1) rotate(0);
}

html:not([data-theme="dark"]) .icasa-theme-toggle__icon--dark,
html:not([data-theme="dark"]) .home-theme-toggle__icon--dark {
    opacity: 1;
    transform: scale(1) rotate(0);
}

@media (prefers-reduced-motion: reduce) {
    .icasa-theme-toggle,
    .home-theme-toggle,
    .icasa-theme-toggle__icon,
    .home-theme-toggle__icon {
        transition: none;
    }
}
