/* =====================================================
   Loviya AI Live Chat – WhatsApp-inspired Widget
   ===================================================== */

:root {
    --loviya-accent: #25D366;
    --loviya-accent-dark: #1da851;
    --loviya-bg: #ffffff;
    --loviya-bg-secondary: #f0f2f5;
    --loviya-text: #111b21;
    --loviya-text-secondary: #667781;
    --loviya-bubble-in: #ffffff;
    --loviya-bubble-out: #d9fdd3;
    --loviya-header: #008069;
    --loviya-border: #e9edef;
    --loviya-shadow: 0 8px 30px rgba(0,0,0,.18);
    --loviya-radius: 12px;
    --loviya-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#loviya-root.dark {
    --loviya-bg: #0b141a;
    --loviya-bg-secondary: #111b21;
    --loviya-text: #e9edef;
    --loviya-text-secondary: #8696a0;
    --loviya-bubble-in: #202c33;
    --loviya-bubble-out: #005c4b;
    --loviya-header: #1f2c34;
    --loviya-border: #222d34;
    --loviya-shadow: 0 8px 30px rgba(0,0,0,.45);
}

#loviya-root {
    font-family: var(--loviya-font);
    z-index: 999999;
    position: relative;
    box-sizing: border-box;
}

#loviya-root *, #loviya-root *::before, #loviya-root *::after {
    box-sizing: border-box;
}

/* ---------- FAB ---------- */
.loviya-fab {
    position: fixed;
    bottom: 22px;
    right: 22px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--loviya-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
    transition: transform .2s ease, box-shadow .2s ease;
    z-index: 999999;
    overflow: hidden;
    padding: 0;
}

.loviya-fab:hover {
    transform: scale(1.07);
    box-shadow: 0 8px 28px rgba(37, 211, 102, 0.55);
}

.loviya-fab-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.loviya-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ea4335;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ---------- Window ---------- */
.loviya-window {
    position: fixed;
    bottom: 96px;
    right: 22px;
    width: 380px;
    max-width: calc(100vw - 24px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: var(--loviya-bg);
    border-radius: 16px;
    box-shadow: var(--loviya-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    animation: loviyaIn .22s ease;
}

@keyframes loviyaIn {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Header ---------- */
.loviya-header {
    background: var(--loviya-header);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.loviya-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.loviya-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}

.loviya-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.loviya-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    background: #25D366;
    border: 2px solid var(--loviya-header);
    border-radius: 50%;
}

.loviya-header-info {
    min-width: 0;
}

.loviya-header-name {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loviya-header-status {
    font-size: 12.5px;
    opacity: .9;
}

.loviya-header-actions {
    display: flex;
    gap: 4px;
}

.loviya-icon-btn {
    background: transparent;
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .9;
    transition: background .15s;
}

.loviya-icon-btn:hover {
    background: rgba(255,255,255,.15);
    opacity: 1;
}

/* ---------- Messages ---------- */
.loviya-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    background: var(--loviya-bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

.loviya-msg {
    max-width: 82%;
    padding: 7px 11px 6px;
    border-radius: 10px;
    font-size: 14.5px;
    line-height: 1.45;
    position: relative;
    word-wrap: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 1px rgba(0,0,0,.06);
}

.loviya-msg.bot {
    background: var(--loviya-bubble-in);
    color: var(--loviya-text);
    align-self: flex-start;
    border-top-left-radius: 2px;
}

.loviya-msg.visitor {
    background: var(--loviya-bubble-out);
    color: var(--loviya-text);
    align-self: flex-end;
    border-top-right-radius: 2px;
}

.loviya-msg.admin {
    background: #c4e0f9;
    color: #111;
    align-self: flex-end;
    border-top-right-radius: 2px;
}

#loviya-root.dark .loviya-msg.admin {
    background: #1a3a5c;
    color: #e9edef;
}

.loviya-msg-time {
    font-size: 10.5px;
    color: var(--loviya-text-secondary);
    text-align: right;
    margin-top: 3px;
    line-height: 1;
}

/* ---------- Typing ---------- */
.loviya-typing {
    padding: 4px 14px 8px;
    background: var(--loviya-bg-secondary);
}

.loviya-typing-bubble {
    display: inline-flex;
    gap: 4px;
    background: var(--loviya-bubble-in);
    padding: 10px 14px;
    border-radius: 10px;
    border-top-left-radius: 2px;
}

.loviya-typing-bubble span {
    width: 7px;
    height: 7px;
    background: var(--loviya-text-secondary);
    border-radius: 50%;
    animation: loviyaDot 1.3s infinite ease-in-out;
}

.loviya-typing-bubble span:nth-child(2) { animation-delay: .18s; }
.loviya-typing-bubble span:nth-child(3) { animation-delay: .36s; }

@keyframes loviyaDot {
    0%, 80%, 100% { transform: translateY(0); opacity: .4; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Composer ---------- */
.loviya-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: var(--loviya-bg);
    border-top: 1px solid var(--loviya-border);
    flex-shrink: 0;
}

#loviya-input {
    flex: 1;
    border: none;
    background: var(--loviya-bg-secondary);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 15px;
    color: var(--loviya-text);
    resize: none;
    max-height: 110px;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
}

#loviya-input::placeholder {
    color: var(--loviya-text-secondary);
}

.loviya-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--loviya-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .15s;
}

.loviya-send-btn:hover {
    background: var(--loviya-accent-dark);
    transform: scale(1.05);
}

.loviya-send-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

/* ---------- Mobile – keep as popup (NOT full screen) ---------- */
/* AdSense-friendly: never cover the whole screen or main content */
@media (max-width: 480px) {
    .loviya-window {
        bottom: 80px;
        right: 10px;
        left: auto;
        width: calc(100vw - 20px);
        max-width: 360px;
        height: 70vh;
        max-height: 520px;
        border-radius: 14px;
    }
    .loviya-fab {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}

/* Scrollbar */
.loviya-messages::-webkit-scrollbar {
    width: 5px;
}
.loviya-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.15);
    border-radius: 4px;
}
#loviya-root.dark .loviya-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.15);
}

/* ---------- Message meta + WhatsApp-style ticks ---------- */
.loviya-msg-body {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.loviya-msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
    line-height: 1;
}

.loviya-msg-time {
    font-size: 10.5px;
    color: var(--loviya-text-secondary);
}

.loviya-ticks {
    font-size: 12px;
    line-height: 1;
    font-weight: 500;
    letter-spacing: -1px;
}

.loviya-ticks-sent {
    color: var(--loviya-text-secondary);
    opacity: 0.7;
}

.loviya-ticks-read {
    color: #53bdeb; /* WhatsApp blue ticks */
}

#loviya-root.dark .loviya-ticks-read {
    color: #53bdeb;
}

.loviya-msg.visitor .loviya-msg-meta {
    /* already right-aligned via flex-end */
}
