/* ===== OnePersonDigital Chat Widget ===== */
#opd-chat-widget {
    --opd-primary: #282a36;
    --opd-primary-light: #3a3d4d;
    --opd-accent: #6c5ce7;
    --opd-bg: #ffffff;
    --opd-bg-secondary: #f8f9fc;
    --opd-text: #2d3436;
    --opd-text-muted: #636e72;
    --opd-border: #e9ecef;
    --opd-radius: 16px;
    --opd-shadow: 0 12px 48px rgba(0,0,0,0.15);
    --opd-font: 'Poppins', 'Segoe UI', system-ui, sans-serif;

    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--opd-font);
}

/* Dark mode support */
.dark #opd-chat-widget {
    --opd-bg: #1a1a2e;
    --opd-bg-secondary: #16213e;
    --opd-text: #e2e8f0;
    --opd-text-muted: #94a3b8;
    --opd-border: rgba(255,255,255,0.08);
    --opd-shadow: 0 12px 48px rgba(0,0,0,0.4);
}

/* ===== Toggle Button ===== */
.opd-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--opd-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(40,42,54,0.35);
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

.opd-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 32px rgba(40,42,54,0.45);
}

.opd-chat-toggle svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    transition: transform 0.3s ease;
}

.opd-chat-toggle .opd-icon-close { display: none; }
.opd-chat-toggle.active .opd-icon-chat { display: none; }
.opd-chat-toggle.active .opd-icon-close { display: block; }
.opd-chat-toggle.active { border-radius: 14px; width: 52px; height: 52px; }

/* Unread badge */
.opd-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.opd-unread-badge.show { display: flex; }

/* ===== Chat Window ===== */
.opd-chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-height: 560px;
    background: var(--opd-bg);
    border-radius: var(--opd-radius);
    box-shadow: var(--opd-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.5) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: bottom right;
}

.opd-chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ===== Chat Header ===== */
.opd-chat-header {
    background: var(--opd-primary);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.opd-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.opd-chat-avatar svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

.opd-chat-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.opd-chat-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.opd-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    animation: opdPulse 2s ease-in-out infinite;
}

@keyframes opdPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.opd-chat-header-status span {
    font-size: 12px;
    opacity: 0.85;
}

/* ===== Chat Body ===== */
.opd-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--opd-bg-secondary);
    min-height: 320px;
    max-height: 380px;
}

.opd-chat-body::-webkit-scrollbar { width: 4px; }
.opd-chat-body::-webkit-scrollbar-track { background: transparent; }
.opd-chat-body::-webkit-scrollbar-thumb { background: var(--opd-border); border-radius: 4px; }

/* ===== Messages ===== */
.opd-msg {
    display: flex;
    gap: 8px;
    animation: opdMsgIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

.opd-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--opd-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.opd-msg-avatar svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

.opd-msg-user .opd-msg-avatar {
    background: var(--opd-accent);
}

.opd-msg-bubble {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-wrap: break-word;
}

.opd-msg-bot .opd-msg-bubble {
    background: var(--opd-bg);
    color: var(--opd-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.dark .opd-msg-bot .opd-msg-bubble {
    background: rgba(255,255,255,0.06);
}

.opd-msg-user .opd-msg-bubble {
    background: var(--opd-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.opd-msg-time {
    font-size: 10px;
    color: var(--opd-text-muted);
    margin-top: 4px;
    opacity: 0.7;
}

.opd-msg-user .opd-msg-time {
    text-align: right;
    color: rgba(255,255,255,0.6);
}

/* ===== Typing Indicator ===== */
.opd-typing {
    display: none;
    align-self: flex-start;
    gap: 8px;
    align-items: center;
}

.opd-typing.active { display: flex; }

.opd-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--opd-bg);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.dark .opd-typing-dots { background: rgba(255,255,255,0.06); }

.opd-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--opd-text-muted);
    animation: opdTyping 1.4s infinite ease-in-out;
}

.opd-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.opd-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes opdTyping {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== Quick Replies ===== */
.opd-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.opd-quick-btn {
    padding: 8px 16px;
    border: 1px solid var(--opd-border);
    border-radius: 20px;
    background: var(--opd-bg);
    color: var(--opd-text);
    font-size: 12.5px;
    font-family: var(--opd-font);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.opd-quick-btn:hover {
    background: var(--opd-primary);
    color: #fff;
    border-color: var(--opd-primary);
}

/* ===== Chat Footer ===== */
.opd-chat-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--opd-border);
    display: flex;
    gap: 10px;
    background: var(--opd-bg);
    flex-shrink: 0;
}

.opd-chat-input {
    flex: 1;
    border: 1px solid var(--opd-border);
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 13.5px;
    font-family: var(--opd-font);
    background: var(--opd-bg-secondary);
    color: var(--opd-text);
    outline: none;
    transition: border-color 0.2s;
}

.opd-chat-input::placeholder { color: var(--opd-text-muted); }
.opd-chat-input:focus { border-color: var(--opd-primary); }

.opd-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--opd-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.opd-chat-send:hover { background: var(--opd-primary-light); transform: scale(1.05); }

.opd-chat-send svg { width: 18px; height: 18px; fill: #fff; }

.opd-powered {
    text-align: center;
    padding: 8px;
    font-size: 10px;
    color: var(--opd-text-muted);
    opacity: 0.6;
    background: var(--opd-bg);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    #opd-chat-widget { bottom: 12px; right: 12px; left: 12px; }
    .opd-chat-window {
        width: auto;
        left: 0;
        right: 0;
        bottom: 68px;
        max-height: calc(100vh - 120px);
        border-radius: 14px;
    }
}
