/* ==========================================================================
   ESTILOS DE INTERNACIONALIZACIÓN (i18n) & ADAPTACIÓN MOBILE-FRIENDLY
   ========================================================================== */

/* 1. SELECTOR DE IDIOMA ULTRA-DISCRETO ESTILO ETSY */
.lang-selector-etsy {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.85);
    padding: 3px 8px;
    border-radius: 14px;
    border: 1.5px solid var(--pastel-pink-border, #ffb7b2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.lang-btn {
    background: transparent;
    border: none;
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.8rem;
    font-weight: 800;
    color: #718096;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 24px;
    min-width: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lang-btn:hover {
    color: #2d3748;
}

.lang-btn.active {
    background: var(--pastel-pink-border, #ffb7b2);
    color: #2d3748;
}

.lang-divider {
    font-size: 0.75rem;
    color: #cbd5e0;
    font-weight: 600;
    user-select: none;
}

/* Ocultar barra inferior en pantallas grandes */
.mobile-bottom-nav {
    display: none;
}

@media screen and (max-width: 768px) {
    .app-header {
        padding: 8px 12px;
        gap: 6px;
    }

    .header-top-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .logo-area {
        padding-right: 0;
        gap: 0.4rem;
    }

    .logo-icon {
        font-size: 1.3rem;
    }

    .title-sub h1 {
        font-size: 1.05rem;
        line-height: 1.15;
    }

    /* Ocultar subtítulo secundario en celular para máxima economía de espacio */
    .title-sub span {
        display: none !important;
    }

    .lang-selector-etsy {
        position: static;
        scale: 0.9;
        margin-left: 4px;
        flex-shrink: 0;
    }

    /* Ocultar navegación superior en celular (Usamos la barra inferior thumb-zone) */
    .app-header .app-nav {
        display: none !important;
    }

    /* BARRA INFERIOR FIJA ESTÁNDAR MÓVIL (THUMB-ZONE NAVIGATION) */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 58px !important;
        background: rgba(255, 255, 255, 0.96) !important;
        backdrop-filter: blur(10px) !important;
        border-top: 2px solid var(--text-dark, #2d3748) !important;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08) !important;
        justify-content: space-around !important;
        align-items: center !important;
        z-index: 9999 !important;
        padding: 0 4px !important;
    }

    .mobile-nav-btn {
        background: transparent;
        border: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: #718096;
        font-family: 'Nunito', sans-serif;
        font-size: 0.72rem;
        font-weight: 700;
        cursor: pointer;
        padding: 4px 2px;
        border-radius: 10px;
        transition: all 0.2s ease;
        flex: 1;
    }

    .mobile-nav-btn i {
        font-size: 1.15rem;
    }

    .mobile-nav-btn.active {
        color: var(--pastel-pink-text, #d85d75);
        font-weight: 900;
        background: var(--pastel-pink-bg, #fff0f3);
    }

    /* Dejar margen inferior en el contenedor principal para que la barra no tape el contenido */
    .app-main {
        padding-bottom: 75px !important;
    }

    .app-footer-etsy {
        display: none !important;
    }
}

/* Footer Toggle Styles */
.footer-disclaimer-toggle {
    background: transparent;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    margin-top: 0.4rem;
    transition: all 0.2s ease;
}

.footer-disclaimer-toggle:hover {
    background: #f8fafc;
    color: #334155;
}

.footer-disclaimer-box {
    margin-top: 0.5rem;
}

.footer-disclaimer-box.hidden {
    display: none;
}

    /* Layout explorador en móvil: Ocultar tarjetas de referencia para maximizar el algoritmo */
    #tab-explore .reference-sidebar {
        display: none !important;
    }

    .explore-layout {
        display: block;
        width: 100%;
    }

    /* Layout simulador apilado */
    .simulate-layout {
        flex-direction: column;
    }

    .sim-sidebar {
        width: 100%;
    }

    /* Monitor clínico adaptativo */
    .monitor-row-etsy {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    /* Subpestañas táctiles con scroll horizontal suave para calculadoras */
    .calc-tabs-etsy {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none; /* Firefox */
    }
    
    .calc-tabs-etsy::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .calc-tab-btn {
        flex-shrink: 0;
        white-space: nowrap;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

}

/* Bottom Sheet de estudio exclusivo para smartphones y dispositivos móviles (< 768px) */
@media screen and (max-width: 768px) {
    .floating-tooltip-etsy {
        position: fixed !important;
        bottom: 0 !important;               /* Pegado 100% al borde inferior en móvil */
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        max-height: 80vh !important;         /* Ocupa hasta el 80% vertical de la pantalla */
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.3) !important;
        border: 2.5px solid #eadead !important;
        border-bottom: none !important;
        padding: 0.9rem 1.2rem 1.4rem 1.2rem !important;
        transform: translateY(100%) !important; /* Oculto fuera de pantalla por defecto */
        transition: transform 0.3s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.25s ease !important;
        z-index: 10000 !important;
    }

    /* Mostrar el Bottom Sheet deslizándose desde abajo al activarse */
    .floating-tooltip-etsy.show {
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Hacer visible la barra de agarre táctil superior en móvil */
    .bottom-sheet-handle {
        display: block !important;
    }

    /* Ocultar la cinta washi tape en modo Bottom Sheet para evitar distorsión visual */
    .tooltip-washi-tape {
        display: none !important;
    }

    /* Ocultar en móvil el encabezado interno del mapa ("Mi Esquema del Algoritmo") y la grapita para maximizar la visión del SVG */
    .flowchart-header-etsy,
    .paper-clip-doodle {
        display: none !important;
    }

    /* Reducir el padding interno del marco del diagrama en móvil para ganar máxima superficie de visualización */
    .flowchart-container-etsy {
        padding: 0.6rem 0.4rem !important;
        border-radius: 16px !important;
    }

    /* Ocultar el footer general en móvil para dejar superficie limpia y liberar espacio para anuncios de Google AdSense */
    .app-footer-etsy {
        display: none !important;
    }
}

/* 3. ADAPTACIÓN PARA SMARTPHONES ANGOSTOS (< 580px) */
@media screen and (max-width: 580px) {
    .score-btn-group {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .score-select-btn {
        min-height: 44px;
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .calculator-centered-layout-suite {
        padding: 0.2rem;
    }

    .study-card {
        padding: 1.1rem;
    }

    .floating-tooltip-etsy {
        padding: 1rem;
    }
}
