/* ============================================================
   AnimaChat Pro — Public Widget CSS
   Anima Infotech © 2024
   ============================================================ */

:root {
    --animachat-primary:      #6C63FF;
    --animachat-primary-dark: #574FDD;
    --animachat-header-bg:    #6C63FF;
    --animachat-bg:           #FFFFFF;
    --animachat-text:         #1E1B4B;
    --animachat-muted:        #6B7280;
    --animachat-bot-bubble-bg:   #FFFFFF;
    --animachat-bot-bubble-text: #1E1B4B;
    --animachat-visitor-bubble-bg:   #E8E6FF;
    --animachat-visitor-bubble-text: #1E1B4B;
    --animachat-white:        #FFFFFF;
    --animachat-border:       rgba(108,99,255,0.12);
    --animachat-radius:       16px;
    --animachat-shadow:       0 16px 64px rgba(30,27,75,0.18);
    --animachat-font:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --animachat-w:            380px;
    --animachat-h:            560px;
    --animachat-z:            9999;
}

/* ── Container ─────────────────────────────────────────────── */
#animachat-container {
    position: fixed;
    z-index: var(--animachat-z);
    font-family: var(--animachat-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--animachat-text);
}

#animachat-container.animachat-bottom-right { bottom: 24px; right: 24px; }
#animachat-container.animachat-bottom-left  { bottom: 24px; left:  24px; }
#animachat-container.animachat-top-right    { top:    24px; right: 24px; }
#animachat-container.animachat-top-left     { top:    24px; left:  24px; }

/* ── Launcher ──────────────────────────────────────────────── */
#animachat-launcher {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--animachat-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(108,99,255,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
    outline: none;
}

#animachat-launcher:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 12px 32px rgba(108,99,255,0.5);
}

#animachat-launcher:active { transform: scale(0.95); }

#animachat-launcher i {
    position: absolute;
    transition: all 0.3s ease;
}

.animachat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #F43F5E;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: animachatPop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes animachatPop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ── Chat Window ───────────────────────────────────────────── */
#animachat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: var(--animachat-w);
    height: var(--animachat-h);
    background: var(--animachat-bg);
    border-radius: var(--animachat-radius);
    box-shadow: var(--animachat-shadow);
    border: 1px solid var(--animachat-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: animachatWindowOpen 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.animachat-bottom-left  #animachat-window { right: auto; left: 0; transform-origin: bottom left; }
.animachat-top-right    #animachat-window { bottom: auto; top: 76px; transform-origin: top right; }
.animachat-top-left     #animachat-window { bottom: auto; top: 76px; right: auto; left: 0; transform-origin: top left; }

@keyframes animachatWindowOpen {
    from { opacity: 0; transform: scale(0.8) translateY(10px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Header ────────────────────────────────────────────────── */
#animachat-header {
    background: var(--animachat-header-bg);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

#animachat-header::before {
    content: '';
    position: absolute;
    top: -30px; right: -30px;
    width: 100px; height: 100px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}

#animachat-header::after {
    content: '';
    position: absolute;
    bottom: -40px; left: -20px;
    width: 120px; height: 120px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}

.animachat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.animachat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    object-fit: cover;
    background: rgba(255,255,255,0.2);
}

.animachat-bot-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.animachat-status {
    font-size: 12px;
    color: rgba(255,255,255,0.85);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.animachat-dot {
    width: 7px;
    height: 7px;
    background: #4ADE80;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
    animation: animachatPulse 2s infinite;
}

@keyframes animachatPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(74,222,128,0.3); }
    50%       { box-shadow: 0 0 0 5px rgba(74,222,128,0.1); }
}

.animachat-header-actions {
    display: flex;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.animachat-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.animachat-action-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

/* ── Messages Area ─────────────────────────────────────────── */
#animachat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--animachat-bg);
    scroll-behavior: smooth;
}

#animachat-messages::-webkit-scrollbar { width: 4px; }
#animachat-messages::-webkit-scrollbar-track { background: transparent; }
#animachat-messages::-webkit-scrollbar-thumb { background: var(--animachat-border); border-radius: 4px; }

/* ── Message Bubbles ───────────────────────────────────────── */
.animachat-msg {
    display: flex;
    gap: 8px;
    animation: animachatFadeSlide 0.25s ease;
    max-width: 85%;
}

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

.animachat-msg.visitor {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.animachat-msg.bot,
.animachat-msg.agent,
.animachat-msg.system {
    align-self: flex-start;
}

.animachat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    margin-top: auto;
}

