.chat-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37,99,235,0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s;
}
.chat-widget-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(37,99,235,0.55);
}
.chat-widget-btn .chat-icon-close { display: none; }
.chat-widget-btn.active .chat-icon-open { display: none; }
.chat-widget-btn.active .chat-icon-close { display: inline; }

.chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}
.chat-panel.open { display: flex; }

.chat-header {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.chat-header-text h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}
.chat-header-text span {
    font-size: 11px;
    opacity: 0.85;
}
.chat-header-actions {
    display: flex;
    gap: 6px;
}
.chat-header-actions button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}
.chat-header-actions button:hover { background: rgba(255,255,255,0.3); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: chatFadeIn 0.25s ease;
}
@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-msg.user {
    align-self: flex-end;
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.chat-msg.assistant a { color: #2563eb; }
.chat-msg-time {
    font-size: 10px;
    opacity: 0.55;
    margin-top: 4px;
    text-align: right;
}

.chat-quick-replies {
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #fff;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}
.chat-quick-replies button {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.chat-quick-replies button:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.chat-input-area {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.chat-input-area input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input-area input:focus { border-color: #2563eb; }
.chat-input-area button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: background 0.2s;
}
.chat-input-area button:hover { background: #1d4ed8; }
.chat-input-area button:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

.chat-typing {
    display: none;
    align-self: flex-start;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    font-size: 13px;
    color: #6b7280;
}
.chat-typing.show { display: flex; align-items: center; gap: 6px; }
.chat-typing-dots {
    display: flex;
    gap: 3px;
}
.chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-4px); }
}

.chat-welcome {
    text-align: center;
    padding: 24px 16px 8px;
}
.chat-welcome-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 10px;
}
.chat-welcome h6 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #111827;
}
.chat-welcome p {
    font-size: 12.5px;
    color: #6b7280;
    margin: 0;
}

@media (max-width: 480px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .chat-widget-btn { bottom: 16px; right: 16px; }
}
