/* ============================================================
   PT AERING – Live Chat Widget Styles
   ============================================================ */

/* ── CSS Variables (Light Mode) ────────────────────────────── */
:root {
    --chat-primary: #1a3c5e;
    --chat-primary-dark: #0f2640;
    --chat-primary-light: #2563a8;
    --chat-accent: #4f9cf9;
    --chat-bg: #ffffff;
    --chat-surface: #f4f6fa;
    --chat-border: rgba(0, 0, 0, .09);
    --chat-text: #1a1d23;
    --chat-text-muted: #6b7280;
    --chat-bubble-agent: #ffffff;
    --chat-bubble-visitor: #1a3c5e;
    --chat-bubble-v-text: #ffffff;
    --chat-shadow: 0 20px 60px rgba(0, 0, 0, .18), 0 4px 16px rgba(0, 0, 0, .10);
    --chat-btn-shadow: 0 6px 24px rgba(26, 60, 94, .40);
    --chat-radius: 18px;
    --chat-w: 360px;
    --chat-h: 520px;
    --chat-z: 2147483640;
    --chat-header-h: 130px;
    --chat-transition: cubic-bezier(.34, 1.56, .64, 1);
}

/* ── Dark Mode ──────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    :root {
        --chat-bg: #1c2333;
        --chat-surface: #242b3d;
        --chat-border: rgba(255, 255, 255, .08);
        --chat-text: #e8eaf0;
        --chat-text-muted: #8d95a8;
        --chat-bubble-agent: #2a3347;
        --chat-bubble-visitor: #2563a8;
        --chat-shadow: 0 20px 60px rgba(0, 0, 0, .50), 0 4px 16px rgba(0, 0, 0, .30);
    }
}

/* ── Widget Container ───────────────────────────────────────── */
#chat-widget-root {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: var(--chat-z) !important;
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    width: 60px;
    height: 60px;
    background: transparent !important;
}

/* ── Floating Speech Bubble Tooltip ──────────────────────────── */
#chat-bubble-tooltip {
    position: absolute;
    right: 74px;
    bottom: 6px;
    background: #ffffff;
    color: #0f172a;
    padding: 10px 14px 10px 18px;
    border-radius: 28px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    z-index: 989;
    pointer-events: auto;
    user-select: none;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
    animation: chat-bubble-pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@media (prefers-color-scheme: dark) {
    #chat-bubble-tooltip {
        background: #1e293b;
        color: #f8fafc;
        border-color: rgba(255, 255, 255, 0.12);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.30);
    }
}

#chat-bubble-tooltip:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22), 0 4px 12px rgba(0, 0, 0, 0.10);
}

#chat-bubble-tooltip.chat-bubble-hidden {
    opacity: 0 !important;
    transform: scale(0.85) translateX(15px) !important;
    pointer-events: none !important;
}

#chat-bubble-content {
    display: flex;
    align-items: center;
    max-width: 320px;
    overflow: hidden;
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

#chat-bubble-text {
    display: inline-block;
    white-space: nowrap;
    will-change: transform, opacity;
}

#chat-bubble-text.fade-out {
    opacity: 0 !important;
    transform: translateY(-6px) !important;
    transition: opacity 0.25s ease, transform 0.25s ease !important;
}

#chat-bubble-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    padding: 2px;
    margin-left: 2px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}

#chat-bubble-close:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

@keyframes chat-bubble-pop-in {
    0% {
        opacity: 0;
        transform: scale(0.8) translateX(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}

/* ── Floating Button ────────────────────────────────────────── */
#chat-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-light));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--chat-btn-shadow);
    transition: transform .3s var(--chat-transition), box-shadow .3s ease;
    position: relative;
    z-index: 30;
    outline: none;
}

#chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 32px rgba(26, 60, 94, .55);
}

#chat-fab:active {
    transform: scale(.96);
}

#chat-fab .icon-chat,
#chat-fab .icon-close {
    color: #fff;
    font-size: 24px;
    line-height: 1;
    transition: transform .25s ease, opacity .2s ease;
    pointer-events: none;
}

#chat-fab .icon-close {
    font-size: 22px;
    font-weight: 900;
}

/* Pulse ring */
#chat-fab::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 3px solid var(--chat-primary-light);
    opacity: 0;
    animation: chat-pulse 2.5s ease-out infinite;
}

@keyframes chat-pulse {
    0% {
        opacity: .7;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.45);
    }
}

