/* ══════════════════════════════════════════════════════════════
   Chat Widget — Modern Design System
   Scoped entirely under .oc-* classes to avoid host-page clashes.
   Works on the storefront AND inside the Bootstrap admin panel.
   ══════════════════════════════════════════════════════════════ */

.oc-chat-widget {
    /* ── Design tokens ── */
    --oc-brand: #6366f1;
    --oc-brand-2: #8b5cf6;
    --oc-brand-strong: #4f46e5;
    --oc-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --oc-ink: var(--theme-text-strong, #0f172a);
    --oc-text: var(--theme-text, #334155);
    --oc-muted: var(--theme-text-muted, #64748b);
    --oc-faint: #94a3b8;
    --oc-line: var(--theme-border, #e2e8f0);
    --oc-surface: var(--theme-surface, #ffffff);
    --oc-canvas: var(--theme-surface-muted, #f8fafc);
    --oc-brand-soft: #eef2ff;
    --oc-brand-line: #c7d2fe;
    --oc-brand-ink: #4338ca;
    --oc-success: #10b981;
    --oc-success-bg: #ecfdf5;
    --oc-success-line: #a7f3d0;
    --oc-warn-ink: #92400e;
    --oc-warn-bg: #fffbeb;
    --oc-warn-line: #fde68a;
    --oc-danger: #ef4444;
    --oc-ring: 0 0 0 3px rgba(99, 102, 241, 0.18);
    --oc-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.08);
    --oc-shadow-md: 0 2px 4px rgba(15, 23, 42, 0.06), 0 12px 32px rgba(15, 23, 42, 0.14);
    --oc-shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.08), 0 24px 64px rgba(15, 23, 42, 0.24);

    position: fixed;
    bottom: 20px;
    right: 20px;
    /* Must sit BELOW the Quick Cart drawer (1055) and SweetAlert2 (1060)
       but above the floating cart pill (1040) and header (1030-1035).
       Was 9999 which covered the drawer's Checkout button — see
       public/frontend/css/quick-cart.css z-index scale. */
    z-index: 1045;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--oc-text);
}

.oc-chat-widget *,
.oc-chat-widget *::before,
.oc-chat-widget *::after { box-sizing: border-box; }

/* ── Launcher ─────────────────────────────────────────────── */
.oc-chat-toggle {
    position: relative;
    cursor: grab;
    touch-action: none;
    width: auto;
    height: 54px;
    border-radius: 999px;
    background: var(--oc-grad);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px 0 16px;
    cursor: grab;
    border: none;
    font-size: 14px;
    margin-left: auto;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
.oc-chat-toggle:active { cursor: grabbing; }
.oc-chat-header { cursor: grab; touch-action: none; }
.oc-chat-header:active { cursor: grabbing; }
.oc-chat-toggle:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.55);
}
.oc-chat-toggle:active { transform: scale(0.97); }

/* Soft attention ring behind the launcher */
.oc-chat-toggle::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: inherit;
    border: 2px solid rgba(99, 102, 241, 0.35);
    animation: ocRingPulse 2.6s ease-out infinite;
    pointer-events: none;
}
@keyframes ocRingPulse {
    0%   { transform: scale(0.92); opacity: 0.9; }
    70%  { transform: scale(1.12); opacity: 0; }
    100% { transform: scale(1.12); opacity: 0; }
}

.oc-chat-icon { display: inline-flex; }
.oc-chat-icon svg { width: 22px; height: 22px; }
.oc-chat-toggle-label { font-size: 14px; font-weight: 600; line-height: 1; letter-spacing: 0.01em; }

/* ── Panel shell ──────────────────────────────────────────── */
.oc-chat-panel {
    position: absolute;
    bottom: 74px;
    right: 0;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 100px);
    background: var(--oc-surface);
    border-radius: 20px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: var(--oc-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
}
/* Entry animation replays every time .oc-hidden is removed */
.oc-chat-panel:not(.oc-hidden) { animation: ocPanelIn 0.32s cubic-bezier(0.21, 1.02, 0.73, 1) both; }
@keyframes ocPanelIn {
    from { opacity: 0; transform: translateY(14px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ───────────────────────────────────────────────── */
.oc-chat-header {
    background: var(--oc-grad);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}
/* Ambient glow blobs in the header */
.oc-chat-header::before,
.oc-chat-header::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    pointer-events: none;
}
.oc-chat-header::before { width: 130px; height: 130px; top: -70px; right: -30px; }
.oc-chat-header::after  { width: 80px;  height: 80px;  bottom: -50px; left: 60px; }

.oc-header-left { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; min-width: 0; }
.oc-header-avatar {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(6px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.oc-header-avatar svg { width: 20px; height: 20px; }

.oc-header-text { display: flex; flex-direction: column; min-width: 0; }
.oc-chat-header-title { font-weight: 700; font-size: 15px; line-height: 1.2; letter-spacing: 0.01em; }
.oc-header-sub {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.82);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.oc-dot {
    width: 7px;
    height: 7px;
    flex: none;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}

.oc-chat-close {
    position: relative;
    z-index: 1;
    width: 32px;
    height: 32px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.14);
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}
.oc-chat-close:hover { background: rgba(255, 255, 255, 0.26); transform: rotate(90deg); }
.oc-chat-close svg { width: 16px; height: 16px; }

/* ── Conversation list ────────────────────────────────────── */
.oc-chat-conversations { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.oc-chat-list-header {
    padding: 12px 16px 10px;
    border-top: 1px solid var(--oc-line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--oc-line);
}
.oc-chat-list-header small {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--oc-faint);
}
.oc-new-chat-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #eef2ff;
    border: 1px solid #e0e7ff;
    color: var(--oc-brand-strong);
    border-radius: 999px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}
.oc-new-chat-btn svg { width: 13px; height: 13px; }
.oc-new-chat-btn:hover { background: #e0e7ff; box-shadow: var(--oc-shadow-sm); transform: translateY(-1px); }

.oc-conversation-list { flex: none; padding: 6px; }
.oc-conv-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 10px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}
.oc-conv-item:hover { background: var(--oc-canvas); box-shadow: inset 0 0 0 1px var(--oc-line); }

.oc-conv-avatar {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    border: 1px solid #e0e7ff;
    color: var(--oc-brand-strong);
    font-weight: 700;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}
.oc-conv-body { flex: 1; min-width: 0; }
.oc-conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.oc-conv-subject {
    font-weight: 600;
    font-size: 13px;
    color: var(--oc-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.oc-conv-preview {
    font-size: 12px;
    color: var(--oc-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.oc-conv-meta { font-size: 10.5px; color: var(--oc-faint); flex: none; }

.oc-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    letter-spacing: 0.02em;
}
.oc-chip-amber { background: var(--oc-warn-bg); color: var(--oc-warn-ink); border: 1px solid var(--oc-warn-line); }
.oc-chip-green { background: var(--oc-success-bg); color: #047857; border: 1px solid var(--oc-success-line); }

/* ── Active chat ──────────────────────────────────────────── */
.oc-chat-active { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.oc-chat-active-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--oc-line);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--oc-surface);
}
.oc-back-btn {
    width: 30px;
    height: 30px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    color: var(--oc-muted);
    transition: background 0.15s, color 0.15s;
}
.oc-back-btn:hover { background: var(--oc-canvas); color: var(--oc-ink); }
.oc-back-btn svg { width: 17px; height: 17px; }
.oc-active-subject {
    flex: 1;
    font-weight: 650;
    font-size: 13px;
    color: var(--oc-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.oc-escalate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--oc-surface);
    border: 1px solid var(--oc-line);
    color: var(--oc-text);
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}
.oc-escalate-btn svg { width: 14px; height: 14px; }
.oc-escalate-btn:hover {
    border-color: var(--oc-brand);
    color: var(--oc-brand-strong);
    background: #eef2ff;
    box-shadow: var(--oc-shadow-sm);
}
.oc-escalate-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Messages canvas ──────────────────────────────────────── */
.oc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    background-color: var(--oc-canvas);
    /* Faint dotted texture, like premium support tools */
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.oc-message { max-width: 82%; animation: ocMsgIn 0.28s cubic-bezier(0.21, 1.02, 0.73, 1) both; }
@keyframes ocMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.oc-message-mine { align-self: flex-end; }
.oc-message-other { align-self: flex-start; }

.oc-msg-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.oc-avatar {
    width: 20px;
    height: 20px;
    flex: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: var(--oc-shadow-sm);
}
.oc-avatar svg { width: 11px; height: 11px; }
.oc-avatar-ai { background: var(--oc-grad); }
.oc-avatar-staff { background: linear-gradient(135deg, #f59e0b, #f97316); }

.oc-role-label { font-size: 11px; font-weight: 700; color: var(--oc-faint); letter-spacing: 0.03em; }

.oc-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 13px;
    line-height: 1.55;
}
.oc-message-mine .oc-bubble {
    background: var(--oc-grad);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.oc-message-other .oc-bubble {
    background: var(--oc-surface);
    color: var(--oc-text);
    border: 1px solid var(--oc-line);
    border-bottom-left-radius: 6px;
    box-shadow: var(--oc-shadow-sm);
}

.oc-time { font-size: 10px; color: var(--oc-faint); display: block; margin-top: 3px; }
.oc-message-mine .oc-time { text-align: right; }

/* AI typing indicator */
.oc-ai-pending { opacity: 1; }
.oc-typing { display: inline-flex; align-items: center; gap: 4px; padding: 3px 2px; }
.oc-typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--oc-brand);
    opacity: 0.4;
    animation: ocTypingBounce 1.2s infinite ease-in-out;
}
.oc-typing i:nth-child(2) { animation-delay: 0.15s; }
.oc-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ocTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* Ratings */
.oc-rating { margin-top: 5px; display: flex; gap: 4px; }
.oc-thumb {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--oc-surface);
    border: 1px solid var(--oc-line);
    border-radius: 8px;
    cursor: pointer;
    color: var(--oc-faint);
    transition: all 0.15s;
}
.oc-thumb svg { width: 13px; height: 13px; }
.oc-thumb:hover { color: var(--oc-brand-strong); border-color: var(--oc-brand); background: #eef2ff; transform: translateY(-1px); }
.oc-rated {
    opacity: 1;
    font-size: 12px;
    color: var(--oc-faint);
    align-items: center;
    gap: 4px;
}
.oc-rated svg { width: 14px; height: 14px; }

/* System notes */
.oc-human-pending {
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 12px;
    border: 1px dashed var(--oc-warn-line);
    border-radius: 12px;
    background: var(--oc-warn-bg);
    color: var(--oc-warn-ink);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    animation: ocMsgIn 0.28s ease both;
}
.oc-resolved-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    background: linear-gradient(180deg, var(--oc-success-bg), #f0fdf4);
    border-top: 1px solid var(--oc-success-line);
    color: #047857;
    font-size: 13px;
    font-weight: 600;
}
.oc-resolved-msg svg { width: 15px; height: 15px; }

.oc-message-error {
    display: inline-flex;
    align-items: flex-start;
    gap: 5px;
    font-size: 11px;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 4px 8px;
    margin-top: 5px;
    word-break: break-word;
    max-width: 100%;
}

/* Attachments */
.oc-attachment { margin-top: 5px; }
.oc-attachment img {
    max-height: 140px;
    max-width: 100%;
    border-radius: 12px;
    cursor: zoom-in;
    border: 1px solid var(--oc-line);
    transition: transform 0.15s;
}
.oc-attachment img:hover { transform: scale(1.02); }

/* ── Composer ─────────────────────────────────────────────── */
.oc-chat-input-area {
    border-top: 1px solid var(--oc-line);
    padding: 10px 12px;
    background: var(--oc-surface);
}
.oc-attachment-preview {
    margin-bottom: 8px;
    padding: 6px;
    background: var(--oc-canvas);
    border: 1px solid var(--oc-line);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: ocMsgIn 0.2s ease both;
}
.oc-attachment-preview img { max-height: 44px; border-radius: 8px; }
.oc-remove-attach {
    width: 24px;
    height: 24px;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--oc-surface);
    border: 1px solid var(--oc-line);
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    color: var(--oc-muted);
    line-height: 1;
    transition: all 0.15s;
}
.oc-remove-attach:hover { color: var(--oc-danger); border-color: var(--oc-danger); background: #fef2f2; }

.oc-chat-input-row { display: flex; align-items: flex-end; gap: 8px; }
.oc-attach-btn {
    width: 38px;
    height: 38px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: var(--oc-muted);
    transition: background 0.15s, color 0.15s;
}
.oc-attach-btn svg { width: 18px; height: 18px; }
.oc-attach-btn:hover { background: var(--oc-canvas); color: var(--oc-brand-strong); }

.oc-chat-input {
    flex: 1;
    border: 1.5px solid var(--oc-line);
    border-radius: 20px;
    padding: 9px 14px;
    resize: none;
    font-size: 13px;
    outline: none;
    max-height: 96px;
    font-family: inherit;
    background: var(--oc-canvas);
    color: var(--oc-ink);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.oc-chat-input::placeholder { color: var(--oc-faint); }
.oc-chat-input:focus {
    border-color: var(--oc-brand);
    background: var(--oc-surface);
    box-shadow: var(--oc-ring);
}

.oc-send-btn {
    width: 38px;
    height: 38px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--oc-grad);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s, opacity 0.15s;
}
.oc-send-btn svg { width: 16px; height: 16px; margin-right: -1px; }
.oc-send-btn:hover:not(:disabled) { transform: scale(1.08); box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5); }
.oc-send-btn:active:not(:disabled) { transform: scale(0.94); }
.oc-send-btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }

/* ── Guest call to action (in place of the composer) ───────── */
.oc-chat-login-prompt {
    flex: none;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 4px 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--oc-line);
    background: var(--oc-surface);
    text-align: start;
}
.oc-login-hero {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--oc-grad);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.32);
}
.oc-login-hero svg { width: 18px; height: 18px; }
.oc-login-copy { min-width: 0; }
.oc-chat-login-prompt p { margin: 0; color: var(--oc-muted); }
.oc-chat-login-prompt .oc-login-title { font-size: 13.5px; font-weight: 700; line-height: 1.3; color: var(--oc-ink); }
.oc-chat-login-prompt .oc-login-sub { font-size: 12px; line-height: 1.4; }
.oc-login-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin-top: 6px;
}
.oc-login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    background: var(--oc-grad);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    padding: 7px 20px;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
    border: none;
    cursor: pointer;
}
.oc-login-btn svg { width: 14px; height: 14px; }
.oc-login-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(99, 102, 241, 0.5); color: #fff; text-decoration: none; }
.oc-track-link { font-size: 12.5px; font-weight: 600; color: var(--oc-brand-ink); text-decoration: underline; text-underline-offset: 2px; }
.oc-track-link:hover { color: var(--oc-brand-strong); }
.oc-cta-pulse { animation: ocCtaPulse 1.2s ease-out 1; }
@keyframes ocCtaPulse {
    0% { box-shadow: inset 0 0 0 2px var(--oc-brand); }
    100% { box-shadow: inset 0 0 0 2px transparent; }
}

