/* Chat Widget Styles */

:root {
    --chat-width: 450px;
    --chat-height: 550px;
    --chat-bg: rgba(23, 5, 55, 0.95);
    /* Deep dark matching footer/header */
    --chat-header-bg: linear-gradient(135deg, var(--color-accent) 0%, #0288c0 100%);
    --chat-user-msg-bg: var(--color-accent);
    --chat-bot-msg-bg: rgba(255, 255, 255, 0.1);
    --chat-border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Floating Toggle Button */
.chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--chat-header-bg);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 20px rgba(3, 160, 225, 0.4);
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
}

.chat-toggle-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
}

.chat-toggle-btn:hover {
    transform: scale(1.1) rotate(-5deg);
}

.chat-toggle-icon {
    font-size: 1.8rem;
    color: white;
    transition: opacity 0.3s ease;
}

/* Chat Window Container */
.chat-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: var(--chat-width);
    height: var(--chat-height);
    background: var(--chat-bg);
    backdrop-filter: blur(15px);
    border: var(--chat-border);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
}

.chat-widget.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.chat-header {
    background: var(--chat-header-bg);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    border-bottom: var(--chat-border);
}

.chat-title {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.chat-close:hover {
    color: white;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: popIn 0.3s ease-out forwards;
}

.message.bot {
    align-self: flex-start;
    background: var(--chat-bot-msg-bg);
    color: var(--color-text-light);
    border-bottom-left-radius: 2px;
}

.message.user {
    align-self: flex-end;
    background: var(--chat-user-msg-bg);
    color: white;
    border-bottom-right-radius: 2px;
}

/* Input Area */
.chat-input-area {
    padding: 8px;
    border-top: var(--chat-border);
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    align-items: center;
}

.chat-input {
    flex: 1;
    width: 100%;
    /* Force expansion */
    min-width: 0;
    /* Prevent flex overflow issues */
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0 20px;
    height: 60px;
    color: white;
    font-family: inherit;
    font-size: 1.15rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--color-accent);
}

.chat-send-btn {
    background: var(--color-accent);
    border: none;
    border-radius: 12px;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

.chat-send-btn:disabled {
    background: gray;
    cursor: not-allowed;
    transform: none;
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chat-bot-msg-bg);
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    align-self: flex-start;
    width: fit-content;
}

.typing span {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chat-widget {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .chat-toggle-btn {
        bottom: max(20px, env(safe-area-inset-bottom, 20px));
        right: max(20px, env(safe-area-inset-right, 20px));
    }
}