/* Unread badge on FAB */
#chat-fab-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    display: none;
}

/* ── Panel ──────────────────────────────────────────────────── */
#chat-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    z-index: 20;
    width: var(--chat-w);
    max-height: var(--chat-h);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(.7) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform .35s var(--chat-transition), opacity .25s ease;
    border: 1px solid var(--chat-border);
}

#chat-panel.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Panel Header ───────────────────────────────────────────── */
#chat-header {
    background: linear-gradient(135deg, var(--chat-primary-dark) 0%, var(--chat-primary) 60%, var(--chat-primary-light) 100%);
    padding: 16px 20px 20px !important;
    color: #fff;
    position: relative;
    overflow: hidden;
    flex-shrink: 0 !important;
    min-height: 120px !important;
    box-sizing: border-box !important;
}

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

#chat-header::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, .05);
    border-radius: 50%;
}

.chat-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
    position: relative;
    z-index: 1;
    width: 100%;
}

.chat-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.chat-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .15);
    backdrop-filter: blur(4px);
    padding: 4px;
    object-fit: contain;
    flex-shrink: 0;
}

.chat-company-name {
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: .3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 500;
    opacity: .9;
    margin-left: 2px;
}

.chat-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
    z-index: 2;
}

.chat-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 7px;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
    outline: none;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.45);
}

.chat-header-icon-btn {
    padding: 5px 7px;
    font-size: 12.5px;
}

#chat-new-btn {
    display: none; /* Shown in active conversation */
}

/* Hide expand button on welcome screen (before conversation starts) */
#chat-header:not(.chat-header-compact) #chat-expand-btn {
    display: none;
}

/* Expanded modal - ONLY for active conversation screen */
#chat-panel.chat-panel-expanded:has(#chat-header.chat-header-compact) {
    width: min(800px, calc(100vw - 48px)) !important;
    max-height: min(780px, calc(100vh - 200px)) !important;
    height: min(780px, calc(100vh - 200px)) !important;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s cubic-bezier(0.16, 1, 0.3, 1), max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* First menu / Welcome screen (filling name & email) is always compact */
#chat-panel:has(#chat-header:not(.chat-header-compact)),
#chat-panel:has(#chat-welcome-screen:not([style*="display: none"])) {
    width: min(400px, calc(100vw - 32px)) !important;
    max-height: min(650px, calc(100vh - 120px)) !important;
    height: auto !important;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: status-blink 2s ease-in-out infinite;
    flex-shrink: 0;
}

.status-dot.offline {
    background: #6b7280;
    animation: none;
}

@keyframes status-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .4;
    }
}

.chat-greeting {
    position: relative;
    z-index: 1;
}

.chat-greeting h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 4px;
    line-height: 1.3;
}

.chat-greeting p {
    font-size: 12.5px;
    opacity: .82;
    margin: 0;
}

/* Compact header when chat starts */
#chat-header.chat-header-compact {
    padding: 12px 16px !important;
    flex-shrink: 0 !important;
    min-height: 60px !important;
    height: 60px !important;
    max-height: 60px !important;
    box-sizing: border-box !important;
}

#chat-header.chat-header-compact .chat-header-top {
    margin-bottom: 0 !important;
}

#chat-header.chat-header-compact .chat-greeting {
    display: none !important;
}

#chat-header.chat-header-compact .chat-header-status {
    display: none !important;
}

#chat-header.chat-header-compact #chat-new-btn {
    display: inline-flex !important;
}

/* ── Welcome / Start Screen ─────────────────────────────────── */
#chat-welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: var(--chat-bg);
    overflow-y: auto;
    box-sizing: border-box;
}

.chat-start-card {
    background: var(--chat-surface);
    border: 1px solid var(--chat-border);
    border-radius: 14px;
    padding: 16px;
    box-sizing: border-box;
}

/* ── Chat History Screen ────────────────────────────────────── */
#chat-history-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    overflow: hidden;
}

.chat-history-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--chat-surface);
    border-bottom: 1px solid var(--chat-border);
}

.chat-history-back-btn {
    background: none;
    border: none;
    color: var(--chat-primary-light);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.chat-history-back-btn:hover {
    background: rgba(14, 116, 144, 0.08);
}

.chat-history-heading {
    font-size: 13px;
    font-weight: 700;
    color: var(--chat-text);
}

.chat-history-new-action-btn {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-light));
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-history-new-action-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(14, 116, 144, 0.35);
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-history-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 15px;
    gap: 6px;
}

