/* =====================================================
   ARI AI AGENT — Chat Widget Styles
   Anovas Integrated Systems
   ===================================================== */

/* ---- VARIABLES ---- */
:root {
    --ari-bg:          #0a0f1e;
    --ari-surface:     #0f172a;
    --ari-surface-2:   #1e293b;
    --ari-border:      rgba(51, 65, 85, 0.7);
    --ari-blue:        #38BDF8;
    --ari-orange:      #F97316;
    --ari-teal:        #14B8A6;
    --ari-text:        #f1f5f9;
    --ari-muted:       #94a3b8;
    --ari-user-bubble: #38BDF8;
    --ari-bot-bubble:  #1e293b;
    --ari-radius:      1rem;
    --ari-shadow:      0 25px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(56,189,248,0.08);
    --ari-z:           99999;
}

/* ---- LAUNCHER BUTTON ---- */
#ari-launcher {
    position: fixed;
    bottom: 1.75rem;
    z-index: var(--ari-z);
    width: 3.75rem;
    height: 3.75rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0ea5e9, #38BDF8);
    box-shadow: 0 8px 30px rgba(56,189,248,0.4), 0 0 0 0 rgba(56,189,248,0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 0;
    animation: ariPulseRing 3s ease-in-out infinite;
    outline: none;
}
#ari-launcher.side-right { right: 1.75rem; }
#ari-launcher.side-left  { left:  1.75rem; }

#ari-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(56,189,248,0.55), 0 0 0 0 rgba(56,189,248,0.2);
}
#ari-launcher:focus-visible {
    outline: 3px solid var(--ari-blue);
    outline-offset: 4px;
}

@keyframes ariPulseRing {
    0%  { box-shadow: 0 8px 30px rgba(56,189,248,0.4), 0 0 0 0   rgba(56,189,248,0.3); }
    50% { box-shadow: 0 8px 30px rgba(56,189,248,0.4), 0 0 0 14px rgba(56,189,248,0); }
    100%{ box-shadow: 0 8px 30px rgba(56,189,248,0.4), 0 0 0 0   rgba(56,189,248,0); }
}

.ari-launcher-avatar {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.9);
    display: block;
    pointer-events: none;
}

.ari-launcher-icon {
    display: none;
    width: 1.5rem;
    height: 1.5rem;
    color: var(--ari-bg);
    pointer-events: none;
}

.ari-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--ari-bg);
}

/* Unread badge */
.ari-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 1.25rem;
    height: 1.25rem;
    background: var(--ari-orange);
    color: white;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--ari-bg);
    animation: badgePop 0.3s ease;
}
@keyframes badgePop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* Launcher tooltip */
.ari-tooltip {
    position: absolute;
    bottom: calc(100% + 0.75rem);
    white-space: nowrap;
    background: var(--ari-surface);
    border: 1px solid var(--ari-border);
    color: var(--ari-text);
    font-size: 0.8125rem;
    font-family: 'Inter', sans-serif;
    padding: 0.5rem 0.875rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.ari-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--ari-border);
}
#ari-launcher:hover .ari-tooltip,
#ari-launcher:focus-visible .ari-tooltip {
    opacity: 1;
    transform: translateY(0);
}

/* ---- CHAT WINDOW ---- */
#ari-chat-window {
    position: fixed;
    bottom: 6rem;
    z-index: var(--ari-z);
    width: 24rem;
    max-width: calc(100vw - 1.5rem);
    height: 600px;
    max-height: calc(100vh - 7rem);
    background: var(--ari-bg);
    border: 1px solid var(--ari-border);
    border-radius: var(--ari-radius);
    box-shadow: var(--ari-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', sans-serif;

    /* Hidden state */
    opacity: 0;
    transform: translateY(1rem) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
#ari-chat-window.side-right { right: 1.75rem; }
#ari-chat-window.side-left  { left:  1.75rem; }
#ari-chat-window.ari-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ---- HEADER ---- */
.ari-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--ari-surface) 0%, rgba(14,165,233,0.08) 100%);
    border-bottom: 1px solid var(--ari-border);
    flex-shrink: 0;
}
.ari-header-avatar {
    position: relative;
    flex-shrink: 0;
}
.ari-header-avatar img {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--ari-blue);
    display: block;
}
.ari-header-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--ari-surface);
}
.ari-header-info { flex: 1; min-width: 0; }
.ari-header-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--ari-text);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.ari-sparkle { color: var(--ari-orange); font-size: 0.75rem; }
.ari-header-status { font-size: 0.6875rem; color: var(--ari-muted); margin-top: 0.1rem; }

