/* ========================================
   Felix AI Chatbot Styles
   Premium Professional Design - Blue & Teal
   ======================================== */

/* --- Color Tokens --- */
:root {
    --ai-primary: #0ea5e9;
    --ai-primary-dark: #0284c7;
    --ai-primary-deep: #0369a1;
    --ai-primary-light: #e0f2fe;
    --ai-primary-glow: rgba(14, 165, 233, 0.35);

    --ai-accent: #14b8a6;
    --ai-accent-dark: #0d9488;
    --ai-accent-glow: rgba(20, 184, 166, 0.3);

    --ai-surface: #ffffff;
    --ai-surface-alt: #f0f9ff;
    --ai-surface-hover: #e0f2fe;

    --ai-text: #0f172a;
    --ai-text-secondary: #475569;
    --ai-text-muted: #94a3b8;

    --ai-border: #e2e8f0;
    --ai-border-accent: #bae6fd;

    --ai-user-bubble: linear-gradient(135deg, #0ea5e9, #0284c7);
    --ai-bot-bubble: #f0f9ff;
    --ai-bot-bubble-border: #bae6fd;

    --ai-danger: #ef4444;
    --ai-success: #10b981;
}

/* ============================================
   Chat Toggle Button
   ============================================ */
.ai-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 62px;
    height: 62px;
    border-radius: 18px;
    background: linear-gradient(145deg, var(--ai-primary), var(--ai-accent));
    color: white;
    border: none;
    cursor: pointer;
    box-shadow:
        0 8px 28px var(--ai-primary-glow),
        0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    animation: chatFloat 4s ease-in-out infinite;
}

.ai-chat-toggle:hover {
    transform: translateY(-3px) scale(1.06);
    box-shadow:
        0 14px 36px var(--ai-primary-glow),
        0 4px 12px rgba(0, 0, 0, 0.1);
}

.ai-chat-toggle.active {
    animation: none;
    background: linear-gradient(145deg, #64748b, #475569);
    box-shadow: 0 6px 20px rgba(71, 85, 105, 0.35);
    border-radius: 50%;
}

.ai-chat-toggle svg {
    width: 26px;
    height: 26px;
    transition: transform 0.35s ease;
}

.ai-chat-toggle.active svg {
    transform: rotate(90deg);
}

.ai-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, var(--ai-accent), var(--ai-accent-dark));
    color: white;
    font-size: 9px;
    font-weight: 800;
    padding: 3px 7px;
    border-radius: 8px;
    border: 2px solid white;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes chatFloat {

    0%,
    100% {
        transform: translateY(0);
        box-shadow: 0 8px 28px var(--ai-primary-glow), 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    50% {
        transform: translateY(-4px);
        box-shadow: 0 14px 36px var(--ai-primary-glow), 0 4px 12px rgba(0, 0, 0, 0.1);
    }
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

/* ============================================
   Chat Window
   ============================================ */
.ai-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    max-height: calc(100vh - 140px);
    background: var(--ai-surface);
    border-radius: 20px;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.12),
        0 8px 24px rgba(0, 0, 0, 0.06),
        0 0 0 1px rgba(14, 165, 233, 0.08);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--ai-border);
}

.ai-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ============================================
   Chat Header
   ============================================ */
.ai-chat-header {
    padding: 18px 20px;
    background: linear-gradient(145deg, #0f172a, #1e293b);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.ai-chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ai-primary), var(--ai-accent), var(--ai-primary));
    background-size: 200% 100%;
    animation: headerShine 3s linear infinite;
}

@keyframes headerShine {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.ai-chat-avatar {
    width: 42px;
    height: 42px;
    background: linear-gradient(145deg, var(--ai-primary), var(--ai-accent));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
}

.ai-chat-avatar svg {
    width: 22px;
    height: 22px;
}

.ai-chat-header-info {
    flex: 1;
}

.ai-chat-header-info h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.2px;
}

.ai-chat-header-info p {
    font-size: 0.72rem;
    opacity: 0.7;
    margin: 3px 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-status-dot {
    width: 7px;
    height: 7px;
    background: var(--ai-success);
    border-radius: 50%;
    display: inline-block;
    animation: statusPulse 2.5s ease-in-out infinite;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
    }

    50% {
        opacity: 0.5;
        box-shadow: 0 0 2px rgba(16, 185, 129, 0.2);
    }
}

/* ============================================
   Quick Actions
   ============================================ */
.ai-quick-actions {
    padding: 10px 14px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    background: var(--ai-surface-alt);
    border-bottom: 1px solid var(--ai-border);
    flex-shrink: 0;
}

.ai-quick-actions::-webkit-scrollbar {
    display: none;
}

.ai-quick-btn {
    padding: 5px 13px;
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ai-primary-dark);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    font-family: inherit;
}

.ai-quick-btn:hover {
    background: var(--ai-primary-light);
    border-color: var(--ai-border-accent);
    color: var(--ai-primary-deep);
    transform: translateY(-1px);
}

/* ============================================
   Messages Area
   ============================================ */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 300px;
    max-height: 400px;
    scroll-behavior: smooth;
    background:
        radial-gradient(ellipse at top right, rgba(14, 165, 233, 0.03), transparent 60%),
        radial-gradient(ellipse at bottom left, rgba(20, 184, 166, 0.03), transparent 60%),
        var(--ai-surface);
}

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

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

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

/* ============================================
   Message Bubbles
   ============================================ */
