/* Chat Widget Button */
.chat-widget-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--gradient);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    font-weight: 600;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    border: none;
    font-size: 1rem;
}

.chat-widget-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
}

.chat-widget-icon {
    width: 28px;
    height: 28px;
}

.chat-widget-button.open {
    opacity: 0;
    pointer-events: none;
}

/* Chat Widget Window */
.chat-widget-window {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chat-widget-window.open {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: white;
}

/* Chat Header */
.chat-header {
    background: var(--gradient);
    color: white;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-header-info {
    display: flex;
    align-items: center;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 0.75rem;
    background: white;
    padding: 4px;
}

.chat-header-content h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.chat-status {
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 0.25rem 0 0 0;
}

.chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

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

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-lighter);
}

/* Message Bubbles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.message-content {
    padding: 0.875rem 1.125rem;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.bot .message-content {
    background: white;
    color: var(--text-dark);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.message.user .message-content {
    background: var(--gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.875rem 1.125rem;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: var(--shadow-sm);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-lighter);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Response Buttons */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.response-button {
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.625rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: left;
    white-space: normal;
    word-wrap: break-word;
}

.response-button:hover {
    background: var(--primary-color);
    color: white;
    transform: translateX(4px);
}

/* Chat Input */
.chat-input-container {
    padding: 1.25rem;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
}

#userInput {
    flex: 1;
    padding: 0.875rem 1.125rem;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    font-family: inherit;
    font-size: 0.9375rem;
    outline: none;
    transition: all 0.2s ease;
}

#userInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-send-btn {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-send-btn:active {
    transform: translateY(0);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Connection Status */
.connection-status {
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.875rem;
    background: #fff3cd;
    color: #856404;
    border-bottom: 1px solid #ffeaa7;
}

.connection-status.connected {
    background: #d4edda;
    color: #155724;
    border-bottom-color: #c3e6cb;
}

.connection-status.error {
    background: #f8d7da;
    color: #721c24;
    border-bottom-color: #f5c6cb;
}

/* Error Message */
.error-message {
    padding: 0.875rem 1.125rem;
    background: #f8d7da;
    color: #721c24;
    border-radius: 12px;
    border-left: 4px solid #dc3545;
    font-size: 0.875rem;
    margin: 0.5rem 0;
}

/* Welcome Message Special Styling */
.message.bot.welcome .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 500;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-widget-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .chat-widget-button {
        bottom: 20px;
        right: 20px;
        padding: 0.875rem 1.25rem;
    }

    .chat-widget-button .chat-text {
        display: none;
    }

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

@media (max-width: 480px) {
    .chat-header {
        padding: 1rem;
    }

    .chat-header-content h3 {
        font-size: 1.125rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .message {
        max-width: 90%;
    }

    .message-content {
        padding: 0.75rem 1rem;
        font-size: 0.9375rem;
    }

    .chat-input-container {
        padding: 1rem;
    }

    #userInput {
        font-size: 1rem;
    }

    .chat-send-btn {
        padding: 0.75rem 1.25rem;
    }
}

/* Loading Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Smooth Scrolling */
.chat-messages {
    scroll-behavior: smooth;
}

/* Focus Visible for Accessibility */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