.chat-history-item {
    background: var(--chat-surface);
    border: 1px solid var(--chat-border);
    border-radius: 11px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chat-history-item:hover {
    border-color: var(--chat-primary-light);
    background: rgba(14, 116, 144, 0.05);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
}

.chat-history-item.is-active-conv {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.05);
}

.chat-history-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
}

.chat-history-item-date {
    color: var(--chat-text-muted);
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-history-badge {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 999px;
    letter-spacing: 0.03em;
}

.chat-history-badge.status-active {
    background: #dcfce7;
    color: #15803d;
}

.chat-history-badge.status-waiting {
    background: #fef9c3;
    color: #854d0e;
}

.chat-history-badge.status-closed {
    background: #f1f5f9;
    color: #64748b;
}

.chat-history-item-snippet {
    font-size: 12px;
    color: var(--chat-text);
    line-height: 1.38;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.chat-history-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10.5px;
    color: var(--chat-text-muted);
    padding-top: 4px;
    border-top: 1px dashed var(--chat-border);
}

.chat-history-empty {
    text-align: center;
    padding: 35px 15px;
    color: var(--chat-text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.chat-history-empty i {
    font-size: 32px;
    color: var(--chat-border);
}

.chat-start-card label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-text-muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 6px;
}

.chat-start-card input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--chat-border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    background: var(--chat-bg);
    color: var(--chat-text);
    outline: none;
    transition: border-color .2s;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.chat-start-card input:focus {
    border-color: var(--chat-primary-light);
    box-shadow: 0 0 0 3px rgba(79, 156, 249, .15);
}

#chat-email-suggestion {
    display: none;
    margin-top: -6px;
    margin-bottom: 12px;
    font-size: 12px;
    color: #0284c7;
    background: #f0f9ff;
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid #bae6fd;
    cursor: pointer;
    transition: background .15s;
}

#chat-email-suggestion:hover {
    background: #e0f2fe;
}

.chat-start-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-light));
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .2s, box-shadow .2s;
    box-shadow: 0 4px 16px rgba(26, 60, 94, .30);
}

.chat-start-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(26, 60, 94, .40);
}

.chat-start-btn:active {
    transform: translateY(0);
}

.chat-start-btn svg {
    width: 18px;
    height: 18px;
}

/* ── Conversation Screen ────────────────────────────────────── */
#chat-conv-screen {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
}

/* Messages area */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    min-height: 0;
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 2px;
}

/* Message bubbles */
.chat-msg {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 9px;
    max-width: 86%;
    animation: msg-in .25s ease;
    margin-bottom: 12px;
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.chat-msg.from-agent {
    align-self: flex-start;
    flex-direction: row;
}

.chat-msg.chat-msg-system {
    max-width: 100%;
    display: block;
}

.msg-avatar-col {
    flex-shrink: 0;
    margin-top: 1px;
}

.msg-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

.msg-avatar-img.customer-avatar {
    border: 2px solid rgba(255, 255, 255, 0.25);
    filter: grayscale(100%) contrast(1.1);
}

.msg-avatar-img.agent-avatar {
    border: 2px solid rgba(14, 165, 233, 0.45);
}

.msg-bubble-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.from-visitor .msg-bubble-wrap {
    align-items: flex-end;
}

.from-agent .msg-bubble-wrap {
    align-items: flex-start;
}

.msg-sender-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--chat-text-muted);
    margin-bottom: 3px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.from-visitor .msg-sender-name {
    justify-content: flex-end;
}

.agent-role-pill {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 1px 7px;
    border-radius: 10px;
    background: rgba(14, 116, 144, 0.12);
    color: #0e7490;
    border: 1px solid rgba(14, 116, 144, 0.28);
    display: inline-flex;
    align-items: center;
    line-height: 1.4;
}

.agent-role-pill.position-pill {
    background: rgba(59, 130, 246, 0.10);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.msg-bubble {
    padding: 9px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
    white-space: pre-wrap;
    max-width: 100%;
}

.from-visitor .msg-bubble {
    background: linear-gradient(135deg, var(--chat-bubble-visitor), var(--chat-primary-light));
    color: var(--chat-bubble-v-text);
    border-bottom-right-radius: 4px;
}

.from-agent .msg-bubble {
    background: var(--chat-bubble-agent);
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-bottom-left-radius: 4px;
}

.msg-meta {
    font-size: 10.5px;
    color: var(--chat-text-muted);
    margin-top: 3px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-read-icon {
    font-size: 11px;
    color: var(--chat-accent);
}

/* Date separator */
.chat-date-sep {
    text-align: center;
    font-size: 11px;
    color: var(--chat-text-muted);
    position: relative;
    margin: 6px 0;
}

.chat-date-sep::before,
.chat-date-sep::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--chat-border);
}