.ai-message {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: messageIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-message.bot {
    align-self: flex-start;
}

.ai-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 700;
}

.ai-message.bot .ai-message-avatar {
    background: linear-gradient(145deg, var(--ai-primary), var(--ai-accent));
    color: white;
    box-shadow: 0 2px 8px var(--ai-primary-glow);
}

.ai-message.user .ai-message-avatar {
    background: #e2e8f0;
    color: #475569;
}

.ai-message-bubble {
    padding: 11px 15px;
    border-radius: 14px;
    font-size: 0.84rem;
    line-height: 1.65;
    word-wrap: break-word;
}

.ai-message.bot .ai-message-bubble {
    background: var(--ai-bot-bubble);
    color: var(--ai-text);
    border: 1px solid var(--ai-bot-bubble-border);
    border-bottom-left-radius: 4px;
}

.ai-message.user .ai-message-bubble {
    background: var(--ai-user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 3px 10px var(--ai-primary-glow);
}

/* Markdown in messages */
.ai-message-bubble strong {
    font-weight: 700;
}

.ai-message-bubble em {
    font-style: italic;
    opacity: 0.85;
}

.ai-message-bubble p {
    margin: 5px 0;
}

.ai-message-bubble p:first-child {
    margin-top: 0;
}

.ai-message-bubble p:last-child {
    margin-bottom: 0;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Typing Indicator
   ============================================ */
.ai-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    max-width: 88%;
}

.ai-typing-dots {
    display: flex;
    gap: 5px;
    padding: 13px 17px;
    background: var(--ai-bot-bubble);
    border: 1px solid var(--ai-bot-bubble-border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.ai-typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--ai-primary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
    opacity: 0.6;
}

.ai-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
    background: var(--ai-accent);
}

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

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* ============================================
   Chat Input
   ============================================ */
.ai-chat-input-area {
    padding: 14px;
    border-top: 1px solid var(--ai-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--ai-surface);
    flex-shrink: 0;
}

.ai-chat-input {
    flex: 1;
    padding: 11px 14px;
    border: 1.5px solid var(--ai-border);
    border-radius: 12px;
    font-size: 0.84rem;
    font-family: inherit;
    resize: none;
    min-height: 42px;
    max-height: 96px;
    outline: none;
    transition: all 0.25s ease;
    color: var(--ai-text);
    background: var(--ai-surface-alt);
}

.ai-chat-input:focus {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    background: var(--ai-surface);
}

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

.ai-chat-send {
    width: 42px;
    height: 42px;
    border: none;
    background: linear-gradient(145deg, var(--ai-primary), var(--ai-accent));
    color: white;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.ai-chat-send:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 14px var(--ai-primary-glow);
}

.ai-chat-send:active {
    transform: scale(0.94);
}

.ai-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.ai-chat-send svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   AI Powered Badge
   ============================================ */
.ai-powered-badge {
    padding: 7px 14px;
    text-align: center;
    font-size: 0.65rem;
    color: var(--ai-text-muted);
    background: var(--ai-surface-alt);
    flex-shrink: 0;
    letter-spacing: 0.2px;
}

.ai-powered-badge span {
    font-weight: 700;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   AI Insights Panel (Dashboard)
   ============================================ */
.ai-insights-card {
    background: linear-gradient(135deg, #f0f9ff, #f0fdfa);
    border: 1px solid var(--ai-border-accent);
    border-radius: 20px;
    padding: var(--space-6, 24px);
    margin-bottom: var(--space-6, 24px);
    position: relative;
    overflow: hidden;
}

.ai-insights-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ai-primary), var(--ai-accent), var(--ai-primary));
    background-size: 200% 100%;
    animation: headerShine 3s linear infinite;
}

.ai-insights-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.ai-insights-icon {
    width: 46px;
    height: 46px;
    background: linear-gradient(145deg, var(--ai-primary), var(--ai-accent));
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px var(--ai-primary-glow);
}

.ai-insights-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ai-text);
    margin: 0;
}

.ai-insights-subtitle {
    font-size: 0.82rem;
    color: var(--ai-text-secondary);
    margin: 2px 0 0;
}

.ai-insights-content {
    font-size: 0.88rem;
    color: var(--ai-text);
    line-height: 1.7;
}

.ai-insights-content p {
    margin-bottom: 10px;
}

.ai-insights-content strong {
    color: var(--ai-primary-deep);
}

.ai-insights-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--ai-text-muted);
}

.ai-insights-loading .ai-typing-dots {
    background: transparent;
    border: none;
}

/* ============================================
   Generate Button
   ============================================ */
.ai-generate-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    background: linear-gradient(145deg, var(--ai-primary), var(--ai-accent));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 14px;
    font-family: inherit;
}

.ai-generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px var(--ai-primary-glow);
}

.ai-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ai-generate-btn svg {
    width: 18px;
    height: 18px;
}

/* Spin animation for loading icons */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

/* ============================================
   Review Analysis Card
   ============================================ */
.ai-review-analysis {
    background: linear-gradient(135deg, #fefce8, #fff7ed);
    border: 1px solid #fde68a;
    border-radius: 16px;
    padding: 20px;
    margin-top: 14px;
}

.ai-review-analysis h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 12px;
}

.ai-review-analysis-content {
    font-size: 0.85rem;
    color: #78350f;
    line-height: 1.65;
}

/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 480px) {
    .ai-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 20px 20px 0 0;
    }

    .ai-chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .ai-chat-messages {
        max-height: calc(100vh - 260px);
    }
}