/* ============================================
   RESPONSIVE STYLES
   ============================================ */
/* Reviewer note: mobile/tablet behavior is isolated here so breakpoint changes
 * can be reviewed independently from base desktop styles.
 */

/* Mobile styles */
@media (max-width: 768px) {
    #winaltchat-root {
        bottom: 20px;
        right: 20px;
        left: auto;
    }

    .ai-window {
        width: calc(100vw - 40px);
        max-width: none;
        height: 70vh;
        max-height: 500px;
        bottom: 88px;
        right: 20px;
        left: 20px;
        margin: 0 auto;
        border-radius: 22px;
    }

    .ai-window.fullscreen {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        margin: 0;
    }

    .ai-messages {
        padding: 15px;
    }

    .ai-message {
        max-width: 85%;
    }

    .ai-input-area {
        padding: 10px;
    }

    /* Mobile header portal — position overridden by chat-layout.css fullscreen rules */
    .ai-header-portal {
        align-items: center;
        justify-content: space-between;
        padding: 0 15px;
    }

    .portal-center {
        flex: 1;
        text-align: center;
        font-weight: 600;
    }

    .portal-btn {
        background: rgba(255,255,255,0.2);
        border: none;
        color: white;
        width: 30px;
        height: 30px;
        border-radius: 50%;
        font-size: 20px;
        line-height: 1;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Tablet styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .ai-window {
        width: 400px;
        height: 500px;
        right: 30px;
        left: auto;
    }

    #winaltchat-root {
        bottom: 30px;
        right: 30px;
    }

    /* Force bubble display on tablets - hide header trigger */
    .ai-chat-trigger-header {
        display: none !important;
    }

    .winaltchat-header-trigger-anchor {
        display: none !important;
    }

    .winaltchat-header-menu-item {
        display: none !important;
    }

    /* Ensure bubble is visible on tablets */
    .ai-window {
        position: fixed !important;
        top: auto !important;
        bottom: 30px !important;
        right: 30px !important;
    }

    .ai-window.header-panel-mode {
        display: none !important;
    }
}

/* Mobile keyboard fixes */
@media (max-width: 768px) {
    /* Fix for iOS Safari 100vh issue */
    @supports (-webkit-touch-callout: none) {
        .ai-window.fullscreen {
            height: -webkit-fill-available;
        }
    }
    
    /* Better input area for mobile */
    .ai-input-area {
        padding-bottom: env(safe-area-inset-bottom, 10px);
    }
    
    /* Ensure messages area scrolls properly */
    .ai-messages {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Prevent zoom on textarea focus in iOS */
    #ai-input {
        font-size: 16px;
        resize: none;
    }
}

/* Final iOS keyboard override lives in the last-loaded stylesheet so it wins */
@media (max-width: 768px) {
    @supports (-webkit-touch-callout: none) {
        .ai-window.fullscreen,
        .ai-window.fullscreen.open {
            transform: none !important;
            height: 100dvh !important;
            min-height: -webkit-fill-available !important;
        }

        .ai-window.fullscreen #ai-header-portal {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
        }

        .ai-window.fullscreen .ai-header {
            display: none !important;
        }

        .ai-window.fullscreen .ai-input-area {
            z-index: 1001 !important;
        }
    }
}