.chat-date-sep::before {
    left: 0;
}

.chat-date-sep::after {
    right: 0;
}

/* Typing indicator */
#chat-typing-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--chat-text-muted);
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-text-muted);
    animation: dot-bounce .9s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: .15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: .30s;
}

@keyframes dot-bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: .5;
    }

    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Input area */
#chat-input-area {
    padding: 12px 16px 14px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--chat-bg);
}

#chat-input {
    flex: 1;
    max-height: 100px;
    min-height: 40px;
    padding: 10px 14px;
    border: 1.5px solid var(--chat-border);
    border-radius: 20px;
    font-family: inherit;
    font-size: 13.5px;
    background: var(--chat-surface);
    color: var(--chat-text);
    resize: none;
    outline: none;
    overflow-y: auto;
    transition: border-color .2s;
    line-height: 1.45;
}

#chat-input:focus {
    border-color: var(--chat-primary-light);
    box-shadow: 0 0 0 3px rgba(79, 156, 249, .12);
    background: var(--chat-bg);
}

#chat-attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-surface);
    border: 1.5px solid var(--chat-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    flex-shrink: 0;
    color: var(--chat-text-muted);
    font-size: 18px;
    animation: attachBtnFadeIn .25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes attachBtnFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#chat-attach-btn:hover {
    background: rgba(14, 116, 144, 0.15);
    color: var(--chat-primary-light);
    border-color: var(--chat-primary-light);
}

#chat-attach-btn.has-file {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-color: #10b981;
}

.msg-attachment-wrap {
    margin-bottom: 6px;
}

.msg-attachment-wrap img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform .2s ease;
}

.msg-attachment-wrap img:hover {
    transform: scale(1.02);
}

#chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-light));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(26, 60, 94, .30);
}

#chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 16px rgba(26, 60, 94, .40);
}

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

#chat-send-btn svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

/* Closed conversation banner */
#chat-closed-banner {
    display: none;
    background: var(--chat-surface);
    border-top: 1px solid var(--chat-border);
    padding: 12px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--chat-text-muted);
}

/* Empty state in messages */
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--chat-text-muted);
    text-align: center;
    gap: 8px;
}

.chat-empty-state svg {
    width: 40px;
    height: 40px;
    opacity: .35;
}

/* ── Skeleton Loader ────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--chat-surface) 25%, var(--chat-border) 50%, var(--chat-surface) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s infinite;
    border-radius: 8px;
    height: 14px;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ── Responsive (mobile) ────────────────────────────────────── */
@media (max-width: 576px) {
    #chat-widget-root {
        bottom: 12px;
        right: 12px;
    }

    #chat-panel,
    #chat-panel.chat-panel-expanded {
        width: calc(100vw - 24px) !important;
        right: 0 !important;
        bottom: 68px !important;
        max-height: calc(100vh - 160px) !important;
        height: calc(100vh - 160px) !important;
        --chat-radius: 14px;
    }

    #chat-expand-btn {
        display: none !important;
    }

    #chat-bubble-tooltip {
        right: 68px;
        bottom: 4px;
        max-width: calc(100vw - 84px);
        font-size: 12px;
        padding: 8px 10px 8px 14px;
        gap: 6px;
        white-space: nowrap;
    }

    #chat-bubble-content {
        max-width: calc(100vw - 130px);
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
    }

    #chat-bubble-text {
        white-space: nowrap !important;
        display: inline-block !important;
        line-height: 1.4;
    }

    #chat-bubble-close {
        flex-shrink: 0;
        font-size: 16px;
        padding: 2px;
    }
}

/* ══════════════════════════════════════════════════════════════
   Modern Animated Confirmation Modal (PT AERING Chat)
   ══════════════════════════════════════════════════════════════ */
