/* Combined fix for input area and mic button in iOS Safari */

/* Input area container */
.input-area { 
    padding: 12px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    align-items: flex-end; /* Align items at the bottom */
}

/* Message input container */
.message-input-container {
    position: relative;
    flex: 1;
    display: flex;
    min-width: 0; /* Prevent flex item from overflowing */
    width: 100%;
}

/* Text input styling */
#message { 
    width: 100%;
    padding: 12px 40px 12px 12px; /* Right padding for mic button */
    border: 1px solid #ddd;
    border-radius: 20px;
    min-height: 50px;
    resize: none;
    box-sizing: border-box;
    font-size: 16px;
    margin: 0; /* Reset margin */
    flex: 1;
}

/* Send button styling */
button { 
    padding: 12px 16px; 
    background-color: #5c4ee5; 
    color: white; 
    border: none; 
    border-radius: 20px;
    cursor: pointer;
    height: auto;
    align-self: center;
    font-size: 15px;
    font-weight: bold;
    min-width: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* Prevent button from shrinking */
    margin: 0; /* Reset margin */
}

/* Mic button positioning */
.mic-button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: none;
    border: none;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    outline: none;
    color: #666;
    transition: color 0.2s ease;
}

/* Make sure the icon displays properly */
.mic-button i,
.mic-button .material-icons {
    font-size: 24px;
    display: block;
    line-height: 1;
}

/* Recording state indicator */
.mic-button.recording {
    color: #ff4444;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Recording status display */
#recording-status {
    position: absolute;
    bottom: -25px;
    left: 0;
    width: 100%;
    text-align: center;
    color: #ff4444;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 0;
    display: none;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 3;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Better flex layout for iOS */
    .input-area {
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-box-align: flex-end;
        -webkit-align-items: flex-end;
        align-items: flex-end;
        -webkit-box-pack: justify;
        -webkit-justify-content: space-between;
        justify-content: space-between;
    }
    
    .message-input-container {
        -webkit-flex: 1;
        flex: 1;
        position: relative;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
    }
    
    #message {
        -webkit-flex: 1;
        flex: 1;
        width: 100% !important;
        margin: 0 !important;
        -webkit-appearance: none; /* Remove iOS styling */
        appearance: none;
    }
    
    /* Mic button iOS specific styling */
    .mic-button {
        position: absolute !important;
        right: 12px !important;
        top: 50% !important;
        -webkit-transform: translateY(-50%) !important;
        transform: translateY(-50%) !important;
        padding: 0 !important;
        height: 30px !important;
        width: 30px !important;
        display: -webkit-box !important;
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-box-align: center !important;
        -webkit-align-items: center !important;
        align-items: center !important;
        -webkit-box-pack: center !important;
        -webkit-justify-content: center !important;
        justify-content: center !important;
        pointer-events: auto !important;
        z-index: 5 !important;
    }
    
    /* Fix icon display in Safari */
    .mic-button i,
    .mic-button .material-icons {
        font-size: 24px !important;
        display: block !important;
        width: auto !important;
        height: auto !important;
        line-height: 1 !important;
        color: #666 !important;
    }
    
    /* Ensure send button doesn't shrink */
    button {
        -webkit-flex-shrink: 0;
        flex-shrink: 0;
        margin-left: 10px !important;
    }
}

/* iPhone X/modern iPhones compatibility */
@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3),
       only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2),
       only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3),
       only screen and (device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3),
       only screen and (device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) {
    .input-area {
        padding-bottom: 25px; /* Extra padding for iPhone X+ bottom area */
    }
}

/* Fix for Safari on iPad */
@media (min-width: 768px) {
    @supports (-webkit-touch-callout: none) {
        .mic-button {
            right: 15px !important;
        }
        
        .input-area {
            padding-bottom: 12px;
        }
    }
}