/* Mobile responsive styles for IGCS AI Chatbot */

/* Base mobile adjustments */
@media screen and (max-width: 768px) {    
    .igcs-chatbot-container {
        width: 94vw !important; /* Slightly reduced from 95vw to provide small margins */
        max-width: none !important;
        height: 85vh !important; /* Increased height for better visibility */
        max-height: 85vh !important; /* Match height */
        margin: 0 3vw !important; /* Add horizontal margins */
        border-radius: 12px !important; /* Slightly reduced radius */
        box-sizing: border-box !important;
        position: fixed !important;
        left: 0 !important; /* Reset left position */
        right: 0 !important; /* Reset right position */
        transform: none !important; /* Reset transform */
        display: flex !important;
        flex-direction: column !important;
        z-index: 999999; /* Match wrapper z-index */
        overflow: hidden !important;
        padding: 0 !important; /* Reset padding */
        bottom: 0 !important; /* Default position at bottom */
    }

    /* Active state positioning */
    .igcs-chatbot-container.active {
        bottom: 20px !important; /* Set bottom margin when active */
    }

    .igcs-chatbot-header {
        position: relative !important;
        flex-shrink: 0 !important;
        z-index: 999999; /* Match wrapper z-index */
        height: 60px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        background-color: var(--igcs-primary-color, #007bff) !important;
        border-top-left-radius: 12px !important;
        border-top-right-radius: 12px !important;
        padding: 12px 16px !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    }

    .igcs-chatbot-body {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        height: calc(100% - 120px) !important; /* Account for header and footer */
        min-height: 0 !important;
        padding: 15px !important; /* Add padding for content */
    }

    /* Improved touch targets */
    .igcs-chatbot-close,
    .igcs-chatbot-links a,
    .igcs-chatbot-toggle {
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Input area optimizations */
    .igcs-chatbot-input {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        padding: 12px !important;
        margin-right: 8px !important;
    }

    .igcs-chatbot-send {
        padding: 12px 20px !important;
        font-size: 16px !important;
    }

    /* Reset position adjustments for mobile to use our new full-width approach */
    .igcs-position-bottom-right .igcs-chatbot-container,
    .igcs-position-bottom-left .igcs-chatbot-container,
    .igcs-position-bottom-middle .igcs-chatbot-container,
    .igcs-position-top-right .igcs-chatbot-container,
    .igcs-position-top-left .igcs-chatbot-container,
    .igcs-position-top-middle .igcs-chatbot-container,
    .igcs-position-middle-left .igcs-chatbot-container,
    .igcs-position-middle-right .igcs-chatbot-container {
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 3vw !important;
        width: 94vw !important;
        transform: none !important;
    }

    /* Override active state for all positions */
    .igcs-position-bottom-right .igcs-chatbot-container.active,
    .igcs-position-bottom-left .igcs-chatbot-container.active,
    .igcs-position-bottom-middle .igcs-chatbot-container.active,
    .igcs-position-top-right .igcs-chatbot-container.active,
    .igcs-position-top-left .igcs-chatbot-container.active,
    .igcs-position-top-middle .igcs-chatbot-container.active,
    .igcs-position-middle-left .igcs-chatbot-container.active,
    .igcs-position-middle-right .igcs-chatbot-container.active {
        bottom: 20px !important;
    }

    /* Message bubbles optimization */
    .igcs-message {
        max-width: 85% !important;
        padding: 12px 16px !important;
        box-sizing: border-box !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Improved scrolling */
    .igcs-chatbot-messages {
        -webkit-overflow-scrolling: touch !important;
        padding: 12px !important;
    }

    /* Improved footer positioning */
    .igcs-chatbot-footer {
        padding: 12px !important;
        min-height: 60px !important;
        border-bottom-left-radius: 12px !important;
        border-bottom-right-radius: 12px !important;
    }
}

/* Small mobile devices */
@media screen and (max-width: 480px) {
    .igcs-chatbot-container {
        width: 96vw !important; /* Even more width on very small screens */
        height: 85vh !important;
        margin: 0 2vw !important; /* Smaller margins */
    }

    .igcs-chatbot-header {
        padding: 12px !important;
    }

    .igcs-chatbot-title {
        font-size: 15px !important;
    }

    .igcs-message {
        max-width: 90% !important;
    }
}

/* Landscape orientation */
@media screen and (max-height: 480px) and (orientation: landscape) {
    .igcs-chatbot-container {
        height: 90vh !important;
    }

    .igcs-chatbot-body {
        height: calc(100% - 100px) !important;
    }

    .igcs-chatbot-header {
        padding: 8px 12px !important;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .igcs-chatbot-input,
    .igcs-chatbot-send,
    .igcs-message {
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }
}
