/* ===== Chat Widget Container ===== */
.chat-widget {
    position: fixed;
    bottom: 90px;
    right: 25px;
    width: 380px;
    max-width: calc(100vw - 40px);
    max-height: 600px;
    height: 550px;
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    border: 1px solid rgba(10, 37, 64, 0.08);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    visibility: hidden;
    opacity: 0;
    transform: scale(0.95) translateY(10px);
}

.chat-widget.active {
    visibility: visible;
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* ===== Chat Header ===== */
.chat-header {
    background: var(--primary-blue);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 3px solid var(--gold);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    background: var(--gold);
    color: var(--primary-blue);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.chat-agent-name {
    font-weight: 700;
    color: var(--white);
    font-size: 0.95rem;
    display: block;
}

.chat-status {
    font-size: 0.7rem;
    color: #A0C4FF;
    display: block;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-close-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--white);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* ===== Chat Body (Messages) ===== */
.chat-body {
    flex: 1;
    padding: 20px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #F7F9FC;
}

.chat-body::-webkit-scrollbar {
    width: 4px;
}

.chat-body::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 10px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

.chat-message.user-message {
    align-self: flex-end;
}

.chat-message.bot-message {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-break: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.user-message .message-bubble {
    background: var(--gold);
    color: var(--primary-blue);
    border-bottom-right-radius: 4px;
}

.bot-message .message-bubble {
    background: var(--white);
    color: var(--primary-blue);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 1px solid #eee;
}

.message-time {
    font-size: 0.65rem;
    color: #999;
    margin-top: 4px;
    padding: 0 6px;
}

.user-message .message-time {
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--gold);
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Chat Footer ===== */
.chat-footer {
    border-top: 1px solid #EDF2F7;
    background: var(--white);
    padding: 10px 12px;
    flex-shrink: 0;
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-attach-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--dark-gray);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    background: #EDF2F7;
}

.chat-input {
    flex: 1;
    border: 1px solid #E2E8F0;
    border-radius: 50px;
    padding: 10px 16px;
    font-size: 0.95rem;
    outline: none;
    transition: border 0.2s;
    font-family: var(--font-family);
    min-width: 0;
}

.chat-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.chat-send-btn {
    background: var(--gold);
    border: none;
    color: var(--primary-blue);
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: #C5A030;
    transform: scale(0.97);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== File Preview Area ===== */
.chat-file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding: 4px 0;
}

.file-preview-item {
    background: #EDF2F7;
    padding: 4px 12px 4px 16px;
    border-radius: 50px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-blue);
    font-weight: 500;
}

.file-preview-item .remove-file {
    background: transparent;
    border: none;
    color: #e53e3e;
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
}

/* ===== Toggle Chat Button (Open) ===== */
.chat-toggle-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: var(--gold);
    border: none;
    color: var(--primary-blue);
    padding: 16px 28px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 8px 30px rgba(212, 175, 55, 0.4);
    cursor: pointer;
    z-index: 999;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px solid var(--gold);
}

.chat-toggle-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(212, 175, 55, 0.5);
}

.chat-toggle-btn.hidden {
    display: none;
}

/* ===== Responsive Chat ===== */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        border: none;
    }
    
    .chat-header {
        border-radius: 0;
        padding: 14px 16px;
    }
    
    .chat-body {
        padding: 16px 12px;
    }
    
    .chat-toggle-btn {
        bottom: 15px;
        right: 15px;
        padding: 14px 20px;
        font-size: 0.9rem;
    }
    
    .chat-send-btn {
        padding: 10px 16px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .chat-widget {
        height: 100vh;
        max-height: 100vh;
    }
    
    .chat-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.7rem;
    }
    
    .chat-agent-name {
        font-size: 0.85rem;
    }
    
    .message-bubble {
        font-size: 0.9rem;
        padding: 10px 14px;
    }
}