/* ── Empty state ──────────────────────────────────────────── */
.oc-empty-state {
    padding: 44px 16px;
    text-align: center;
    color: var(--oc-faint);
    font-size: 13px;
}

/* ── CSAT ─────────────────────────────────────────────────── */
.oc-csat-prompt {
    align-self: stretch;
    padding: 14px;
    text-align: center;
    background: var(--oc-surface);
    border: 1px solid var(--oc-line);
    border-radius: 14px;
    margin: 4px 0;
    box-shadow: var(--oc-shadow-sm);
    animation: ocMsgIn 0.28s ease both;
}
.oc-csat-prompt p { margin: 0 0 10px; font-size: 13px; font-weight: 650; color: var(--oc-ink); }
.oc-csat-actions { display: flex; gap: 8px; justify-content: center; }
.oc-csat-prompt button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px 18px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
}
.oc-csat-prompt svg { width: 14px; height: 14px; }
.oc-csat-yes { background: var(--oc-grad); color: #fff; border: none; box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35); }
.oc-csat-yes:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(99, 102, 241, 0.45); }
.oc-csat-no { background: var(--oc-surface); color: var(--oc-muted); border: 1.5px solid var(--oc-line); }
.oc-csat-no:hover { border-color: var(--oc-danger); color: var(--oc-danger); background: #fef2f2; }
.oc-csat-thanks {
    color: #047857 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0 !important;
}
.oc-csat-thanks svg { width: 14px; height: 14px; }

/* ── Toast ────────────────────────────────────────────────── */
.oc-toast {
    position: absolute;
    bottom: 74px;
    right: 0;
    background: var(--oc-ink);
    color: #f8fafc;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    max-width: 300px;
    box-shadow: var(--oc-shadow-lg);
    animation: ocToastIn 0.25s cubic-bezier(0.21, 1.02, 0.73, 1) both;
    z-index: 1;
}
@keyframes ocToastIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.oc-toast-success { background: linear-gradient(135deg, #059669, #10b981); }
.oc-toast-error { background: linear-gradient(135deg, #dc2626, #ef4444); }

.oc-hidden { display: none !important; }

/* ── Scrollbar ────────────────────────────────────────────── */
.oc-chat-panel ::-webkit-scrollbar { width: 6px; height: 6px; }
.oc-chat-panel ::-webkit-scrollbar-track { background: transparent; }
.oc-chat-panel ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
.oc-chat-panel ::-webkit-scrollbar-thumb:hover { background: var(--oc-faint); }
.oc-conversation-list, .oc-messages { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }

/* ── Focus visibility ─────────────────────────────────────── */
.oc-chat-widget button:focus-visible,
.oc-chat-widget a:focus-visible,
.oc-chat-widget textarea:focus-visible {
    outline: 2px solid var(--oc-brand);
    outline-offset: 2px;
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .oc-chat-widget *,
    .oc-chat-widget *::before,
    .oc-chat-widget *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Responsive ─────────────────────────────────────────────
   Full-screen on phones (and short viewports, e.g. landscape).
   Anchored to the viewport itself because the wrapper sits
   inset from the corner. */
@media (max-width: 640px), (max-height: 520px) {
    .oc-chat-widget {
        right: 16px;
        bottom: calc(16px + constant(safe-area-inset-bottom));
        bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .oc-chat-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        border: none;
        transform-origin: center;
    }

    .oc-chat-toggle {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        padding: 0;
        justify-content: center;
    }
    .oc-chat-icon svg { width: 20px; height: 20px; }
    .oc-chat-toggle::before { display: none; }
    .oc-chat-toggle-label { display: none; }

    .oc-chat-input-area {
        padding-bottom: calc(10px + constant(safe-area-inset-bottom));
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .oc-toast {
        position: fixed;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        margin: 0 auto;
        text-align: center;
        bottom: calc(76px + constant(safe-area-inset-bottom));
        bottom: calc(76px + env(safe-area-inset-bottom));
    }
}

/* ── Admin-side helpers (unchanged contracts) ─────────────── */
.provider-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 6px;
    margin-left: 4px;
    vertical-align: middle;
    border-radius: 10px;
    color: #495057;
    background: #fff;
    border: 1px solid #dee2e6;
}

.message-error-detail {
    font-size: 12px;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 4px 8px;
    margin-top: 6px;
    word-break: break-word;
    max-width: 100%;
}

/* ── Quick Cart Drawer overlap fix ──────────────────────────────
   When the cart drawer (#quickCartSidebar.open, z-index 1055) is open it
   occupies the bottom-right corner where the chat launcher and floating
   cart pill sit. With the old z-index 9999 the launcher painted OVER the
   drawer's Checkout button making it unclickable. Now that the drawer is
   above the launcher (1045 < 1055) we also fully hide the launcher so it
   doesn't peek through, trap focus, or flash during the slide animation. */
.qc-sidebar.open ~ #oc-chat-widget,
body:has(.qc-sidebar.open) #oc-chat-widget {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    /* hide instantly on open, fade back on close */
    transition: opacity .18s ease, visibility .18s ease;
}
@media(prefers-reduced-motion:reduce){
    .qc-sidebar.open ~ #oc-chat-widget,
    body:has(.qc-sidebar.open) #oc-chat-widget{transition:none!important}
}
/* When the chat panel itself is open and the cart drawer opens, push the
   chat panel behind the drawer as well so the drawer is always on top. */
.qc-sidebar.open ~ #oc-chat-widget .oc-chat-panel{pointer-events:none}

/* ══════════════════════════════════════════════════════════════
   Suggested questions ("chips"): the opening screen, the inline
   empty state, the Suggestions tray and per-answer follow-ups.
   ══════════════════════════════════════════════════════════════ */
.oc-sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Opening screen */
.oc-home { padding: 18px 14px 14px; }
.oc-home-hero { text-align: center; margin-bottom: 14px; }
.oc-home-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 10px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--oc-grad);
    color: #fff;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.32);
}
.oc-home-icon svg { width: 22px; height: 22px; }
.oc-chat-widget .oc-home-title {
    margin: 0 0 4px;
    padding: 0;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0;
    color: var(--oc-ink);
    overflow-wrap: anywhere;
}
/* Focus lands here (tabindex=-1) so screen readers start at the greeting; it is not a control, so no ring. */
#oc-chat-widget .oc-home-title:focus,
#oc-chat-widget .oc-home-title:focus-visible { outline: none !important; box-shadow: none !important; }
.oc-home-intro { margin: 0 auto; max-width: 300px; font-size: 12.5px; line-height: 1.5; color: var(--oc-muted); }

/* Category cards */
.oc-chip-groups {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.oc-chip-group {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--oc-line);
    border-radius: 12px;
    background: var(--oc-surface);
}
.oc-chat-widget .oc-chip-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--oc-muted);
}
.oc-chip-title svg { flex: none; width: 13px; height: 13px; color: var(--oc-brand); }
.oc-chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

.oc-chat-widget .oc-chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    min-height: 32px;
    margin: 0;
    padding: 5px 10px;
    border: 1px solid var(--oc-line);
    border-radius: 14px;
    background: var(--oc-canvas);
    color: var(--oc-text);
    font: inherit;
    font-size: 12.5px;
    line-height: 1.35;
    text-align: start;
    cursor: pointer;
    transition: border-color .15s, background-color .15s, color .15s;
}
.oc-chip-text { min-width: 0; overflow-wrap: anywhere; }
.oc-chip-go { display: inline-flex; flex: none; color: var(--oc-muted); }
.oc-chip-go svg { width: 12px; height: 12px; }
.oc-chat-widget .oc-chip-btn:hover { border-color: var(--oc-brand); background: var(--oc-brand-soft); color: var(--oc-ink); }
.oc-chat-widget .oc-chip-btn:focus-visible { outline: 2px solid var(--oc-brand); outline-offset: 2px; border-color: var(--oc-brand); }
.oc-chat-widget .oc-chip-btn:active { background: var(--oc-brand-soft); }
.oc-chips-busy .oc-chip-btn { opacity: .55; cursor: progress; }

