/* Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.chat-widget.minimized {
    width: 60px;
    height: 60px;
}

.chat-widget.expanded {
    width: 420px;
    height: min(600px, calc(100vh - 100px));
    max-height: calc(100vh - 100px);
}

.chat-toggle {
    font-size: xx-large;
    width: 60px;
    height: 60px;
    background: #00aeef;
    border-radius: 0;
    border: 0px solid #182333;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(42, 198, 217, 0.3);
    transition: all 0.3s ease;
}

.chat-toggle:hover {
    background: #0088cc;
    transform: scale(1.1);
}

.chat-widget.minimized .chat-toggle {
    display: flex;
}

.chat-widget.expanded .chat-toggle {
    display: none;
}

.chat-widget .chat-container {
    background: white;
    border-radius: 0px;
    box-shadow: 0 -6px 25px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: none;
    flex-direction: column;
    height: 100%;
}

.chat-widget.expanded .chat-container {
    display: flex;
}

.chat-widget .chat-header {
    background: linear-gradient(135deg, #00aeef, #00aeef);
    color: white;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    margin-bottom: 0;
    padding-bottom: 10px;
    border-bottom: none;
}

.chat-widget .chat-header h6 {
    margin: 0;
    font-weight: 600;
    color: white;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-widget .chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
    max-height: calc(100vh - 200px);
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
}

.chat-widget .message {
    margin-bottom: 15px;
    display: flex;
}

.chat-widget .message.user {
    justify-content: flex-end;
}

.chat-widget .message.bot {
    justify-content: flex-start;
}

.chat-widget .message-content {
    max-width: 97%;
    padding: 10px 15px;
    border-radius: 18px;
    word-wrap: break-word;
}

.chat-widget .message.user .message-content {
    background: #00aeef;
    color: white;
    border-bottom-right-radius: 5px;
}

.chat-widget .message.bot .message-content {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 5px;
}

.chat-widget .chat-input-container {
    padding: 15px 0;
    background: white;
    border-top: 1px solid #e9ecef;
    border-radius: 0;
    box-shadow: none;
}

.chat-input-form {
    display: flex;
    gap: 10px;
    margin: 0 15px;
}

.chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 15px;
    outline: none;
    font-size: 14px;
}

.chat-input:focus {
    border-color: #00aeef;
    box-shadow: 0 0 0 2px rgba(0, 174, 239, 0.1);
}

.chat-send-btn {
    font-size: large;
    min-width: 46px !important;
    max-height: 46px !important;
    background: #00aeef;
    border: none;
    border-radius: 50% !important;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
    flex-grow: 0;
    padding: 0;
    box-sizing: border-box;
}

.chat-send-btn:hover {
    background: #0088cc;
}

.chat-send-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* Loading animation */
.typing-indicator {
    display: none;
    padding: 10px 15px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    margin-bottom: 15px;
    max-width: 80px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .chat-widget.expanded {
        width: calc(100vw - 40px);
        /* Use viewport height with safe margins */
        height: 87vh; /*calc(100dvh - 200px);*/
        bottom: 20px;
        right: 20px;
        left: 20px;
        max-height: 87vh; /*calc(100dvh - 200px);*/
        min-height: 300px;
    }
    
    .chat-widget .message-content {
        max-width: 85%;
    }
    
    /* Fix mobile gap by removing max-height constraint on messages */
    .chat-widget .chat-messages {
        max-height: none;
        flex: 1;
    }
}

/* Mobile keyboard detection using viewport height changes */
@media (max-width: 768px) and (max-height: 600px) {
    /* When viewport height is reduced (keyboard likely visible) */
    .chat-widget.expanded {
        height: calc(100vh - 20px);
        max-height: calc(100vh - 20px);
        bottom: 10px;
        top: 10px;
    }
}

@media (max-width: 768px) and (max-height: 500px) {
    /* When viewport is very short (keyboard definitely visible) */
    .chat-widget.expanded {
        height: calc(100vh - 10px);
        max-height: calc(100vh - 10px);
        bottom: 5px;
        top: 5px;
    }
}

@media (max-width: 768px) and (max-height: 400px) {
    /* When viewport is extremely short (large keyboard) */
    .chat-widget.expanded {
        height: calc(100vh - 5px);
        max-height: calc(100vh - 5px);
        bottom: 2px;
        top: 2px;
    }
}
