/* AI Chat Widget - Frontend Styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=DM+Sans:wght@300;400;500&display=swap');

:root {
    --acw-primary: #1a1a2e;
    --acw-accent:  #e94560;
    --acw-bg:      #ffffff;
    --acw-surface: #f7f7fb;
    --acw-border:  #ebebf5;
    --acw-text:    #1a1a2e;
    --acw-muted:   #9090aa;
    --acw-radius:  20px;
    --acw-shadow:  0 24px 64px rgba(26,26,46,0.18), 0 4px 16px rgba(26,26,46,0.08);
    --acw-w:       380px;
    --acw-h:       520px;
}

/* ── BUBBLE ── */
#acw-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--acw-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(26,26,46,0.32);
    z-index: 99998;
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s ease;
    border: none;
    outline: none;
}
#acw-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(26,26,46,0.4);
}
#acw-bubble:active { transform: scale(0.96); }

#acw-bubble svg {
    width: 26px;
    height: 26px;
    transition: opacity 0.2s, transform 0.2s;
}
#acw-bubble .acw-icon-open  { opacity: 1;  transform: rotate(0deg) scale(1); }
#acw-bubble .acw-icon-close { opacity: 0;  transform: rotate(90deg) scale(0.5); position: absolute; }

#acw-bubble.is-open .acw-icon-open  { opacity: 0;  transform: rotate(-90deg) scale(0.5); }
#acw-bubble.is-open .acw-icon-close { opacity: 1;  transform: rotate(0deg) scale(1); }

/* Pulse ring */
#acw-bubble::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--acw-primary);
    opacity: 0;
    animation: acw-pulse 2.5s ease-out infinite;
}
@keyframes acw-pulse {
    0%   { opacity: 0.7; transform: scale(1); }
    100% { opacity: 0;   transform: scale(1.5); }
}

/* Unread badge */
#acw-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: var(--acw-accent);
    border-radius: 50%;
    font-size: 10px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
    pointer-events: none;
}
#acw-badge.visible {
    opacity: 1;
    transform: scale(1);
}

/* ── WINDOW ── */
#acw-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    width: var(--acw-w);
    height: var(--acw-h);
    background: var(--acw-bg);
    border-radius: var(--acw-radius);
    box-shadow: var(--acw-shadow);
    display: flex;
    flex-direction: column;
    z-index: 99997;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
    font-family: 'DM Sans', sans-serif;
}
#acw-window.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── HEADER ── */
#acw-header {
    background: var(--acw-primary);
    padding: 18px 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.acw-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}
.acw-header-info { flex: 1; min-width: 0; }
.acw-header-name {
    font-family: 'DM Serif Display', serif;
    font-size: 16px;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.acw-header-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.acw-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
    animation: acw-blink 2s ease infinite;
}
@keyframes acw-blink {
    0%,100% { opacity: 1; }
    50%      { opacity: 0.4; }
}
#acw-header-clear {
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 8px;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    padding: 6px 8px;
    font-size: 11px;
    font-family: 'DM Sans', sans-serif;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
#acw-header-clear:hover {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

/* ── MESSAGES ── */
#acw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
#acw-messages::-webkit-scrollbar { width: 4px; }
#acw-messages::-webkit-scrollbar-track { background: transparent; }
#acw-messages::-webkit-scrollbar-thumb { background: var(--acw-border); border-radius: 4px; }

/* Welcome state */
.acw-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: 24px;
    gap: 8px;
    color: var(--acw-muted);
    font-size: 13px;
    line-height: 1.6;
}
.acw-welcome-icon { font-size: 36px; margin-bottom: 4px; }
.acw-welcome strong { color: var(--acw-text); font-size: 14px; font-weight: 500; }

/* Message bubbles */
.acw-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: acw-msg-in 0.25s ease both;
}
@keyframes acw-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.acw-msg.user { flex-direction: row-reverse; }

.acw-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}
.acw-msg.bot  .acw-msg-avatar { background: var(--acw-primary); }
.acw-msg.user .acw-msg-avatar { background: var(--acw-surface); }

.acw-bubble-text {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}
.acw-msg.bot  .acw-bubble-text {
    background: var(--acw-surface);
    color: var(--acw-text);
    border-bottom-left-radius: 4px;
}
.acw-msg.user .acw-bubble-text {
    background: var(--acw-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.acw-typing .acw-bubble-text {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
}
.acw-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--acw-muted);
    animation: acw-bounce 1.2s ease infinite;
}
.acw-dot:nth-child(2) { animation-delay: 0.15s; }
.acw-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes acw-bounce {
    0%,60%,100% { transform: translateY(0); }
    30%          { transform: translateY(-6px); }
}