/* Personal shortcuts (logged-in customers' own open orders) */
.oc-chip-personal { display: grid; gap: 6px; margin-bottom: 8px; }
.oc-chat-widget .oc-chip-personal .oc-chip-btn {
    width: 100%;
    min-height: 38px;
    padding: 7px 12px;
    border-color: var(--oc-brand-line);
    border-inline-start: 3px solid var(--oc-brand);
    border-radius: 10px;
    background: var(--oc-brand-soft);
    color: var(--oc-ink);
    font-weight: 600;
}

.oc-chat-widget .oc-chip-note {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 8px 2px 0;
    font-size: 11.5px;
    color: var(--oc-muted);
}
.oc-chip-note svg { width: 12px; height: 12px; }

/* Loading placeholders: same footprint as the cards they stand in for */
.oc-chip-skeleton { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.oc-chip-group.oc-skel { display: grid; gap: 8px; min-height: 96px; align-content: start; }
.oc-skel span, .oc-skel i {
    display: block;
    height: 10px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--oc-canvas) 0%, var(--oc-line) 50%, var(--oc-canvas) 100%);
    background-size: 200% 100%;
    animation: ocShimmer 1.4s linear infinite;
}
.oc-skel span { width: 55%; }
.oc-skel i { height: 26px; border-radius: 13px; }
.oc-skel i + i { width: 70%; }
@keyframes ocShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Inside a conversation with no customer message yet */
.oc-inline-chips { align-self: stretch; margin-top: 2px; }
.oc-chat-widget .oc-inline-chips-title {
    margin: 0 2px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--oc-muted);
}

