/* =========================================================
   AI CHAT ASSISTANT WIDGET (Js/ai-chat.js, every page)
   Bottom-left, so it doesn't clash with WhatsApp / back-to-top
   on the right.
   ========================================================= */
.aic {
    --aic-teal: #19a985;
    --aic-teal-dark: #12655f;
    --aic-ink: #0a2a28;
    --aic-text: #3d5754;
    font-family: inherit;
}

/* ---------- Launcher button ---------- */
.aic-toggle {
    position: fixed;
    left: 22px;
    bottom: 22px;
    z-index: 99990;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    font-size: 24px;
    background: linear-gradient(135deg, var(--aic-teal), var(--aic-teal-dark));
    box-shadow: 0 10px 26px rgba(18, 101, 95, 0.45);
    transition: transform 0.3s ease;
}

.aic-toggle:hover {
    transform: scale(1.08);
}

/* Pulsing ring to draw attention */
.aic-toggle::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--aic-teal);
    animation: aicPulse 2.4s ease-out infinite;
}

@keyframes aicPulse {
    0%   { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
}

.aic-toggle .aic-ico-close { display: none; }
.aic.is-open .aic-toggle .aic-ico-open { display: none; }
.aic.is-open .aic-toggle .aic-ico-close { display: inline; }
.aic.is-open .aic-toggle::before { display: none; }

/* Unread dot */
.aic-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffae00;
    border: 2px solid #fff;
}

.aic.is-open .aic-dot,
.aic.seen .aic-dot { display: none; }

/* ---------- Greeting teaser bubble ---------- */
.aic-teaser {
    position: fixed;
    left: 92px;
    bottom: 34px;
    z-index: 99989;
    max-width: 230px;
    padding: 12px 34px 12px 14px;
    border-radius: 16px 16px 16px 4px;
    background: #fff;
    color: var(--aic-ink);
    font-size: 13.5px;
    line-height: 1.45;
    box-shadow: 0 12px 30px rgba(10, 42, 40, 0.2);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s;
}

.aic-teaser.show {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.aic-teaser-close {
    position: absolute;
    top: 6px;
    right: 8px;
    border: none;
    background: none;
    color: #8aa8a3;
    font-size: 14px;
    cursor: pointer;
}

/* ---------- Chat window ---------- */
.aic-window {
    position: fixed;
    left: 22px;
    bottom: 96px;
    z-index: 99991;
    width: 370px;
    height: 540px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    overflow: hidden;
    background: #f6fbfa;
    box-shadow: 0 24px 60px rgba(10, 42, 40, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.96);
    transform-origin: bottom left;
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2), visibility 0.3s;
}

.aic.is-open .aic-window {
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* Header */
.aic-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: #fff;
    background: linear-gradient(120deg, #0a2b29, var(--aic-teal-dark) 60%, var(--aic-teal));
}

.aic-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    background: rgba(255, 255, 255, 0.16);
}

.aic-avatar::after {
    content: "";
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #3ddc84;
    border: 2px solid #12655f;
}

.aic-header strong {
    display: block;
    font-size: 15.5px;
}

.aic-header small {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.aic-header-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.aic-icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: background 0.25s ease;
}

.aic-icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Messages */
.aic-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.aic-msg {
    max-width: 85%;
    padding: 10px 13px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: aicIn 0.3s ease both;
}

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

.aic-msg.bot {
    align-self: flex-start;
    color: var(--aic-ink);
    background: #fff;
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 3px 10px rgba(10, 42, 40, 0.06);
}

.aic-msg.user {
    align-self: flex-end;
    color: #fff;
    background: linear-gradient(135deg, var(--aic-teal), var(--aic-teal-dark));
    border-radius: 16px 4px 16px 16px;
}

.aic-msg.success {
    border-left: 4px solid #3ddc84;
}

.aic-msg a {
    color: var(--aic-teal-dark);
    font-weight: 600;
}

/* Typing indicator */
.aic-typing {
    align-self: flex-start;
    display: flex;
    gap: 5px;
    padding: 12px 14px;
    border-radius: 4px 16px 16px 16px;
    background: #fff;
}

.aic-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--aic-teal);
    animation: aicDot 1.2s ease-in-out infinite;
}

.aic-typing span:nth-child(2) { animation-delay: 0.15s; }
.aic-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aicDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

/* Quick replies */
.aic-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 14px 10px;
}

.aic-quick button {
    padding: 7px 12px;
    border-radius: 50px;
    border: 1.5px solid #cfe7e2;
    background: #fff;
    color: var(--aic-teal-dark);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.aic-quick button:hover {
    background: var(--aic-teal);
    border-color: var(--aic-teal);
    color: #fff;
    transform: translateY(-2px);
}

/* Input */
.aic-input {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e3efec;
    background: #fff;
}

.aic-input textarea {
    flex: 1;
    resize: none;
    height: 42px;
    min-height: 42px !important;
    max-height: 100px;
    padding: 10px 12px;
    border: 1.5px solid #dcebe8;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--aic-ink);
    background: #f6fbfa;
    outline: none;
    transition: border-color 0.25s ease;
}

.aic-input textarea:focus {
    border-color: var(--aic-teal);
    background: #fff;
}

.aic-send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, var(--aic-teal), var(--aic-teal-dark));
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.aic-send:hover {
    transform: scale(1.06);
}

.aic-send:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
}

.aic-foot {
    padding: 0 12px 8px;
    background: #fff;
    text-align: center;
    font-size: 11px;
    color: #8aa8a3;
}

/* ---------- Phones ---------- */
@media (max-width: 480px) {
    .aic-toggle {
        left: 16px;
        bottom: 16px;
        width: 54px;
        height: 54px;
    }

    .aic-window {
        left: 8px;
        right: 8px;
        bottom: 80px;
        width: auto;
        height: calc(100vh - 100px);
    }

    .aic-teaser {
        left: 80px;
        bottom: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .aic-toggle::before,
    .aic-msg,
    .aic-typing span {
        animation: none;
    }
}
