/* ========================================
   CHATBOT WIDGET - FACEBOOK MESSENGER STYLE
   Inline chat widget for all pages
   Version 2.0
   ======================================== */

.chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Floating Button */
.chatbot-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary, #2e7d32), var(--color-secondary, #66bb6a));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    color: white;
    font-size: 26px;
}

.chatbot-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.4);
}

.chatbot-widget-button:active {
    transform: scale(0.95);
}

.chatbot-widget-button.active i {
    transform: rotate(90deg);
}

.chatbot-widget-button i {
    transition: transform 0.3s ease;
}

/* Badge notification */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Chat Window */
.chatbot-widget-window {
    position: absolute;
    bottom: 0;
    right: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--bg-card, #ffffff);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chatbot-widget-window.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

/* Header */
.chatbot-widget-header {
    background: linear-gradient(135deg, var(--color-primary, #2e7d32), var(--color-secondary, #66bb6a));
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chatbot-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Messages Container */
.chatbot-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-secondary, #f5f7fa);
    scroll-behavior: smooth;
}

.chatbot-widget-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-widget-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-widget-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chatbot-widget-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Message Bubbles */
.widget-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
}

.widget-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.bot-message .widget-message-bubble {
    background: var(--bg-card, #ffffff);
    color: var(--text-primary, #1a1f36);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.user-message .widget-message-bubble {
    background: linear-gradient(135deg, var(--color-primary, #2e7d32), var(--color-secondary, #66bb6a));
    color: white;
    border-bottom-right-radius: 4px;
}

.widget-message-time {
    font-size: 11px;
    color: var(--text-muted, #718096);
    margin-top: 4px;
    padding: 0 4px;
}

.user-message .widget-message-time {
    text-align: right;
}

/* Typing Indicator */
.widget-typing-indicator {
    display: flex;
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--bg-card, #ffffff);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary, #2e7d32);
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Quick Questions */
.chatbot-quick-questions {
    padding: 12px 16px;
    background: var(--bg-secondary, #f5f7fa);
    border-top: 1px solid var(--border-color, #e2e8f0);
}

.quick-label {
    font-size: 12px;
    color: var(--text-muted, #718096);
    margin: 0 0 8px 0;
    font-weight: 500;
}

.quick-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.quick-btn {
    padding: 8px 12px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary, #1a1f36);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    text-align: left;
}

.quick-btn:hover {
    background: var(--color-primary, #2e7d32);
    color: white;
    border-color: var(--color-primary, #2e7d32);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.quick-btn i {
    font-size: 14px;
}

/* Input Area */
.chatbot-widget-input {
    padding: 12px 16px;
    background: var(--bg-card, #ffffff);
    border-top: 1px solid var(--border-color, #e2e8f0);
    flex-shrink: 0;
}

.chatbot-widget-input form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chatbot-widget-input textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    background: var(--bg-secondary, #f5f7fa);
    color: var(--text-primary, #1a1f36);
    transition: border-color 0.2s ease;
}

.chatbot-widget-input textarea:focus {
    outline: none;
    border-color: var(--color-primary, #2e7d32);
    background: var(--bg-card, #ffffff);
}

.chatbot-widget-input textarea::placeholder {
    color: var(--text-muted, #718096);
}

.chatbot-widget-input button[type="submit"] {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary, #2e7d32), var(--color-secondary, #66bb6a));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-widget-input button[type="submit"]:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chatbot-widget-input button[type="submit"]:active {
    transform: scale(0.95);
}

.char-counter {
    font-size: 11px;
    color: var(--text-muted, #718096);
    text-align: right;
    margin-top: 4px;
}

/* Dark Mode Support */
body.dark-mode .chatbot-widget-window {
    background: var(--bg-card);
}

body.dark-mode .chatbot-widget-messages {
    background: var(--bg-secondary);
}

body.dark-mode .bot-message .widget-message-bubble {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.dark-mode .chatbot-quick-questions {
    background: var(--bg-secondary);
}

body.dark-mode .quick-btn {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.dark-mode .chatbot-widget-input {
    background: var(--bg-card);
}

body.dark-mode .chatbot-widget-input textarea {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.dark-mode .widget-typing-indicator {
    background: var(--bg-tertiary);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chatbot-widget {
        bottom: 15px;
        right: 15px;
    }

    .chatbot-widget-button {
        width: 55px;
        height: 55px;
        font-size: 24px;
    }

    .chatbot-widget-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        bottom: 75px;
    }

    .chatbot-widget-messages {
        padding: 12px;
    }

    .widget-message {
        max-width: 85%;
    }

    .quick-buttons {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 10px;
        right: 10px;
    }

    .chatbot-widget-button {
        width: 50px;
        height: 50px;
        font-size: 22px;
    }

    .chatbot-widget-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 65px;
    }

    .chatbot-widget-header {
        padding: 12px;
    }

    .chatbot-avatar {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .chatbot-info h4 {
        font-size: 14px;
    }
}

/* Animation for button bounce */
.chatbot-widget-button:not(.active) i {
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-8px);
    }
    60% {
        transform: translateY(-4px);
    }
}

/* Smooth transitions for theme changes */
.chatbot-widget-window,
.chatbot-widget-messages,
.widget-message-bubble,
.quick-btn,
.chatbot-widget-input textarea {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ========================================
   LIVE SUPPORT MODE STYLES
   ======================================== */

/* Subtle "Talk to a real person" link above the textarea */
.live-support-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 2px;
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
}

.live-support-link i {
    font-size: 11px;
    color: var(--primary-color, #1a6b3c);
    opacity: 0.7;
}

.live-support-link a {
    color: var(--primary-color, #1a6b3c);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

.live-support-link a:hover {
    text-decoration: underline;
    color: var(--primary-dark, #145530);
}

/* Live mode active bar — replaces the link when in live chat */
.live-support-active {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.08), rgba(245, 124, 0, 0.05));
    border-bottom: 1px solid rgba(255, 152, 0, 0.15);
    animation: liveBarFade 0.3s ease;
}

@keyframes liveBarFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.live-active-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary, #64748b);
}

.live-active-info strong {
    color: var(--text-primary, #334155);
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #FF9800;
    display: inline-block;
    animation: liveDotPulse 1.5s infinite ease-in-out;
}

@keyframes liveDotPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(255, 152, 0, 0); }
}

.live-end-btn {
    background: none;
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #dc3545;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.live-end-btn:hover {
    background: rgba(220, 53, 69, 0.08);
    border-color: rgba(220, 53, 69, 0.5);
}

.live-end-btn i {
    font-size: 10px;
}

/* Dark Mode for Live Support */
body.dark-mode .live-support-link {
    color: #94a3b8;
}

body.dark-mode .live-support-link a {
    color: #6ee7a0;
}

body.dark-mode .live-support-active {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.12), rgba(245, 124, 0, 0.06));
    border-bottom-color: rgba(255, 152, 0, 0.2);
}

body.dark-mode .live-active-info {
    color: #cbd5e1;
}

body.dark-mode .live-active-info strong {
    color: #f1f5f9;
}

body.dark-mode .live-end-btn {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
}

body.dark-mode .live-end-btn:hover {
    background: rgba(248, 113, 113, 0.1);
}