.ari-header-actions { display: flex; gap: 0.375rem; }
.ari-header-btn {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 0.375rem;
    background: var(--ari-surface-2);
    color: var(--ari-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}
.ari-header-btn:hover { background: rgba(56,189,248,0.1); color: var(--ari-blue); }
.ari-header-btn svg { width: 1rem; height: 1rem; pointer-events: none; }

/* ---- MESSAGES AREA ---- */
.ari-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}
.ari-messages::-webkit-scrollbar { width: 4px; }
.ari-messages::-webkit-scrollbar-track { background: transparent; }
.ari-messages::-webkit-scrollbar-thumb { background: var(--ari-surface-2); border-radius: 2px; }

/* Message row */
.ari-message {
    display: flex;
    gap: 0.625rem;
    animation: msgIn 0.25s ease forwards;
}
.ari-message.ari-message--user { flex-direction: row-reverse; }

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

.ari-msg-avatar {
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    align-self: flex-end;
    border: 1px solid var(--ari-border);
}
.ari-msg-avatar.ari-msg-avatar--user {
    background: var(--ari-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ari-bg);
    font-family: 'Orbitron', sans-serif;
}

.ari-msg-bubble {
    max-width: 78%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    line-height: 1.65;
    word-break: break-word;
}
.ari-message--bot .ari-msg-bubble {
    background: var(--ari-bot-bubble);
    color: #cbd5e1;
    border-bottom-left-radius: 0.25rem;
    border: 1px solid var(--ari-border);
}
.ari-message--user .ari-msg-bubble {
    background: var(--ari-user-bubble);
    color: var(--ari-bg);
    border-bottom-right-radius: 0.25rem;
    font-weight: 500;
}