.animachat-msg.bot    .animachat-msg-avatar { background: var(--animachat-primary); color: #fff; }
.animachat-msg.agent  .animachat-msg-avatar { background: var(--animachat-secondary); color: #fff; }
.animachat-msg.visitor .animachat-msg-avatar { background: #E5E7EB; color: var(--animachat-text); }

.animachat-msg-body { display: flex; flex-direction: column; gap: 4px; }

.animachat-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}

.animachat-msg.bot .animachat-msg-bubble,
.animachat-msg.agent .animachat-msg-bubble {
    background: var(--animachat-bot-bubble-bg);
    border: 1px solid var(--animachat-border);
    border-bottom-left-radius: 4px;
    color: var(--animachat-bot-bubble-text);
    box-shadow: 0 2px 8px rgba(108,99,255,0.05);
}

.animachat-msg.visitor .animachat-msg-bubble {
    background: var(--animachat-visitor-bubble-bg);
    color: var(--animachat-visitor-bubble-text);
    border-bottom-right-radius: 4px;
}

.animachat-msg.system .animachat-msg-bubble {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
    border-radius: 8px;
    font-size: 12px;
    padding: 7px 12px;
}

/* Markdown styles inside bubbles */
.animachat-msg-bubble p  { margin: 0 0 6px; }
.animachat-msg-bubble p:last-child { margin-bottom: 0; }
.animachat-msg-bubble ul,
.animachat-msg-bubble ol { padding-left: 18px; margin: 6px 0; }
.animachat-msg-bubble code {
    background: rgba(108,99,255,0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Fira Code', monospace;
}
.animachat-msg.visitor .animachat-msg-bubble code { background: rgba(255,255,255,0.2); }
.animachat-msg-bubble pre {
    background: rgba(0,0,0,0.06);
    border-radius: 8px;
    padding: 10px;
    overflow-x: auto;
    font-size: 12px;
}
.animachat-msg-bubble a { color: var(--animachat-primary); }
.animachat-msg.visitor .animachat-msg-bubble a { color: rgba(255,255,255,0.85); }

.animachat-msg-time {
    font-size: 10px;
    color: var(--animachat-muted);
    padding: 0 4px;
}

.animachat-msg.visitor .animachat-msg-time { text-align: right; }

/* File / Image message */
.animachat-msg-image {
    max-width: 100%;
    border-radius: 10px;
    display: block;
    cursor: pointer;
}

.animachat-msg-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--animachat-border);
    background: #fff;
    font-size: 12px;
    text-decoration: none;
    color: var(--animachat-text);
}

/* ── Typing Indicator ──────────────────────────────────────── */
#animachat-typing {
    padding: 4px 16px 8px;
}

.animachat-typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--animachat-border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 10px 14px;
    box-shadow: 0 2px 8px rgba(108,99,255,0.05);
}

.animachat-typing-bubble span {
    width: 7px;
    height: 7px;
    background: var(--animachat-primary);
    border-radius: 50%;
    opacity: 0.4;
    animation: animachatTyping 1.2s ease infinite;
}

.animachat-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.animachat-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes animachatTyping {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50%       { opacity: 1;   transform: translateY(-4px); }
}

/* ── Quick Replies ─────────────────────────────────────────── */
#animachat-quick-replies {
    padding: 6px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.animachat-qr-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--animachat-primary);
    background: transparent;
    color: var(--animachat-primary);
    font-family: var(--animachat-font);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.animachat-qr-btn:hover {
    background: var(--animachat-primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108,99,255,0.25);
}

/* ── Input Area ────────────────────────────────────────────── */
#animachat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--animachat-border);
    background: #fff;
    flex-shrink: 0;
}

#animachat-input {
    flex: 1;
    border: 1.5px solid var(--animachat-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-family: var(--animachat-font);
    font-size: 13.5px;
    resize: none;
    max-height: 120px;
    min-height: 42px;
    overflow-y: auto;
    background: #faf9ff;
    color: var(--animachat-text);
    outline: none;
    transition: all 0.2s;
    line-height: 1.4;
}

#animachat-input:focus {
    border-color: var(--animachat-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(108,99,255,0.08);
}

#animachat-input::placeholder { color: #C4C2D6; }

#animachat-btn-attach {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1.5px solid var(--animachat-border);
    background: #fff;
    color: var(--animachat-muted);
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#animachat-btn-attach:hover {
    border-color: var(--animachat-primary);
    color: var(--animachat-primary);
    background: #f0eeff;
}

#animachat-send {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--animachat-primary);
    border: none;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 4px 12px rgba(108,99,255,0.3);
}

