/* ═══════════════════════════════════════════════════════════════
   Alina Balloon Chat Widget
   Warm, elegant style matching alinaballoon.com branding
   ═══════════════════════════════════════════════════════════════ */

:root {
    --ac-bg:       #FAFAF8;
    --ac-surface:  #FFFFFF;
    --ac-border:   #E8E2DB;
    --ac-border2:  #D4CCC2;
    --ac-text:     #1A1A1A;
    --ac-muted:    #6B6B6B;
    --ac-accent:   #C9A96E;
    --ac-accent-t: #8B6914;
    --ac-white:    #FFFFFF;
    --ac-ease:     cubic-bezier(0.4, 0, 0.2, 1);
    --ac-font:     'Inter', system-ui, -apple-system, sans-serif;
    --ac-font-h:   'Cormorant Garamond', Georgia, serif;
    --ac-shadow:   0 8px 30px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
}

/* ── Toggle Button ─────────────────────────────────────────── */
.ac-toggle {
    position: fixed; bottom: 24px; right: 24px;
    width: 56px; height: 56px;
    background: var(--ac-accent); border: none; border-radius: 50%;
    cursor: pointer; z-index: 99998; padding: 0;
    box-shadow: 0 4px 16px rgba(201,169,110,0.35);
    transition: transform 0.2s var(--ac-ease), box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
    display: flex; align-items: center; justify-content: center;
}
.ac-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(201,169,110,0.45); }
.ac-toggle.hidden { opacity: 0; pointer-events: none; }
.ac-toggle svg { width: 26px; height: 26px; fill: #fff; }
.ac-toggle .ac-close-icon { display: none; }
.ac-toggle.open .ac-chat-icon { display: none; }
.ac-toggle.open .ac-close-icon { display: block; }

/* ── Badge ─────────────────────────────────────────────────── */
.ac-badge { position: absolute; top: -2px; right: -2px; width: 18px; height: 18px; background: #EF4444; border-radius: 50%; font-size: 10px; font-weight: 700; color: #fff; display: flex; align-items: center; justify-content: center; border: 2px solid var(--ac-bg); }

/* ── Chat Window ───────────────────────────────────────────── */
.ac-window {
    position: fixed; bottom: 92px; right: 24px;
    width: 380px; height: 540px;
    background: var(--ac-bg);
    border: 1px solid var(--ac-border);
    border-radius: 16px;
    box-shadow: var(--ac-shadow);
    z-index: 99999;
    display: flex; flex-direction: column; overflow: hidden;
    opacity: 0; pointer-events: none; transform: translateY(12px) scale(0.96);
    transition: opacity 0.3s var(--ac-ease), transform 0.3s var(--ac-ease);
    font-family: var(--ac-font); font-size: 14px; line-height: 1.6; color: var(--ac-text);
}
.ac-window.open { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }

/* ── Header ────────────────────────────────────────────────── */
.ac-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    background: var(--ac-surface);
    border-bottom: 1px solid var(--ac-border);
    flex-shrink: 0;
}
.ac-header-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--ac-accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.ac-header-info { flex: 1; }
.ac-header-title { font-weight: 600; font-size: 14px; color: var(--ac-text); }
.ac-header-status { font-size: 11px; color: var(--ac-muted); }
.ac-header-status::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #22C55E; margin-right: 5px; vertical-align: middle; }
.ac-header-close { background: none; border: none; cursor: pointer; padding: 6px; color: var(--ac-muted); display: flex; }
.ac-header-close:hover { color: var(--ac-text); }
.ac-header-close svg { width: 18px; height: 18px; }

/* ── Messages ──────────────────────────────────────────────── */
.ac-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
    scroll-behavior: smooth;
}
.ac-messages::-webkit-scrollbar { width: 3px; }
.ac-messages::-webkit-scrollbar-thumb { background: var(--ac-border2); border-radius: 3px; }