/* Markdown-like formatting in bot messages */
.ari-msg-bubble strong { color: var(--ari-text); font-weight: 600; }
.ari-msg-bubble a { color: var(--ari-blue); text-decoration: underline; }
.ari-msg-bubble a:hover { color: #7dd3fc; }
.ari-msg-bubble br + br { display: none; }
.ari-msg-bubble ul, .ari-msg-bubble ol { padding-left: 1.25rem; margin: 0.5rem 0; }
.ari-msg-bubble li { margin-bottom: 0.25rem; }

/* Typing indicator */
.ari-typing {
    display: flex;
    gap: 0.625rem;
    align-items: flex-end;
    animation: msgIn 0.25s ease forwards;
}
.ari-typing-dots {
    background: var(--ari-bot-bubble);
    border: 1px solid var(--ari-border);
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    padding: 0.875rem 1.125rem;
    display: flex;
    gap: 4px;
    align-items: center;
}
.ari-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--ari-muted);
    border-radius: 50%;
    animation: typingBounce 1.2s ease-in-out infinite;
}
.ari-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ari-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%,60%,100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ---- QUICK REPLIES ---- */
.ari-quick-replies {
    padding: 0 1.25rem 0.75rem;
    flex-shrink: 0;
}
.ari-quick-replies-label {
    font-size: 0.6875rem;
    color: var(--ari-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}
.ari-quick-replies-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.ari-quick-reply {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--ari-border);
    border-radius: 9999px;
    background: transparent;
    color: var(--ari-muted);
    font-size: 0.75rem;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.ari-quick-reply:hover {
    border-color: var(--ari-blue);
    color: var(--ari-blue);
    background: rgba(56,189,248,0.06);
}

/* ---- LEAD QUALIFIER ---- */
.ari-qualifier {
    padding: 0 1.25rem 0.75rem;
    flex-shrink: 0;
}
.ari-qualifier-label {
    font-size: 0.6875rem;
    color: var(--ari-orange);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.ari-qualifier-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.ari-qualifier-btn {
    padding: 0.375rem 0.875rem;
    border: 1px solid rgba(249,115,22,0.3);
    border-radius: 0.5rem;
    background: rgba(249,115,22,0.06);
    color: #fdba74;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}
.ari-qualifier-btn:hover {
    border-color: var(--ari-orange);
    color: var(--ari-orange);
    background: rgba(249,115,22,0.1);
}

/* ---- GROWTH SCORE ANALYSIS CARD ---- */
.ari-score-card {
    background: linear-gradient(135deg, rgba(56,189,248,0.08), rgba(20,184,166,0.06));
    border: 1px solid rgba(56,189,248,0.2);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 0.5rem;
}
.ari-score-card-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ari-blue);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.ari-score-card-content {
    font-size: 0.8125rem;
    color: #cbd5e1;
    line-height: 1.7;
    white-space: pre-wrap;
}
.ari-score-card-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 1rem;
    padding: 0.5rem 1.125rem;
    background: var(--ari-orange);
    color: white;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-decoration: none;
    transition: filter 0.2s ease;
    border: none;
    cursor: pointer;
    width: 100%;
    justify-content: center;
}
.ari-score-card-cta:hover { filter: brightness(1.1); color: white; }

/* ---- INPUT AREA ---- */
.ari-input-area {
    padding: 0.875rem 1.25rem 1rem;
    border-top: 1px solid var(--ari-border);
    flex-shrink: 0;
    background: var(--ari-surface);
}
.ari-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}
.ari-input {
    flex: 1;
    background: var(--ari-bg);
    border: 1px solid var(--ari-border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--ari-text);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    resize: none;
    max-height: 6rem;
    min-height: 2.75rem;
    overflow-y: auto;
    transition: border-color 0.2s ease;
    outline: none;
    line-height: 1.5;
}
.ari-input:focus { border-color: var(--ari-blue); box-shadow: 0 0 0 3px rgba(56,189,248,0.1); }
.ari-input::placeholder { color: #475569; }
.ari-input:disabled { opacity: 0.5; cursor: not-allowed; }

.ari-send-btn {
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    border-radius: 0.75rem;
    background: var(--ari-blue);
    color: var(--ari-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
    outline: none;
}
.ari-send-btn:hover:not(:disabled) { background: #7dd3fc; transform: scale(1.05); }
.ari-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ari-send-btn svg { width: 1.125rem; height: 1.125rem; pointer-events: none; }

.ari-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
}
.ari-powered {
    font-size: 0.625rem;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.ari-powered span { color: #475569; }
.ari-char-count { font-size: 0.625rem; color: #334155; }
.ari-char-count.near-limit { color: var(--ari-orange); }

/* ---- OFFLINE STATE ---- */
.ari-offline-msg {
    padding: 1rem 1.25rem;
    background: rgba(249,115,22,0.08);
    border-top: 1px solid rgba(249,115,22,0.2);
    flex-shrink: 0;
}
.ari-offline-msg p {
    font-size: 0.8125rem;
    color: #fdba74;
    margin: 0 0 0.5rem;
}
.ari-offline-msg a {
    color: var(--ari-blue);
    font-weight: 500;
}

/* ---- MOBILE ---- */
@media (max-width: 480px) {
    #ari-chat-window {
        bottom: 0;
        right: 0 !important;
        left: 0 !important;
        width: 100%;
        max-width: 100%;
        height: 85dvh;
        border-radius: 1.25rem 1.25rem 0 0;
        border-bottom: none;
    }
    #ari-launcher.side-right { right: 1.25rem; bottom: 1.25rem; }
    #ari-launcher.side-left  { left:  1.25rem; bottom: 1.25rem; }
}

/* ---- REDUCED MOTION ---- */
@media (prefers-reduced-motion: reduce) {
    #ari-launcher { animation: none; }
    .ari-typing-dot { animation: none; opacity: 0.5; }
    .ari-message { animation: none; }
    #ari-chat-window { transition: opacity 0.1s; }
}
