/* ==========================================
   MOBILE RESPONSIVENESS & PWA ADAPTATIONS
   ========================================== */

/* TABLET & MOBILE (max-width: 768px) */
@media (max-width: 768px) {
    .nexus-container {
        padding: 10px;
        /* Ajuste para barra de navegación móvil */
        min-height: calc(100vh - 70px);
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Header más compacto */
    .nexus-header {
        margin-bottom: 10px;
        padding: 4px;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .nexus-status-bar {
        width: 100%;
        justify-content: space-between;
        margin-bottom: 10px;
        padding: 4px;
    }

    /* Área de chat - Espacio para input fijo */
    .nexus-chat-area {
        padding-bottom: 180px;
        /* Mucho espacio para el input fijo */
        padding-right: 0;
    }

    /* Input Area - Flotante estilo App */
    .nexus-input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        background: rgba(21, 21, 32, 0.95);
        /* var(--bg-secondary) semi-transparente */
        backdrop-filter: blur(10px);
        padding: 12px;
        border-top: 1px solid var(--border-color);
        z-index: 900;
        /* Debajo del sidebar (1000) pero encima del contenido */
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    /* Controles de modo desplazables horizontalmente */
    .nexus-mode-controls {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 8px;
        margin-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* Firefox */
    }

    .nexus-mode-controls::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari */
    }

    .nexus-mode-chip {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* Ajustes del input */
    .nexus-input-container {
        border-radius: 20px;
    }

    .nexus-input {
        font-size: 16px;
        /* Evita zoom automático en iOS */
        min-height: 50px;
    }

    /* Botones más grandes para tocar */
    .nexus-icon-btn,
    .nexus-send-btn,
    .nexus-attach-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Sugerencias en columna o grid de 1 */
    .nexus-suggestions {
        grid-template-columns: 1fr;
        padding-bottom: 100px;
        /* Evitar que queden tapadas */
    }

    /* Hero ajustado */
    .nexus-hero {
        margin-top: 20px;
        margin-bottom: 30px;
    }

    .nexus-hero h1 {
        font-size: 2rem;
    }
}

/* SMALL MOBILE (max-width: 480px) */
@media (max-width: 480px) {
    .nexus-message {
        max-width: 95%;
        padding: 12px 14px;
        font-size: 0.9rem;
    }

    .nexus-status-text {
        display: none;
        /* Ahorrar espacio */
    }

    .nexus-actions {
        gap: 4px;
    }

    .nexus-icon-btn {
        width: 38px;
        height: 38px;
    }

    /* Modal settings full screen */
    .nexus-modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* PWA UTILITIES */
@media all and (display-mode: standalone) {

    /* Ajustes específicos cuando se abre como App instalada */
    .nexus-container {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .nexus-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}