/**
 * Bright Automations - AI Helpdesk Chatbot Styles
 * Matches the website's design system
 */

/* ===========================
   CHATBOT CONTAINER
   =========================== */
.ba-chatbot {
    --chat-primary: #2E7D8A;
    --chat-primary-dark: #1D5A64;
    --chat-primary-light: #4AABB8;
    --chat-bg: #FFFFFF;
    --chat-bg-secondary: #F8FAFB;
    --chat-text: #374151;
    --chat-text-light: #6B7280;
    --chat-border: #E5E7EB;
    --chat-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    --chat-radius: 1rem;
    --chat-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--chat-font);
}

/* ===========================
   TOGGLE BUTTON
   =========================== */
.ba-chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(46, 125, 138, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.ba-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(46, 125, 138, 0.5);
}

.ba-chat-toggle:active {
    transform: scale(0.95);
}

.ba-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.ba-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #EF4444;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ===========================
   CHAT WINDOW
   =========================== */
.ba-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 1px solid var(--chat-border);
}

.ba-chat-window.ba-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ===========================
   HEADER
   =========================== */
.ba-chat-header {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ba-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ba-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.ba-avatar img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.ba-avatar-fallback {
    font-size: 16px;
    font-weight: 700;
    color: var(--chat-primary);
}

.ba-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ba-header-title {
    font-weight: 600;
    font-size: 15px;
}

.ba-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ba-status-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ba-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ba-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===========================
   MESSAGES AREA
   =========================== */
.ba-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--chat-bg-secondary);
}

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

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

.ba-chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

.ba-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* ===========================
   MESSAGE BUBBLES
   =========================== */
.ba-message {
    display: flex;
    animation: messageSlide 0.3s ease-out;
}

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

.ba-bot-message {
    justify-content: flex-start;
}

.ba-user-message {
    justify-content: flex-end;
}

.ba-message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ba-bot-message .ba-message-content {
    background: var(--chat-bg);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.ba-user-message .ba-message-content {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ba-message-content strong {
    font-weight: 600;
}

.ba-message-content .ba-bullet {
    color: var(--chat-primary);
    font-weight: 600;
}

.ba-chat-link {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 16px;
    background: var(--chat-primary);
    color: white !important;
    text-decoration: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.ba-chat-link:hover {
    background: var(--chat-primary-dark);
    transform: translateX(3px);
}

/* ===========================
   TYPING INDICATOR
   =========================== */
.ba-typing-indicator .ba-message-content {
    padding: 16px 20px;
}

.ba-typing-dots {
    display: flex;
    gap: 5px;
}

.ba-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--chat-text-light);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.ba-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.ba-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ba-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* ===========================
   QUICK ACTIONS
   =========================== */
.ba-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    background: var(--chat-bg);
    border-top: 1px solid var(--chat-border);
}

.ba-quick-btn {
    padding: 8px 16px;
    background: var(--chat-bg-secondary);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--chat-text);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--chat-font);
}

.ba-quick-btn:hover {
    background: var(--chat-primary);
    border-color: var(--chat-primary);
    color: white;
    transform: translateY(-1px);
}

/* ===========================
   INPUT AREA
   =========================== */
.ba-chat-input-area {
    padding: 16px 20px;
    background: var(--chat-bg);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.ba-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--chat-bg-secondary);
    border: 1px solid var(--chat-border);
    border-radius: 25px;
    padding: 4px 4px 4px 16px;
    transition: all 0.2s ease;
}

.ba-input-container:focus-within {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(46, 125, 138, 0.1);
}

.ba-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--chat-text);
    font-family: var(--chat-font);
    outline: none;
}

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

.ba-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ba-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(46, 125, 138, 0.4);
}

.ba-send-btn:active {
    transform: scale(0.95);
}

.ba-powered-by {
    text-align: center;
    font-size: 11px;
    color: var(--chat-text-light);
    margin-top: 10px;
}

/* ===========================
   RESPONSIVE STYLES
   =========================== */
@media (max-width: 480px) {
    .ba-chatbot {
        bottom: 16px;
        right: 16px;
    }

    .ba-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        bottom: 76px;
        right: -8px;
    }

    .ba-chat-toggle {
        width: 56px;
        height: 56px;
    }

    .ba-chat-toggle svg {
        width: 24px;
        height: 24px;
    }

    .ba-message-content {
        max-width: 90%;
        font-size: 15px;
    }

    .ba-quick-actions {
        padding: 10px 16px;
    }

    .ba-quick-btn {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* ===========================
   ANIMATIONS
   =========================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ba-chatbot {
    animation: fadeIn 0.5s ease-out;
}

/* Pulse animation for toggle button when not yet opened */
.ba-chat-toggle:not(.opened)::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--chat-primary);
    opacity: 0.3;
    animation: ripple 2s ease-out infinite;
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.3;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ba-chat-window {
        border: 2px solid var(--chat-primary);
    }

    .ba-message-content {
        border: 1px solid var(--chat-border);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ba-chat-window,
    .ba-chat-toggle,
    .ba-message,
    .ba-typing-dots span {
        animation: none;
        transition: none;
    }

    .ba-chat-toggle::before {
        animation: none;
    }
}