#animachat-send:hover {
    transform: scale(1.1) translateY(-1px);
    box-shadow: 0 6px 18px rgba(108,99,255,0.45);
}

#animachat-send:active { transform: scale(0.95); }
#animachat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Rating ────────────────────────────────────────────────── */
#animachat-rating {
    padding: 10px 14px;
    border-top: 1px solid var(--animachat-border);
    text-align: center;
    background: #faf9ff;
    flex-shrink: 0;
}

#animachat-rating p {
    font-size: 12px;
    color: var(--animachat-muted);
    margin: 0 0 6px;
}

.animachat-star-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: #D1D5DB;
    cursor: pointer;
    padding: 0 2px;
    transition: all 0.15s;
}

.animachat-star-btn:hover,
.animachat-star-btn.active {
    color: #F59E0B;
    transform: scale(1.2);
}

/* ── Footer ────────────────────────────────────────────────── */
#animachat-footer {
    padding: 7px 14px;
    text-align: center;
    font-size: 11px;
    color: var(--animachat-muted);
    background: #fff;
    border-top: 1px solid var(--animachat-border);
    flex-shrink: 0;
}

#animachat-footer a {
    color: var(--animachat-primary);
    text-decoration: none;
    font-weight: 600;
}

#animachat-footer a:hover { text-decoration: underline; }

/* ── GDPR Banner ───────────────────────────────────────────── */
#animachat-gdpr-banner {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1E1B4B;
    color: #fff;
    padding: 16px;
    z-index: 10;
    border-radius: 0 0 var(--animachat-radius) var(--animachat-radius);
    animation: animachatFadeSlide 0.3s ease;
}

#animachat-gdpr-banner p { font-size: 12px; margin: 0 0 10px; opacity: 0.85; line-height: 1.5; }

.animachat-gdpr-actions { display: flex; gap: 8px; }

.animachat-gdpr-accept,
.animachat-gdpr-decline {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: none;
    font-family: var(--animachat-font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.animachat-gdpr-accept  { background: var(--animachat-primary); color: #fff; }
.animachat-gdpr-decline { background: rgba(255,255,255,0.15); color: #fff; }
.animachat-gdpr-accept:hover,
.animachat-gdpr-decline:hover { opacity: 0.85; }

/* ── Inline Widget ─────────────────────────────────────────── */
.animachat-inline-wrapper { position: relative; border-radius: var(--animachat-radius); overflow: hidden; }

.animachat-inline {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--animachat-border);
    border-radius: var(--animachat-radius);
    box-shadow: var(--animachat-shadow);
    overflow: hidden;
}

.animachat-inline-title {
    background: var(--animachat-primary);
    color: #fff;
    padding: 14px 18px;
    font-weight: 700;
    font-size: 15px;
}

.animachat-inline-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #faf9ff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.animachat-inline-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--animachat-border);
    background: #fff;
}

.animachat-inline-input {
    flex: 1;
    border: 1.5px solid var(--animachat-border);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: var(--animachat-font);
    font-size: 13px;
    resize: none;
    outline: none;
}

.animachat-inline-input:focus { border-color: var(--animachat-primary); }

.animachat-inline-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--animachat-primary);
    border: none;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.animachat-inline-send:hover { background: var(--animachat-primary-dark); transform: scale(1.05); }

/* ── Mobile Responsive ─────────────────────────────────────── */
@media (max-width: 480px) {
    :root {
        --animachat-w: calc(100vw - 24px);
        --animachat-h: calc(100vh - 120px);
    }

    #animachat-container.animachat-bottom-right,
    #animachat-container.animachat-bottom-left {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }

    #animachat-window {
        bottom: 72px;
        right: 0;
        left: 0;
        width: 100%;
    }
}

/* ── Dark Mode ─────────────────────────────────────────────── */
/* Removed conflicting dark mode overrides to respect Appearance settings */

/* ── SweetAlert2 Responsive Fixes ──────────────────────────── */
.swal2-popup {
    border-radius: var(--animachat-radius) !important;
    font-family: var(--animachat-font) !important;
    max-width: 95vw !important;
}

.swal2-input, .swal2-select, .swal2-textarea {
    border-radius: 10px !important;
    border: 1.5px solid var(--animachat-border) !important;
    font-size: 14px !important;
}

@media (max-width: 480px) {
    .swal2-popup {
        width: 90% !important;
        padding: 1.25rem !important;
    }
    .swal2-title {
        font-size: 1.15rem !important;
    }
    .swal2-html-container {
        font-size: 13.5px !important;
    }
}
