/**
 * AI Chat Widget – Valeacell.com
 * CSS Custom Properties, Responsive, Dark Mode
 */
:root {
    --aichat-primary: #099405;
    --aichat-primary-hover: #077303;
    --aichat-bg: #ffffff;
    --aichat-bg-secondary: #f8fafc;
    --aichat-text: #1e293b;
    --aichat-text-muted: #64748b;
    --aichat-border: #e2e8f0;
    --aichat-shadow: 0 4px 20px rgba(0,0,0,.15);
    --aichat-radius: 12px;
}



#aichat-widget {
    position: fixed;
    bottom: 20px;
    z-index: 99999;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
}

#aichat-widget.aichat-left { left: 20px; }
#aichat-widget.aichat-right { right: 20px; }

.aichat-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    pointer-events: all;
    background: var(--aichat-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--aichat-shadow);
    transition: transform .2s, background .2s;
}

.aichat-btn:hover {
    background: var(--aichat-primary-hover);
    transform: scale(1.05);
}

.aichat-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--aichat-primary);
    opacity: 0;
    animation: aichat-pulse 2s infinite;
}

@keyframes aichat-pulse {
    0% { transform: scale(1); opacity: .6; }
    100% { transform: scale(1.2); opacity: 0; }
}

.aichat-window {
    display: none;
    pointer-events: all;
    position: absolute;
    bottom: 70px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--aichat-bg);
    border-radius: var(--aichat-radius);
    box-shadow: var(--aichat-shadow);
    flex-direction: column;
    overflow: hidden;
}

.aichat-window.aichat-right { right: 0; }
.aichat-window.aichat-left { left: 0; }
.aichat-window.aichat-open { display: flex; }

.aichat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--aichat-bg-secondary);
    border-bottom: 1px solid var(--aichat-border);
}

.aichat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aichat-primary), #04c404);
    margin-right: 12px;
}

.aichat-header-text strong {
    display: block;
    color: var(--aichat-text);
}

.aichat-status {
    font-size: 12px;
    color: var(--aichat-text-muted);
}

.aichat-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--aichat-text-muted);
    cursor: pointer;
    padding: 0 4px;
}

.aichat-close:hover { color: var(--aichat-text); }

.aichat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aichat-msg {
    max-width: 85%;
    align-self: flex-start;
}

.aichat-msg-user {
    align-self: flex-end;
}

.aichat-msg-content {
    padding: 10px 14px;
    border-radius: var(--aichat-radius);
    background: var(--aichat-bg-secondary);
    color: var(--aichat-text);
}

.aichat-msg-user .aichat-msg-content {
    background: var(--aichat-primary);
    color: #fff;
}

.aichat-typing .aichat-dots span {
    animation: aichat-blink 1.4s infinite;
}

.aichat-dots span:nth-child(2) { animation-delay: .2s; }
.aichat-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes aichat-blink {
    0%, 80%, 100% { opacity: .3; }
    40% { opacity: 1; }
}

.aichat-quick-replies {
    padding: 0 16px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aichat-input-area {
    display: flex;
    padding: 12px 16px;
    gap: 8px;
    border-top: 1px solid var(--aichat-border);
}

.aichat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--aichat-border);
    border-radius: 20px;
    background: var(--aichat-bg);
    color: var(--aichat-text);
}

.aichat-input-area input:focus {
    outline: none;
    border-color: var(--aichat-primary);
}

.aichat-input-area button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--aichat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aichat-input-area button:hover {
    background: var(--aichat-primary-hover);
}

.aichat-footer {
    padding: 8px 16px;
    font-size: 11px;
    color: var(--aichat-text-muted);
}

.aichat-footer a { color: var(--aichat-primary); }
.aichat-bubble {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--aichat-text);
    color: var(--aichat-bg);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 8px;
    white-space: nowrap;
    animation: aichat-fadeIn .3s;
}

@keyframes aichat-fadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 480px) {
    #aichat-widget { bottom: 12px; }
    .aichat-window { width: calc(100vw - 24px); right: 12px; left: 12px; bottom: 68px; }
}

/* Typing indicator - standalone div with direct spans */
#aichat-typing {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 4px;
}
#aichat-typing[hidden] { display: none; }
#aichat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--aichat-primary, #099405);
    display: inline-block;
    animation: aichat-blink 1.4s infinite;
}
#aichat-typing span:nth-child(2) { animation-delay: .2s; }
#aichat-typing span:nth-child(3) { animation-delay: .4s; }

/* Link color */
.aichat-msg-content a {
    color: var(--aichat-link-color, #099405);
    text-decoration: underline;
}
.aichat-msg-content a:hover {
    opacity: .8;
}
