/* =========================================
   Check-Bas AI Chat Widget
   ========================================= */

.chat-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gradient-primary);
    border: none;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(0,212,170,0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(0,212,170,0.5);
}

.chat-widget-btn .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.chat-widget-btn.active .btn-icon {
    transform: rotate(180deg);
}

.chat-widget-btn .notification-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid var(--bg-dark);
    animation: pulse 2s infinite;
}

/* Chat Container */
.chat-widget-container {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 360px;
    height: 520px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 16px 64px rgba(0,0,0,0.5);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Chat Header */
.chat-header {
    padding: 18px 20px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-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-info {
    flex: 1;
}

.chat-header-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.chat-header-info p {
    font-size: 11px;
    font-weight: 400;
    color: rgba(255,255,255,0.7);
    margin: 2px 0 0;
}

.chat-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    transition: color 0.2s;
}

.chat-close-btn:hover {
    color: #fff;
}

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

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

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

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

/* Message Bubbles */
.chat-msg {
    max-width: 90%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msgIn 0.3s ease-out;
}

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

.chat-msg.bot {
    align-self: flex-start;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg-time {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.chat-msg.user .chat-msg-time {
    color: rgba(255,255,255,0.5);
}

/* Typing Indicator */
.chat-typing {
    align-self: flex-start;
    padding: 12px 18px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    display: none;
    gap: 4px;
}

.chat-typing.active {
    display: flex;
}

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

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

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

/* Chat Input */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    background: var(--bg-card);
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 24px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s;
}

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

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

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

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

/* Quick Reply Buttons */
.chat-quick-replies {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0 16px 12px;
    flex-shrink: 0;
}

.quick-reply-btn {
    padding: 8px 14px;
    border-radius: 18px;
    background: rgba(0,212,170,0.08);
    border: 1px solid rgba(0,212,170,0.15);
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.quick-reply-btn:hover {
    background: rgba(0,212,170,0.15);
    border-color: var(--primary);
}

/* WhatsApp Button in Chat */
.whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 50px;
    background: #25d366;
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    margin-top: 10px;
    transition: all 0.2s;
}

.whatsapp-btn:hover {
    background: #1da851;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(37,211,102,0.3);
}

.whatsapp-btn i {
    font-size: 18px;
}

/* =========================================
   Chat Notification Bubble
   ========================================= */

.chat-notification {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 320px;
    z-index: 9998;
    display: none;
    animation: notifSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom right;
}

.chat-notification.show {
    display: block;
}

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

.chat-notif-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    position: relative;
}

/* Arrow pointing down to chat button */
.chat-notif-content::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 30px;
    width: 16px;
    height: 16px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transform: rotate(45deg);
    border-radius: 0 0 3px 0;
}

.chat-notif-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-notif-text {
    flex: 1;
    min-width: 0;
}

.chat-notif-text strong {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.chat-notif-text p {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.chat-notif-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    flex-shrink: 0;
    transition: color 0.2s;
    line-height: 1;
}

.chat-notif-close:hover {
    color: var(--text-primary);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-widget-container {
        right: 12px;
        left: 12px;
        bottom: 80px;
        width: auto;
        height: 70vh;
    }

    .chat-widget-btn {
        bottom: 16px;
        right: 16px;
    }
}