/* ============================================
   QuantumLogic Chatbot Stylesheet
   Version: 2.0 | Production Ready
   ============================================ */

:root {
    --ql-accent: #00ffc4;
    --ql-accent-glow: rgba(0, 255, 196, 0.15);
    --ql-bg-primary: #0a0a0f;
    --ql-bg-secondary: #111118;
    --ql-bg-tertiary: #1a1a24;
    --ql-text-primary: #ffffff;
    --ql-text-secondary: #b0b0c0;
    --ql-text-muted: #6b6b80;
    --ql-border: rgba(255, 255, 255, 0.08);
    --ql-border-hover: rgba(0, 255, 196, 0.3);
    --ql-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --ql-radius: 16px;
    --ql-radius-sm: 10px;
    --ql-radius-xs: 8px;
    --ql-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ql-font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    --ql-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Floating Chat Button ---- */
.ql-chat-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ql-bg-secondary);
    border: 1.5px solid var(--ql-border);
    cursor: pointer;
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ql-transition);
    box-shadow: var(--ql-shadow);
    backdrop-filter: blur(10px);
}

.ql-chat-toggle:hover {
    border-color: var(--ql-accent);
    box-shadow: 0 8px 40px var(--ql-accent-glow);
    transform: translateY(-2px);
}

.ql-chat-toggle svg {
    width: 26px;
    height: 26px;
    stroke: var(--ql-accent);
    fill: none;
    stroke-width: 2;
    transition: transform var(--ql-transition);
}

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

.ql-chat-toggle::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid var(--ql-bg-primary);
    opacity: 0;
    transition: opacity 0.3s;
}

.ql-chat-toggle.unread::after {
    opacity: 1;
    animation: ql-pulse 2s infinite;
}

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

/* ---- Chat Window ---- */
.ql-chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--ql-bg-primary);
    border: 1px solid var(--ql-border);
    border-radius: var(--ql-radius);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    box-shadow: var(--ql-shadow);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ---- Header ---- */
.ql-chat-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--ql-border);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.ql-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ql-accent), #00b8ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: var(--ql-bg-primary);
    flex-shrink: 0;
}

.ql-chat-header-info {
    flex: 1;
    min-width: 0;
}

.ql-chat-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ql-text-primary);
}

.ql-chat-subtitle {
    font-size: 0.72rem;
    color: var(--ql-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ql-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    animation: ql-status-pulse 2s infinite;
}

@keyframes ql-status-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

.ql-chat-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--ql-bg-tertiary);
    color: var(--ql-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ql-transition);
    flex-shrink: 0;
}

.ql-chat-close:hover {
    background: rgba(255, 75, 75, 0.2);
    color: #ff6b6b;
}

/* ---- Messages Area ---- */
.ql-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

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

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

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

/* ---- Message Bubbles ---- */
.ql-message {
    display: flex;
    gap: 10px;
    animation: ql-message-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 90%;
}

@keyframes ql-message-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

.ql-message.bot .ql-message-avatar {
    background: var(--ql-accent-glow);
    color: var(--ql-accent);
}

.ql-message.user .ql-message-avatar {
    background: var(--ql-bg-tertiary);
    color: var(--ql-text-secondary);
}

.ql-message-bubble {
    padding: 12px 16px;
    border-radius: var(--ql-radius-sm);
    font-size: 0.88rem;
    line-height: 1.55;
    word-break: break-word;
}

.ql-message.bot .ql-message-bubble {
    background: var(--ql-bg-secondary);
    border: 1px solid var(--ql-border);
    color: var(--ql-text-primary);
}

.ql-message.user .ql-message-bubble {
    background: var(--ql-accent-glow);
    border: 1px solid rgba(0, 255, 196, 0.2);
    color: var(--ql-text-primary);
}

.ql-message-bubble ul {
    margin: 8px 0 0 0;
    padding-left: 18px;
    list-style: none;
}

.ql-message-bubble ul li {
    margin-bottom: 6px;
    position: relative;
}

.ql-message-bubble ul li::before {
    content: '\203A';
    position: absolute;
    left: -14px;
    color: var(--ql-accent);
    font-weight: 700;
}

.ql-message-bubble strong {
    color: var(--ql-accent);
    font-weight: 600;
}

.ql-message-bubble code {
    font-family: var(--ql-font-mono);
    font-size: 0.8em;
    background: rgba(0, 255, 196, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--ql-accent);
}

.ql-message-time {
    font-size: 0.65rem;
    color: var(--ql-text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

/* ---- Typing Indicator ---- */
.ql-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

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

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

@keyframes ql-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
}

/* ---- Suggestion Chips ---- */
.ql-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 16px 16px 16px;
    flex-shrink: 0;
}

.ql-chip {
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--ql-border);
    background: var(--ql-bg-secondary);
    color: var(--ql-text-secondary);
    transition: all var(--ql-transition);
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.ql-chip:hover {
    border-color: var(--ql-accent);
    background: var(--ql-accent-glow);
    color: var(--ql-accent);
    transform: translateY(-1px);
}

.ql-chip:active {
    transform: scale(0.96);
}

/* ---- Input Area ---- */
.ql-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--ql-border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.ql-chat-input {
    flex: 1;
    padding: 10px 16px;
    border-radius: var(--ql-radius-xs);
    border: 1px solid var(--ql-border);
    background: var(--ql-bg-secondary);
    color: var(--ql-text-primary);
    font-family: var(--ql-font);
    font-size: 0.88rem;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    outline: none;
    transition: border-color var(--ql-transition);
    line-height: 1.5;
}

.ql-chat-input:focus {
    border-color: var(--ql-accent);
    box-shadow: 0 0 0 3px var(--ql-accent-glow);
}

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

.ql-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--ql-accent);
    color: var(--ql-bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ql-transition);
    flex-shrink: 0;
    font-weight: 700;
}

.ql-send-btn:hover {
    box-shadow: 0 4px 20px var(--ql-accent-glow);
    transform: scale(1.05);
}

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

/* ---- Lead Capture Form ---- */
.ql-lead-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 0;
}

.ql-lead-form input {
    padding: 10px 14px;
    border-radius: var(--ql-radius-xs);
    border: 1px solid var(--ql-border);
    background: var(--ql-bg-primary);
    color: var(--ql-text-primary);
    font-family: var(--ql-font);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--ql-transition);
}

.ql-lead-form input:focus {
    border-color: var(--ql-accent);
}

.ql-lead-form button {
    padding: 10px;
    border-radius: var(--ql-radius-xs);
    border: none;
    background: var(--ql-accent);
    color: var(--ql-bg-primary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--ql-transition);
}

.ql-lead-form button:hover {
    box-shadow: 0 4px 20px var(--ql-accent-glow);
}

.ql-lead-form .ql-skip-btn {
    background: transparent;
    border: 1px solid var(--ql-border);
    color: var(--ql-text-muted);
}

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

    .ql-chat-window.open {
        border-radius: 0;
    }

    .ql-chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    .ql-chat-header {
        padding-top: max(18px, env(safe-area-inset-top));
    }

    .ql-chat-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    .ql-message,
    .ql-chat-window,
    .ql-chat-toggle {
        animation: none !important;
        transition: none !important;
    }
}