/* Chat Toggle Button */
.chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(37, 211, 102, 0.4);
    background: linear-gradient(135deg, #128c7e 0%, #25d366 100%);
}

/* Chat Widget */
#chatSupport {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 480px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(37, 211, 102, 0.1);
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.2);
}

.chat-header h5 {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
    font-family: 'Segoe UI', sans-serif;
}

.chat-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 18px;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

/* Messages Container - Facebook Messenger Style */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: linear-gradient(to bottom, #f0f2f5 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    height: calc(100% - 200px);
    max-height: calc(100% - 200px);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(37, 211, 102, 0.05);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #128c7e 0%, #25d366 100%);
}

/* Message Styles - Messenger Style */
.chat-message {
    display: flex;
    margin-bottom: 4px;
    animation: messageSlide 0.3s ease-out;
    align-items: flex-end;
}

.chat-message.customer {
    justify-content: flex-end;
}

.chat-message.staff,
.chat-message.ai {
    justify-content: flex-start;
}

.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 20px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
    font-family: 'Segoe UI', sans-serif;
}

/* Customer messages - Green gradient like WhatsApp */
.customer .message-content {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.2);
}

/* AI/Staff messages - Light green gradient */
.staff .message-content,
.ai .message-content {
    background: linear-gradient(135deg, #f0f9f0 0%, #e8f5e8 100%);
    color: #2d5016;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(37, 211, 102, 0.1);
}

.message-content p {
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* AI Icon Styling */

.ai .ai-icon {
    color: #25d366;
    font-size: 20px;
    margin-top: 2px;
    flex-shrink: 0;
    width: 32px; /* Make icon bigger */
    height: 32px; /* Make icon bigger */
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white;
    border-radius: 50%;
    font-size: 16px; /* Adjust icon font size */
    margin-right: 8px; /* Add padding */
}

.ai .ai-icon i {
    color: white; /* Ensure icon color is white */
}

/* Message Time */
.message-time {
    font-size: 11px;
    opacity: 0.6;
    display: block;
    margin-top: 4px;
    font-family: 'Segoe UI', sans-serif;
}

.customer .message-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.8);
}

/* Chat Input - Fixed at bottom */
.chat-input {
    position: relative;
    background: #ffffff;
    padding: 16px;
    border-top: 1px solid rgba(37, 211, 102, 0.1);
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    min-height: 76px;
    height: 76px;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid rgba(37, 211, 102, 0.2);
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    font-family: 'Segoe UI', sans-serif;
    transition: all 0.3s ease;
    background: #f8f9fa;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    overflow-y: auto;
}

.chat-input input:focus {
    border-color: #25d366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
    background: #ffffff;
}

.chat-input input::placeholder {
    color: #8e8e93;
}

.chat-input button {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.chat-input button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
    background: linear-gradient(135deg, #128c7e 0%, #25d366 100%);
}

.chat-input button:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f0f9f0 0%, #e8f5e8 100%);
    border-radius: 20px;
    border-bottom-left-radius: 6px;
    max-width: 75%;
    margin-bottom: 8px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #25d366;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    #chatSupport {
        width: calc(100vw - 40px); /* Add more space around */
        height: calc(100dvh - 240px); /* Much more space for input visibility */
        bottom: 160px; /* Position much higher above chat button */
        right: 20px;
        left: 20px;
        border-radius: 16px; /* Keep rounded corners like desktop */
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15); /* Keep desktop shadow */
        border: 1px solid rgba(37, 211, 102, 0.1); /* Keep desktop border */
    }
    
    .chat-toggle-btn {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 22px;
        z-index: 999; /* Ensure it's below the chat widget when open */
    }
    
    .message-content {
        max-width: 85%;
        font-size: 14px;
    }
    
    .chat-input {
        padding: 12px;
        flex-shrink: 0; /* Prevent input from shrinking */
    }
    
    .chat-input input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    #chatSupport {
        width: calc(100vw - 20px); /* Small margins like desktop */
        height: calc(100dvh - 200px); /* Much more space above chat button */
        bottom: 160px; /* Position much higher above chat button */
        right: 10px;
        left: 10px;
        border-radius: 16px; /* Rounded corners like desktop */
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15); /* Desktop shadow */
        border: 1px solid rgba(37, 211, 102, 0.1); /* Desktop border */
        z-index: 1003; /* Ensure it's above the chat bubble */
    }
    
    .chat-messages {
        height: calc(100% - 120px); /* Adjust for header and input */
        padding-bottom: 20px;
        flex: 1; /* Allow messages to take available space */
        overflow-y: auto;
    }
    
    .chat-input {
        padding: 12px;
        padding-bottom: 16px; /* Standard padding */
        min-height: 76px;
        height: 76px;
        background: #ffffff;
        border-top: 1px solid rgba(37, 211, 102, 0.1);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
        flex-shrink: 0; /* Prevent input from shrinking */
        position: relative; /* Ensure proper positioning */
    }
    
    /* For very tall screens like ZFold5 unfolded */
    @media (min-height: 800px) {
        #chatSupport {
            height: calc(100dvh - 220px); /* Even more space for tall screens */
            bottom: 180px; /* Much higher position for tall screens */
        }
    }
    
    @media (max-height: 700px) {
        #chatSupport {
            height: calc(100dvh - 180px); /* More space for shorter screens */
            bottom: 140px; /* Higher position for shorter screens */
        }
        
        .chat-messages {
            height: calc(100% - 110px); /* Reduce space for smaller screens */
            max-height: calc(100% - 110px);
        }
    }
    
    .chat-header {
        padding: 16px; /* Standard padding */
        flex-shrink: 0; /* Prevent header from shrinking */
    }
    
    .message-content {
        max-width: 90%;
    }
}

/* Font improvements */
#chatSupport, 
.chat-messages, 
.chat-message, 
.chat-input input, 
.chat-header, 
.chat-input button {
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
}

/* Ensure input stays visible */
.chat-input input {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

/* Quick actions removed as per original file */
.chat-quick-actions {
    display: none;
}