/* ── INPUT ── */
#acw-input-area {
    border-top: 1px solid var(--acw-border);
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--acw-bg);
    flex-shrink: 0;
}
#acw-input {
    flex: 1;
    border: 1.5px solid var(--acw-border);
    border-radius: 14px;
    padding: 10px 14px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    color: var(--acw-text);
    background: var(--acw-surface);
    resize: none;
    outline: none;
    max-height: 100px;
    transition: border-color 0.2s;
    line-height: 1.5;
}
#acw-input:focus { border-color: var(--acw-primary); background: #fff; }
#acw-input::placeholder { color: var(--acw-muted); }

#acw-send {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--acw-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}
#acw-send:hover  { background: #2a2a4e; }
#acw-send:active { transform: scale(0.93); }
#acw-send:disabled { opacity: 0.45; cursor: not-allowed; }
#acw-send svg { width: 18px; height: 18px; }

/* Powered by */
#acw-footer-note {
    text-align: center;
    font-size: 10px;
    color: var(--acw-muted);
    padding: 0 0 8px;
    letter-spacing: 0.3px;
}

/* ── MOBILE ── */
@media (max-width: 480px) {
    :root {
        --acw-w: calc(100vw - 24px);
        --acw-h: calc(100dvh - 120px);
    }
    #acw-window {
        right: 12px;
        bottom: 96px;
    }
    #acw-bubble {
        right: 16px;
        bottom: 20px;
    }
}

/* ── CTA BAR ── */
#acw-cta-bar {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 10px 14px 0;
    flex-shrink: 0;
}
#acw-cta-bar:empty { display: none; }

.acw-cta-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 14px;
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.15s, transform 0.15s;
    cursor: pointer;
    letter-spacing: 0.1px;
}
.acw-cta-btn:hover  { opacity: 0.88; transform: translateY(-1px); }
.acw-cta-btn:active { transform: scale(0.97); }
.acw-cta-btn svg    { width: 14px; height: 14px; flex-shrink: 0; }

.acw-cta-primary {
    background: var(--acw-primary);
    color: #fff !important;
}
.acw-cta-fb {
    background: #1877f2;
    color: #fff !important;
}

/* ── PRE-CHAT FORM ── */
#acw-prechat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    overflow-y: auto;
}

.acw-prechat-inner {
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.acw-prechat-icon {
    font-size: 38px;
    margin-bottom: 12px;
}

.acw-prechat-title {
    font-family: 'DM Serif Display', serif;
    font-size: 20px;
    color: var(--acw-text);
    margin: 0 0 6px;
    font-weight: 400;
}

.acw-prechat-sub {
    font-size: 13px;
    color: var(--acw-muted);
    margin: 0 0 24px;
    line-height: 1.5;
}

.acw-field-group {
    text-align: left;
    margin-bottom: 14px;
}

.acw-field-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--acw-text);
    margin-bottom: 5px;
    letter-spacing: 0.2px;
}

.acw-field-input {
    width: 100%;
    border: 1.5px solid var(--acw-border);
    border-radius: 10px;
    padding: 10px 13px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    color: var(--acw-text);
    background: var(--acw-surface);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}
.acw-field-input:focus {
    border-color: var(--acw-primary);
    background: #fff;
}
.acw-field-input::placeholder { color: var(--acw-muted); }

.acw-field-error {
    display: block;
    font-size: 11.5px;
    color: #e94560;
    margin-top: 4px;
    min-height: 16px;
}

.acw-prechat-btn {
    width: 100%;
    background: var(--acw-primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
    transition: background 0.2s, transform 0.15s;
}
.acw-prechat-btn:hover  { background: #2a2a4e; }
.acw-prechat-btn:active { transform: scale(0.97); }
.acw-prechat-btn svg    { width: 16px; height: 16px; }

.acw-prechat-privacy {
    font-size: 11px;
    color: var(--acw-muted);
    margin: 12px 0 0;
    line-height: 1.5;
}

/* ── VISITOR PILL ── */
.acw-visitor-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    background: #f0f4ff;
    border-bottom: 1px solid #e8eeff;
    font-size: 12px;
    color: #445;
    flex-shrink: 0;
}
.acw-visitor-pill strong { color: var(--acw-text); }
.acw-pill-reset {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: var(--acw-muted);
    padding: 2px 5px;
    border-radius: 4px;
    transition: background 0.15s;
}
.acw-pill-reset:hover { background: #e0e8ff; color: #333; }

/* ── LOGO IMAGES ── */

/* Bubble button logo */
.acw-bubble-logo {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Header avatar logo */
.acw-avatar-logo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Bot message avatar logo */
.acw-msg-logo {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Welcome screen logo */
.acw-welcome-logo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto;
}

/* Override avatar background when showing logo */
.acw-msg.bot .acw-msg-avatar:has(.acw-msg-logo) {
    background: #fff;
    border: 1.5px solid var(--acw-border);
}
.acw-avatar:has(.acw-avatar-logo) {
    background: #fff;
}