/* "Suggestions" button and tray above the composer */
.oc-chip-dock {
    flex: none;
    padding: 6px 12px 0;
    border-top: 1px solid var(--oc-line);
    background: var(--oc-surface);
}
.oc-chat-widget .oc-suggest-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 4px 12px;
    border: 1px solid var(--oc-brand-line);
    border-radius: 999px;
    background: var(--oc-brand-soft);
    color: var(--oc-brand-ink);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.oc-suggest-toggle svg { width: 14px; height: 14px; }
.oc-chat-widget .oc-suggest-toggle:hover { border-color: var(--oc-brand); }
.oc-chip-tray {
    max-height: min(40vh, 260px);
    overflow-y: auto;
    padding: 8px 0 2px;
    scrollbar-width: thin;
}
.oc-chip-dock + .oc-chat-input-area { border-top: 0; }

/* Compact chips (tray and inline): one horizontally scrollable row per group */
.oc-chip-tray .oc-chip-groups,
.oc-inline-chips .oc-chip-groups,
.oc-chip-tray .oc-chip-skeleton,
.oc-inline-chips .oc-chip-skeleton { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.oc-chip-tray .oc-chip-group { padding: 0; border: 0; background: transparent; }
.oc-chip-tray .oc-chip-title { margin-bottom: 6px; }
.oc-chip-tray .oc-chip-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    scrollbar-width: none;
}
.oc-chip-tray .oc-chip-list::-webkit-scrollbar { display: none; }
.oc-chip-tray .oc-chip-btn { flex: none; white-space: nowrap; scroll-snap-align: start; }