.chat-confirm-backdrop {
    position: absolute;
    inset: 0;
    z-index: 1000;
    background: rgba(8, 14, 26, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: inherit;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-confirm-backdrop.is-active {
    opacity: 1;
    pointer-events: auto;
}

.chat-confirm-backdrop.is-closing {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s cubic-bezier(0.4, 0, 1, 1);
}

.chat-confirm-dialog {
    background: linear-gradient(155deg, rgba(24, 34, 53, 0.98) 0%, rgba(13, 21, 39, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-top: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 20px;
    box-shadow: 
        0 24px 50px -12px rgba(0, 0, 0, 0.75),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 0 35px rgba(14, 116, 144, 0.22);
    padding: 26px 22px 22px;
    text-align: center;
    width: 100%;
    max-width: 310px;
    transform: scale(0.86) translateY(16px);
    opacity: 0;
    filter: blur(4px);
    transition: 
        transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

/* Subtle top reflective glow */
.chat-confirm-dialog::before {
    content: '';
    position: absolute;
    top: 0;
    left: 15%;
    right: 15%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.6), transparent);
}

.chat-confirm-backdrop.is-active .chat-confirm-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
    filter: blur(0);
}

.chat-confirm-backdrop.is-closing .chat-confirm-dialog {
    transform: scale(0.92) translateY(-12px);
    opacity: 0;
    filter: blur(2px);
    transition: 
        transform 0.22s cubic-bezier(0.4, 0, 1, 1),
        opacity 0.2s cubic-bezier(0.4, 0, 1, 1),
        filter 0.2s cubic-bezier(0.4, 0, 1, 1);
}

/* Icon & Pulsing Halo */
.chat-confirm-icon-wrap {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-confirm-icon-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.35) 0%, rgba(14, 165, 233, 0) 72%);
    animation: chatConfirmRingPulse 2.4s infinite ease-in-out;
}

@keyframes chatConfirmRingPulse {
    0%, 100% {
        transform: scale(0.92);
        opacity: 0.55;
    }
    50% {
        transform: scale(1.18);
        opacity: 0.95;
    }
}

.chat-confirm-icon-box {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(14, 116, 144, 0.35) 0%, rgba(2, 132, 199, 0.2) 100%);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #38bdf8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.25);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-confirm-backdrop.is-active .chat-confirm-icon-box {
    animation: chatConfirmIconPop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatConfirmIconPop {
    0% {
        transform: scale(0.6) rotate(-45deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.12) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

/* Typography */
.chat-confirm-title {
    font-size: 17px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}

.chat-confirm-desc {
    font-size: 12.5px;
    color: #94a3b8;
    line-height: 1.55;
    margin: 0 0 20px;
}

/* Actions */
.chat-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.chat-confirm-btn {
    border-radius: 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 14px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-confirm-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.45);
}

/* Cancel Button */
.chat-confirm-btn-cancel {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
}

.chat-confirm-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.chat-confirm-btn-cancel:active,
.chat-confirm-btn-cancel.is-clicked {
    transform: scale(0.92) translateY(1px) !important;
    background: rgba(255, 255, 255, 0.04);
}

/* Accept Button */
.chat-confirm-btn-accept {
    flex: 1.35;
    background: linear-gradient(135deg, #0e7490 0%, #0284c7 100%);
    border: 1px solid rgba(56, 189, 248, 0.45);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(14, 116, 144, 0.35);
    overflow: hidden;
}

.chat-confirm-btn-accept:hover {
    background: linear-gradient(135deg, #0891b2 0%, #0369a1 100%);
    box-shadow: 0 6px 22px rgba(14, 165, 233, 0.5);
    border-color: rgba(56, 189, 248, 0.65);
    transform: translateY(-1px);
}

.chat-confirm-btn-accept:active,
.chat-confirm-btn-accept.is-clicked {
    transform: scale(0.92) translateY(1px) !important;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.25);
}

.chat-confirm-btn-accept:hover .chat-confirm-btn-arrow {
    transform: translateX(3px);
}

.chat-confirm-btn-arrow {
    font-size: 16px;
    margin-left: 2px;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-confirm-btn-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Click Ripple Wave */
.chat-confirm-btn-accept::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 10%, transparent 60%);
    transform: scale(0);
    opacity: 0;
    transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}

.chat-confirm-btn-accept.is-clicked::after {
    transform: scale(2.5);
    opacity: 1;
    transition: 0s;
}

/* Loading Spinner on Accept */
.chat-confirm-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: chatConfirmSpin 0.6s linear infinite;
    display: inline-block;
    margin-left: 6px;
}

@keyframes chatConfirmSpin {
    to { transform: rotate(360deg); }
}