.ac-msg { display: flex; gap: 8px; max-width: 85%; animation: acFadeIn 0.3s var(--ac-ease); }
@keyframes acFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.ac-msg-bot { align-self: flex-start; }
.ac-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.ac-msg-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0; margin-top: 2px;
}
.ac-msg-bot .ac-msg-avatar { background: var(--ac-accent); color: #fff; }
.ac-msg-user .ac-msg-avatar { background: var(--ac-border); color: var(--ac-muted); font-size: 11px; font-weight: 600; }

.ac-msg-bubble { padding: 10px 14px; border-radius: 14px; word-wrap: break-word; font-size: 14px; line-height: 1.6; }
.ac-msg-bot .ac-msg-bubble { background: var(--ac-surface); border: 1px solid var(--ac-border); border-bottom-left-radius: 4px; }
.ac-msg-user .ac-msg-bubble { background: var(--ac-accent); color: #fff; border-bottom-right-radius: 4px; }

.ac-msg-bubble p { margin: 0; }
.ac-msg-bubble p + p { margin-top: 6px; }

/* ── Typing ────────────────────────────────────────────────── */
.ac-typing { display: none; align-self: flex-start; align-items: center; gap: 8px; max-width: 85%; animation: acFadeIn 0.3s; }
.ac-typing.visible { display: flex; }
.ac-typing-dots { display: flex; gap: 5px; padding: 12px 16px; background: var(--ac-surface); border: 1px solid var(--ac-border); border-radius: 14px; border-bottom-left-radius: 4px; }
.ac-typing-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ac-accent); animation: acPulse 1.4s ease-in-out infinite; }
.ac-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ac-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes acPulse {
    0%, 100% { transform: scale(0.6); opacity: 0.3; }
    50% { transform: scale(1); opacity: 1; }
}

/* ── Checking availability animation ──────────────────────── */
.ac-checking { display: inline-flex; align-items: center; gap: 6px; }
.ac-checking-spinner { width: 14px; height: 14px; border: 2px solid var(--ac-border); border-top-color: var(--ac-accent); border-radius: 50%; animation: acSpin 0.8s linear infinite; }
@keyframes acSpin { to { transform: rotate(360deg); } }

/* ── Quick Replies ─────────────────────────────────────────── */
.ac-quick-replies { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; flex-shrink: 0; }
.ac-quick-btn {
    padding: 7px 14px; border: 1px solid var(--ac-border2); border-radius: 20px;
    background: var(--ac-surface); color: var(--ac-text);
    font-family: var(--ac-font); font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.ac-quick-btn:hover { background: var(--ac-accent); color: #fff; border-color: var(--ac-accent); }

/* ── Input Area ────────────────────────────────────────────── */
.ac-input-area {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 12px 16px; border-top: 1px solid var(--ac-border);
    background: var(--ac-surface); flex-shrink: 0;
}
.ac-input {
    flex: 1; min-height: 38px; max-height: 120px;
    padding: 8px 14px; border: 1px solid var(--ac-border); border-radius: 20px;
    background: var(--ac-bg); color: var(--ac-text);
    font-family: var(--ac-font); font-size: 14px; line-height: 1.4;
    resize: none; outline: none; overflow-y: hidden;
    transition: border-color 0.2s;
}
.ac-input:focus { border-color: var(--ac-accent); }
.ac-input::placeholder { color: #999; }

.ac-attach-btn {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; flex-shrink: 0; cursor: pointer;
    color: var(--ac-muted); transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.ac-attach-btn:hover { color: var(--ac-accent); }

.ac-send-btn {
    width: 38px; height: 38px; border: none; border-radius: 50%;
    background: var(--ac-accent); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity 0.2s;
}
.ac-send-btn:hover { opacity: 0.85; }
.ac-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.ac-send-btn svg { width: 16px; height: 16px; fill: #fff; }

/* ── Disclaimer ────────────────────────────────────────────── */
.ac-disclaimer { padding: 4px 16px 6px; font-size: 10px; color: #999; text-align: center; flex-shrink: 0; }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Hide floating toggle on mobile — chat is in bottom bar */
    .ac-toggle { display: none; }
    .ac-toggle.open { display: flex; bottom: 16px; right: 16px; width: 52px; height: 52px; }

    /* Fullscreen chat */
    .ac-window {
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        width: 100%; height: 100dvh;
        border-radius: 0; border: none;
    }
    /* When virtual keyboard is open */
    .ac-window.kb-open {
        bottom: auto;
    }

    /* Prevent iOS zoom on input focus */
    .ac-input { font-size: 16px; }
    .ac-input-area { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}
@media print { .ac-toggle, .ac-window { display: none !important; } }
