/* ===== CHATBOT STYLES ===== */

/* Base font */
.chatbot-btn,
.chatbot-modal,
.chatbot-modal * {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
}

/* Floating Button */
.chatbot-btn {
    position: fixed;
    bottom: 115px;
    right: 45px;
    width: 52px;
    height: 52px;
    background: linear-gradient(145deg, #B01E2C 0%, #901824 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(176, 30, 44, 0.32);
    z-index: 9998;
    transition: all 0.25s ease;
    border: none;
    animation: pulse 3s ease-in-out infinite;
}

.chatbot-btn img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.chatbot-btn i {
    color: #fff;
    font-size: 1.3rem;
}

.chatbot-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(176, 30, 44, 0.45);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(176, 30, 44, 0.32); }
    50%       { box-shadow: 0 4px 22px rgba(176, 30, 44, 0.5); }
}

.chatbot-btn.active {
    background: linear-gradient(145deg, #1a56db 0%, #1447b2 100%);
}

/* Badge notification */
.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53935;
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    border: 2px solid #fff;
}

/* Chat Modal */
.chatbot-modal {
    position: fixed;
    bottom: 185px;
    right: 20px;
    width: 370px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 210px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.13), 0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(8px);
    opacity: 0;
    transition: all 0.28s cubic-bezier(0.34, 1.36, 0.64, 1);
}

.chatbot-modal.active {
    display: flex;
    transform: scale(1) translateY(0);
    opacity: 1;
}

.chatbot-modal.fullscreen {
    width: 90vw;
    height: 90vh;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
}

.chatbot-modal.fullscreen.active {
    transform: translate(-50%, 50%) scale(1);
}

/* Chat Header */
.chatbot-header {
    background: linear-gradient(135deg, #1F2C4E 0%, #16213e 100%);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.chatbot-header::before {
    content: '';
    position: absolute;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(176, 30, 44, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    top: -90px;
    right: -40px;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.chatbot-avatar i {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
}

.chatbot-header-text h6 {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.1px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.chatbot-header-text h6::after {
    content: 'AI';
    background: rgba(74, 222, 128, 0.12);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
    font-size: 0.58rem;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.6px;
}

.chatbot-header-text p {
    margin: 2px 0 0;
    font-size: 0.7rem;
    opacity: 0.6;
    letter-spacing: 0.4px;
}

.chatbot-status {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    margin-right: 4px;
    animation: blink 2.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.chatbot-controls {
    display: flex;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.chatbot-control-btn {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.75);
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.78rem;
}

.chatbot-control-btn i {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Chat Body */
.chatbot-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f5f6f8;
    min-height: 0;
    max-height: 400px;
}

.chatbot-modal.fullscreen .chatbot-body {
    max-height: none;
}

/* Messages */
.chat-message {
    display: flex;
    margin-bottom: 12px;
    animation: fadeInMessage 0.25s ease;
}

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

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

.message-avatar {
    width: 30px;
    height: 30px;
    background: #B01E2C;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 8px;
}

.message-avatar img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.message-avatar i {
    color: #fff;
    font-size: 0.85rem;
}

.chat-message.user .message-avatar {
    background: #1a56db;
    margin-right: 0;
    margin-left: 8px;
    order: 2;
}

.message-content {
    max-width: 76%;
    padding: 10px 14px;
    border-radius: 14px;
    position: relative;
}

.chat-message.bot .message-content {
    background: #fff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, #B01E2C 0%, #941824 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(176, 30, 44, 0.2);
}

.message-text {
    margin: 0;
    font-size: 0.855rem;
    line-height: 1.55;
    font-weight: 400;
}

.message-time {
    font-size: 0.65rem;
    opacity: 0.45;
    margin-top: 4px;
    display: block;
}

.msg-source {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    padding: 2px 6px;
    border-radius: 20px;
    margin-top: 4px;
    opacity: 0.75;
}
.msg-source.ai {
    background: rgba(99, 102, 241, 0.09);
    color: #6366f1;
}
.msg-source.local {
    background: rgba(107, 114, 128, 0.09);
    color: #9ca3af;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    padding: 10px 14px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.typing-indicator.active {
    display: block;
}

.typing-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #c5c8d0;
    border-radius: 50%;
    margin: 0 2px;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-7px); }
}

/* Quick Replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.quick-reply-btn {
    background: transparent;
    border: 1.5px solid rgba(176, 30, 44, 0.5);
    color: #B01E2C;
    padding: 5px 13px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.1px;
}

.quick-reply-btn:hover {
    background: #B01E2C;
    border-color: #B01E2C;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(176, 30, 44, 0.22);
}

/* Chat Footer */
.chatbot-footer {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #eef0f3;
}

.chatbot-input-group {
    display: flex;
    gap: 9px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 9px 14px;
    border: 1.5px solid #e4e7ec;
    border-radius: 22px;
    font-size: 0.855rem;
    outline: none;
    transition: all 0.2s ease;
    background: #fafbfc;
    color: #1a1a2e;
}

.chatbot-input::placeholder {
    color: #adb5bd;
    font-size: 0.83rem;
}

.chatbot-input:focus {
    border-color: rgba(176, 30, 44, 0.5);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(176, 30, 44, 0.07);
}

.chatbot-send-btn {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #B01E2C 0%, #901824 100%);
    border: none;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.chatbot-send-btn i {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 12px rgba(176, 30, 44, 0.35);
}

.chatbot-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* Welcome Screen */
.chatbot-welcome {
    text-align: center;
    padding: 28px 18px;
}

.chatbot-welcome img {
    width: 70px;
    height: 70px;
    margin-bottom: 14px;
    opacity: 0.25;
}

.chatbot-welcome h5 {
    color: #1F2C4E;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.chatbot-welcome p {
    color: #8a90a0;
    font-size: 0.82rem;
    line-height: 1.5;
    margin-bottom: 18px;
}

/* Responsive */
@media (max-width: 768px) {
    .chatbot-modal {
        width: calc(100vw - 40px);
        bottom: 165px;
        right: 20px;
        max-height: calc(100vh - 185px);
    }

    .chatbot-modal.fullscreen {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        transform: none;
    }

    .chatbot-modal.fullscreen.active {
        transform: none;
    }

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

@media (max-width: 480px) {
    .chatbot-btn {
        bottom: 100px;
        right: 45px;
        width: 48px;
        height: 48px;
    }

    .chatbot-btn img {
        width: 26px;
        height: 26px;
    }

    .chatbot-modal {
        right: 10px;
        bottom: 160px;
        width: calc(100vw - 20px);
        max-height: calc(100vh - 180px);
    }

    .chatbot-header {
        padding: 13px 15px;
    }

    .chatbot-body {
        padding: 13px;
        max-height: 350px;
    }
}

/* Scrollbar */
.chatbot-body::-webkit-scrollbar {
    width: 4px;
}

.chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-body::-webkit-scrollbar-thumb {
    background: #dde0e6;
    border-radius: 10px;
}

.chatbot-body::-webkit-scrollbar-thumb:hover {
    background: rgba(176, 30, 44, 0.35);
}