/* Follow-ups under the newest answer */
.oc-followups {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.oc-chat-widget .oc-chip-follow {
    border-color: var(--oc-brand-line);
    background: var(--oc-surface);
    color: var(--oc-brand-ink);
    font-weight: 600;
}

/* Answers: the light Markdown subset */
.oc-md p { margin: 0 0 6px; }
.oc-md p:last-child, .oc-md ul:last-child, .oc-md ol:last-child { margin-bottom: 0; }
.oc-md ul, .oc-md ol { margin: 4px 0 6px; padding-inline-start: 18px; }
.oc-md li { margin: 2px 0; }
.oc-md li::marker { color: var(--oc-muted); }
.oc-md strong { font-weight: 700; color: var(--oc-ink); }
.oc-md code { padding: 1px 4px; border-radius: 4px; background: var(--oc-canvas); font-size: 12px; }
.oc-md a { color: var(--oc-link, #1d4ed8); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }

/* Phones: full-screen panel, one swipeable row per group */
@media (max-width: 640px) {
    .oc-home { padding: 16px 16px 14px; }
    .oc-chip-groups, .oc-chip-skeleton { grid-template-columns: minmax(0, 1fr); }
    .oc-chip-group { padding: 10px 0 10px 10px; }
    .oc-chip-list {
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        padding-inline-end: 10px;
        padding-bottom: 2px;
        scrollbar-width: none;
    }
    .oc-chip-list::-webkit-scrollbar { display: none; }
    .oc-chat-widget .oc-chip-btn { flex: none; min-height: 36px; white-space: nowrap; scroll-snap-align: start; }
    .oc-chat-widget .oc-chip-personal .oc-chip-btn { white-space: normal; }
    .oc-chip-group.oc-skel { min-height: 64px; }
    .oc-chat-login-prompt {
        padding-bottom: calc(12px + constant(safe-area-inset-bottom));
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}
[dir="rtl"] .oc-chip-group { padding-inline: 10px; }
@media (max-width: 640px) { [dir="rtl"] .oc-chip-group { padding: 10px 10px 10px 0; } }

/* Right to left: mirror the parts that point somewhere */
[dir="rtl"] .oc-chat-panel { transform-origin: bottom left; }
[dir="rtl"] .oc-message-mine .oc-bubble { border-bottom-right-radius: 16px; border-bottom-left-radius: 6px; }
[dir="rtl"] .oc-message-other .oc-bubble { border-bottom-left-radius: 16px; border-bottom-right-radius: 6px; }
[dir="rtl"] .oc-message-mine .oc-time { text-align: left; }
[dir="rtl"] .oc-back-btn svg,
[dir="rtl"] .oc-send-btn svg,
[dir="rtl"] .oc-chip-go svg { transform: scaleX(-1); }
[dir="rtl"] .oc-remove-attach { margin-left: 0; margin-right: auto; }

/* Dark: the widget's dark palette (support-cards.css) plus the new chip tokens */
:is([data-theme="dark"], [data-bs-theme="dark"], .dark-mode) .oc-chat-widget {
    --oc-brand-soft: rgba(129, 140, 248, .16);
    --oc-brand-line: rgba(129, 140, 248, .42);
    --oc-brand-ink: #c7d2fe;
}
:is([data-theme="dark"], [data-bs-theme="dark"], .dark-mode) .oc-chat-widget .oc-new-chat-btn {
    background: var(--oc-brand-soft);
    border-color: var(--oc-brand-line);
    color: var(--oc-brand-ink);
}
:is([data-theme="dark"], [data-bs-theme="dark"], .dark-mode) .oc-chat-widget .oc-conv-avatar {
    background: var(--oc-brand-soft);
    border-color: var(--oc-brand-line);
    color: var(--oc-brand-ink);
}
:is([data-theme="dark"], [data-bs-theme="dark"], .dark-mode) .oc-chat-panel { border-color: var(--oc-line); }
:is([data-theme="dark"], [data-bs-theme="dark"], .dark-mode) .oc-chat-widget .oc-escalate-btn:hover,
:is([data-theme="dark"], [data-bs-theme="dark"], .dark-mode) .oc-chat-widget .oc-thumb:hover { background: var(--oc-brand-soft); color: var(--oc-brand-ink); }

@media (prefers-reduced-motion: reduce) {
    .oc-skel span, .oc-skel i { animation: none; }
    .oc-cta-pulse { animation: none; }
    .oc-chip-btn { transition: none; }
}

/* Suggestions unavailable: the guest greeting sits in the middle, as the old login prompt did */
.oc-is-guest .oc-chips-off .oc-chat-conversations { justify-content: center; }
.oc-is-guest .oc-chips-off .oc-home-hero { margin-bottom: 0; }
