/* === Welfog chat: tokens + themes ================================= */
:root {
    --wf-primary: #fb5404;
    --wf-primary-hover: #ff6a28;
    --wf-primary-glow: rgba(251, 84, 4, 0.22);
    --wf-secondary: #009688;
    --wf-secondary-hover: #26a69a;
    --wf-secondary-soft: rgba(0, 150, 136, 0.14);
    --wf-secondary-border: rgba(0, 150, 136, 0.32);
    --wf-font: "DM Sans", system-ui, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
    --wf-page-bg: #060807;
    --wf-page-grad-mid: #0c1211;
    --wf-surface: #0e1211;
    --wf-surface-elevated: #141a19;
    --wf-border: rgba(0, 150, 136, 0.22);
    --wf-text: #f0f3f2;
    --wf-text-muted: #8a9694;
    --wf-header-bg: #0f1413;
    --wf-input-bg: #ffffff;
    --wf-input-text: #111;
    --wf-bot-bg: #f4f6f5;
    --wf-bot-text: #111;
    --wf-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
    --wf-page-bg: #e8eded;
    --wf-page-grad-mid: #dce5e4;
    --wf-surface: #ffffff;
    --wf-surface-elevated: #f6faf9;
    --wf-border: rgba(0, 150, 136, 0.2);
    --wf-text: #14201e;
    --wf-text-muted: #5c6d6a;
    --wf-header-bg: #ffffff;
    --wf-input-bg: #f3f7f6;
    --wf-input-text: #111;
    --wf-bot-bg: #ffffff;
    --wf-bot-text: #111;
    --wf-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

html, body {
    height: 100%;
}

.app-body {
    margin: 0;
    font-family: var(--wf-font);
    background: linear-gradient(145deg, var(--wf-page-bg), var(--wf-page-grad-mid), var(--wf-page-bg));
    color: var(--wf-text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 12px;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: min(420px, 100%);
    height: min(92vh, 900px);
    max-height: 100vh;
    background: var(--wf-surface);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 0 1px var(--wf-border), var(--wf-shadow);
    position: relative;
    overflow: hidden;
}

/* --- Sidebar ------------------------------------------------------ */
.history-panel {
    position: absolute;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: var(--wf-surface-elevated);
    z-index: 20;
    transition: left 0.28s ease;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--wf-border);
}

.history-panel.open {
    left: 0;
    pointer-events: auto;
}

.history-panel:not(.open) {
    pointer-events: none;
}

.sidebar-brand {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--wf-border);
}

.sidebar-brand__text {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--wf-text);
    display: block;
    padding-bottom: 2px;
    border-bottom: 2px solid var(--wf-secondary);
    width: fit-content;
}

.btn-new-chat {
    margin: 12px 12px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: calc(100% - 24px);
    padding: 11px 14px;
    border: none;
    border-radius: 10px;
    background: var(--wf-primary);
    color: #fff;
    font-family: var(--wf-font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.btn-new-chat:hover {
    background: var(--wf-primary-hover);
}

.btn-new-chat:active {
    transform: scale(0.98);
}

.history-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.history-header {
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--wf-secondary);
    background: rgba(0, 150, 136, 0.06);
}

.history-close-mobile {
    display: flex;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px 16px;
}

.hist-placeholder {
    text-align: center;
    color: var(--wf-text-muted);
    font-size: 0.85rem;
    margin-top: 16px;
}

.hist-item {
    padding: 10px 10px;
    margin-bottom: 8px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.82rem;
    background: var(--wf-surface);
    border: 1px solid transparent;
    color: var(--wf-text);
    transition: border-color 0.2s, background 0.2s;
}

[data-theme="dark"] .hist-item {
    background: #121816;
}

.hist-item:hover {
    border-color: var(--wf-secondary-border);
    background: rgba(0, 150, 136, 0.08);
}

.hist-item--active {
    border-color: rgba(0, 150, 136, 0.45);
    box-shadow: 0 0 0 1px rgba(0, 150, 136, 0.22);
    background: rgba(0, 150, 136, 0.06);
}

.hist-item--active:hover {
    border-color: rgba(0, 150, 136, 0.55);
    box-shadow: 0 0 0 1px rgba(0, 150, 136, 0.32);
    background: rgba(0, 150, 136, 0.09);
}

[data-theme="dark"] .hist-item--active {
    border-color: rgba(0, 150, 136, 0.55);
    box-shadow: 0 0 0 1px rgba(0, 150, 136, 0.35);
    background: rgba(0, 150, 136, 0.11);
}

[data-theme="dark"] .hist-item--active:hover {
    border-color: rgba(0, 150, 136, 0.7);
    box-shadow: 0 0 0 1px rgba(0, 150, 136, 0.45);
    background: rgba(0, 150, 136, 0.14);
}

.hist-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.hist-date {
    font-size: 0.68rem;
    color: var(--wf-text-muted);
    margin-top: 4px;
}

.hist-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.hist-item-body {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.hist-delete {
    background: none;
    border: none;
    color: var(--wf-primary);
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    border-radius: 8px;
    flex-shrink: 0;
}

.hist-delete:hover {
    background: var(--wf-secondary-soft);
    color: var(--wf-secondary-hover);
}

/* --- Main panel --------------------------------------------------- */
.main-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    height: 100%;
    min-height: 0;
}

.main-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px 0 6px;
    height: 52px;
    background: var(--wf-header-bg);
    border-bottom: 1px solid var(--wf-border);
    position: relative;
    z-index: 10;
}

.main-header__menu {
    flex-shrink: 0;
}

.main-header__fill {
    flex: 1;
}

.main-header__contact {
    flex-shrink: 0;
    text-decoration: none;
    color: var(--wf-primary);
    border: 1px solid transparent;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.main-header__contact:hover {
    color: var(--wf-primary-hover);
    background: var(--wf-secondary-soft);
    border-color: var(--wf-border);
}

.main-header__contact:active {
    transform: scale(0.94);
}

/* Font Awesome sets display on .fas, which beats the default [hidden] UA rule — force one icon */
#themeToggle i[hidden],
.theme-toggle > i[hidden] {
    display: none !important;
}

.theme-toggle {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--wf-text);
    background: transparent;
    border: 1px solid transparent;
    transition: background 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
    background: var(--wf-secondary-soft);
    border-color: var(--wf-border);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--wf-text);
    font-size: 1.1rem;
    cursor: pointer;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--wf-secondary-soft);
}

.main-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Landing: hero centered above composer */
.state-landing .main-body {
    justify-content: center;
    align-items: center;
    padding: 12px 16px 8px;
}

.welcome-hero {
    text-align: center;
    max-width: 26rem;
    padding: 0 8px 8px;
    transition: opacity 0.4s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), max-height 0.45s ease, margin 0.45s ease;
}

.welcome-hero__title {
    margin: 0 0 10px;
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--wf-text);
}

.welcome-hero__subtitle {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--wf-text-muted);
}

.state-chat .welcome-hero {
    opacity: 0;
    transform: translateY(-20px);
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    pointer-events: none;
}

.state-landing .chat-messages {
    flex: 0 0 0;
    min-height: 0;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0;
    transition: opacity 0.25s ease, flex 0.45s ease, max-height 0.45s ease;
}

.state-chat .main-body {
    padding: 0;
}

.state-chat .chat-messages {
    flex: 1;
    opacity: 1;
    max-height: none;
    overflow-y: auto;
    padding: 14px 14px 10px;
    scroll-behavior: smooth;
    transition: opacity 0.35s ease 0.08s;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msg {
    max-width: min(88%, 100%);
    width: fit-content;
    padding: 11px 13px;
    margin: 4px 0;
    border-radius: 14px;
    animation: fadeIn 0.32s ease;
    display: flex;
    flex-direction: column;
    overflow-wrap: anywhere;
    word-break: break-word;
    box-sizing: border-box;
    /* Bubbles must not shrink when #chat becomes flex+scroll (state-chat) — avoids clipped/textarea-like boxes */
    flex-shrink: 0;
    flex-grow: 0;
}

.msg.user {
    align-self: flex-end;
}

.user {
    background: var(--wf-primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.bot {
    background: var(--wf-bot-bg);
    color: var(--wf-bot-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 0 0 1px var(--wf-secondary-soft);
    max-width: min(92%, 100%);
    /* Wide product rails need horizontal scroll; text still wraps due to max-width on .msg */
    overflow-x: auto;
    overflow-y: visible;
    min-width: 0;
}

/* Default: constrain injected HTML; product rail overrides below */
.msg * {
    box-sizing: border-box;
    max-width: 100%;
}

.msg .wf-product-rail,
.msg .wf-product-rail * {
    max-width: none;
}

.msg .wf-product-card img {
    max-width: 100% !important;
}

.msg img, .msg svg, .msg video, .msg iframe {
    max-width: 100% !important;
    height: auto !important;
}

.msg pre, .msg code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Composer -------------------------------------------------------- */
.composer {
    flex-shrink: 0;
    padding: 10px 12px 14px;
    background: var(--wf-surface);
    border-top: 1px solid var(--wf-border);
}

.composer__inner {
    display: flex;
    align-items: stretch;
    gap: 10px;
    max-width: 720px;
    margin: 0 auto;
    padding: 6px 8px 6px 14px;
    border-radius: 999px;
    background: var(--wf-input-bg);
    border: 1px solid var(--wf-border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .composer__inner {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

.composer__input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--wf-input-text);
    font-family: var(--wf-font);
    font-size: 0.95rem;
    min-width: 0;
    padding: 10px 4px;
}

.composer__input::placeholder {
    color: var(--wf-text-muted);
}

.composer__input:focus {
    outline: none;
}

.composer__mic {
    align-self: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--wf-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.05rem;
    transition: color 0.2s, background 0.2s, transform 0.15s;
}

.composer__mic:hover {
    color: var(--wf-text);
    background: var(--wf-secondary-soft);
}

.composer__mic:active {
    transform: scale(0.94);
}

.composer__mic:disabled,
.composer__mic--unsupported {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.composer__mic--active {
    color: #e53935;
    background: rgba(229, 57, 53, 0.12);
    animation: wf-mic-pulse 1.4s ease-in-out infinite;
}

.composer__mic--active:hover {
    color: #c62828;
    background: rgba(229, 57, 53, 0.18);
}

@keyframes wf-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(229, 57, 53, 0); }
}

.composer__inner--dictating {
    border-color: rgba(229, 57, 53, 0.45);
    box-shadow: 0 0 0 1px rgba(229, 57, 53, 0.2), 0 2px 12px rgba(229, 57, 53, 0.08);
}

.composer__send {
    align-self: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--wf-primary);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.composer__send:hover {
    background: var(--wf-primary-hover);
}

.composer__send:active {
    transform: scale(0.96);
}

.composer__send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(0.15);
}

.composer__send:disabled:hover {
    background: var(--wf-primary);
}

.composer__inner--locked {
    opacity: 0.9;
}

.composer__input:disabled {
    cursor: not-allowed;
    opacity: 0.88;
}

.composer-voice-status {
    max-width: 720px;
    margin: 6px auto 0;
    padding: 0 6px;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--wf-secondary);
    text-align: center;
}

.composer-voice-status--error {
    color: #c62828;
}

[data-theme="dark"] .composer-voice-status--error {
    color: #ef9a9a;
}

.typing {
    font-size: 0.88rem;
    margin: 6px 0;
    padding: 10px 12px;
    background: var(--wf-bot-bg);
    color: var(--wf-bot-text);
    border-radius: 12px;
    align-self: flex-start;
    box-shadow: 0 0 0 1px var(--wf-secondary-soft);
    flex-shrink: 0;
}

.dot {
    animation: blink 1.4s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Modal ------------------------------------------------------------ */
.confirm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
    backdrop-filter: blur(4px);
}

.confirm-backdrop.show {
    display: flex;
}

.confirm-modal {
    width: min(92%, 380px);
    background: var(--wf-surface-elevated);
    border: 1px solid var(--wf-border);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--wf-shadow);
    color: var(--wf-text);
}

.confirm-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--wf-secondary);
}

.confirm-text {
    font-size: 0.9rem;
    color: var(--wf-text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-btn {
    min-width: 92px;
    padding: 10px 14px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-family: var(--wf-font);
    font-weight: 600;
    font-size: 0.9rem;
}

.confirm-btn.cancel {
    background: var(--wf-surface);
    color: var(--wf-text-muted);
    border: 1px solid var(--wf-border);
}

.confirm-btn.delete {
    background: var(--wf-primary);
    color: #fff;
}

.confirm-btn.delete:hover {
    background: var(--wf-primary-hover);
}

/* === Desktop / tablet ============================================ */
@media (min-width: 768px) {
    .app-body {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .container {
        width: 100vw;
        height: 100vh;
        max-height: none;
        border-radius: 0;
        flex-direction: row;
    }

    .history-panel {
        position: relative;
        left: 0 !important;
        height: 100%;
        flex-shrink: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        transition: flex-basis 0.28s ease, min-width 0.28s ease, max-width 0.28s ease, opacity 0.22s ease;
        z-index: 1;
    }

    /* Collapsed: hamburger se sidebar band — pehle yahan dono state same thi isliye toggle dikhta nahi tha */
    .history-panel:not(.open) {
        flex: 0 0 0;
        width: 0;
        min-width: 0;
        max-width: 0;
        opacity: 0;
        border-right: none;
        pointer-events: none;
        padding: 0;
    }

    .history-panel.open {
        flex: 0 0 300px;
        width: 300px;
        min-width: 300px;
        max-width: 300px;
        opacity: 1;
        pointer-events: auto;
        border-right: 1px solid var(--wf-border);
    }

    .history-close-mobile {
        display: none;
    }

    .main-panel {
        border-left: 1px solid var(--wf-border);
    }

    .state-chat .chat-messages {
        padding: 18px 22px 12px;
    }

    .msg {
        max-width: min(72%, 100%);
    }

    .bot {
        max-width: min(78%, 100%);
    }
}

@media (max-width: 480px) {
    .app-body {
        padding: 0;
    }

    .container {
        width: 100%;
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }
}

/* --- Product / deal horizontal rails (HTML from chat_routes) ---------- */
.msg .wf-product-carousel {
    position: relative;
    width: 100%;
    min-width: 0;
}

.msg .wf-product-carousel__btn {
    position: absolute;
    top: 50%;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: var(--wf-primary);
    color: #fff;
    cursor: pointer;
    transform: translateY(-50%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    transition: opacity 0.2s ease, visibility 0.2s ease, background-color 0.15s ease;
}

.msg .wf-product-carousel__btn:hover:not(:disabled) {
    background: var(--wf-primary-hover);
}

.msg .wf-product-carousel__btn:focus-visible {
    outline: 2px solid var(--wf-primary);
    outline-offset: 2px;
}

.msg .wf-product-carousel__btn--prev {
    left: 6px;
}

.msg .wf-product-carousel__btn--next {
    right: 6px;
}

.msg .wf-product-carousel__btn.is-hidden,
.msg .wf-product-carousel__btn:disabled {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.msg .wf-product-carousel__btn i {
    font-size: 14px;
    line-height: 1;
    pointer-events: none;
}

.msg .wf-product-rail {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 12px;
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 148px;
    padding: 6px 0 8px;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 6px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    flex-shrink: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.msg .wf-product-rail::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.msg .wf-product-card {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    scroll-snap-align: start;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 12px;
    background: var(--wf-bot-bg);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
    min-width: 160px;
    min-height: 240px;
    flex-shrink: 0;
}

[data-theme="dark"] .msg .wf-product-card {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}

.msg .wf-product-card a[href] {
    display: block;
    text-align: center;
    margin-top: auto;
    flex-shrink: 0;
    background-color: var(--wf-primary);
    color: #fff;
    padding: 10px 12px;
    text-decoration: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
}

.msg .wf-product-card a[href]:hover {
    background-color: var(--wf-primary-hover);
    color: #fff;
}

@media (max-width: 767px) {
    @supports selector(:has(*)) {
        .state-chat .chat-messages .msg.bot:has(.wf-product-rail) {
            max-width: 100% !important;
            width: 100%;
            align-self: stretch;
        }
    }

    .msg .wf-product-carousel__btn {
        width: 32px;
        height: 32px;
    }

    .msg .wf-product-carousel__btn--prev {
        left: 4px;
    }

    .msg .wf-product-carousel__btn--next {
        right: 4px;
    }

    .msg .wf-product-card {
        /* Exactly 2 cards visible per viewport width; scroll horizontally for more */
        flex: 0 0 calc((100% - 12px) / 2);
        width: calc((100% - 12px) / 2);
        min-width: calc((100% - 12px) / 2);
        max-width: calc((100% - 12px) / 2);
        scroll-snap-align: start;
    }
}

@media (min-width: 768px) {
    .msg .wf-product-card {
        width: 188px;
        flex: 0 0 188px;
        max-width: 188px;
    }
}

/* --- Purchase history (API list + View more) -------------------------------- */
.msg .wf-ph-title {
    font-size: 15px;
    margin-bottom: 10px;
    color: var(--wf-bot-text);
}

.msg .wf-ph-msg {
    font-size: 14px;
    line-height: 1.5;
    color: var(--wf-bot-text);
}

.msg .wf-ph-scroll {
    max-height: min(52vh, 420px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    margin-bottom: 0;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.msg .wf-ph-root > .wf-ph-tail {
    padding: 14px 4px 4px;
    margin-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
    flex-shrink: 0;
}

.msg .wf-ph-scroll .wf-ph-tail {
    padding: 14px 4px 8px;
    margin-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
    flex-shrink: 0;
}

[data-theme="dark"] .msg .wf-ph-root > .wf-ph-tail,
[data-theme="dark"] .msg .wf-ph-scroll .wf-ph-tail {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.msg .wf-ph-card {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.03);
    position: relative;
}

.msg .wf-ph-card-head {
    position: relative;
    padding-top: 2px;
}

.msg .wf-ph-track-btn {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    appearance: none;
    border: 1px solid var(--wf-primary);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    background: #fff;
    color: var(--wf-primary);
    white-space: nowrap;
    touch-action: manipulation;
}

[data-theme="dark"] .msg .wf-ph-track-btn {
    background: rgba(255, 122, 0, 0.12);
}

.msg .wf-ph-track-btn:hover {
    background: var(--wf-primary);
    color: #fff;
}

.msg .wf-ph-card--track-open .wf-ph-track-btn {
    background: var(--wf-primary);
    color: #fff;
}

.msg .wf-ph-meta--status {
    margin-top: 4px;
}

.msg .wf-ph-status-label {
    display: inline;
    margin-right: 4px;
}

.msg .wf-ph-status-badge {
    display: inline-block;
    font-weight: 700;
    font-size: 12px;
    color: #ff7a00;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(255, 122, 0, 0.12);
}

.msg .wf-ph-status-badge--cancelled {
    color: #b91c1c;
    background: rgba(185, 28, 28, 0.1);
}

.msg .wf-ph-status-badge--delivered {
    color: #15803d;
    background: rgba(21, 128, 61, 0.12);
}

.msg .wf-ph-status-badge--shipped {
    color: #1d4ed8;
    background: rgba(29, 78, 216, 0.1);
}

.msg .wf-ph-track-panel {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .msg .wf-ph-track-panel {
    border-top-color: rgba(255, 255, 255, 0.12);
}

.msg .wf-ph-track-panel-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--wf-bot-text);
    margin-bottom: 10px;
}

.msg .wf-ph-track-empty {
    font-size: 12px;
    color: var(--wf-text-muted);
}

.msg .wf-ph-flow {
    border-left: 3px solid var(--wf-primary);
    margin-left: 6px;
    padding-left: 14px;
}

.msg .wf-ph-flow-step {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 12px;
    font-size: 12px;
}

.msg .wf-ph-flow-step:last-child {
    margin-bottom: 0;
}

.msg .wf-ph-flow-dot {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 4px;
    background: #cbd5e1;
}

.msg .wf-ph-flow-step--done .wf-ph-flow-dot {
    background: #22c55e;
}

.msg .wf-ph-flow-step--pending .wf-ph-flow-title {
    color: var(--wf-text-muted);
}

.msg .wf-ph-flow-step--done .wf-ph-flow-title {
    color: var(--wf-bot-text);
    font-weight: 600;
}

.msg .wf-ph-flow-when {
    font-size: 11px;
    color: var(--wf-text-muted);
    margin-top: 2px;
}

.msg .wf-ph-flow-reason {
    font-size: 11px;
    color: var(--wf-text-muted);
    margin-top: 2px;
    font-style: italic;
}

[data-theme="dark"] .msg .wf-ph-card {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.msg .wf-ph-card-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.msg .wf-ph-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 8px;
    background: #f5f5f5;
    flex-shrink: 0;
}

.msg .wf-ph-img--placeholder {
    background: linear-gradient(135deg, #e8e8e8, #f5f5f5);
}

[data-theme="dark"] .msg .wf-ph-img {
    background: rgba(255, 255, 255, 0.06);
}

.msg .wf-ph-card-row .wf-ph-card-body {
    flex: 1;
    min-width: 0;
    padding-right: 92px;
}

.msg .wf-ph-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.35;
    color: var(--wf-bot-text);
    margin-bottom: 6px;
}

.msg .wf-ph-meta {
    font-size: 12px;
    color: var(--wf-text-muted);
    line-height: 1.45;
}

.msg .wf-ph-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--wf-primary);
    text-decoration: none;
}

.msg .wf-ph-link:hover {
    text-decoration: underline;
}

.msg .wf-ph-more {
    appearance: none;
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    background: var(--wf-primary);
    color: #fff;
    width: 100%;
    max-width: 280px;
    display: block;
    margin: 0 auto;
    box-shadow: 0 4px 14px var(--wf-primary-glow);
    touch-action: manipulation;
    text-decoration: none;
    text-align: center;
    box-sizing: border-box;
}

.msg a.wf-ph-more {
    text-decoration: none;
    color: #fff;
}

.msg .wf-ph-more__label {
    display: inline;
    pointer-events: none;
}

.msg .wf-ph-more:hover {
    background: var(--wf-primary-hover);
}

.msg .wf-ph-more:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Purchase history "View more" — loading state (no separate typing bubble) */
.msg .wf-ph-more.wf-ph-more--loading {
    opacity: 0.62;
    filter: blur(0.55px);
    cursor: wait;
    box-shadow: none;
    pointer-events: none;
}

[data-theme="dark"] .msg .wf-ph-more.wf-ph-more--loading {
    opacity: 0.58;
}

/* --- Order IDs compact list ------------------------------------------------- */
.msg .wf-oid-root {
    font-size: 14px;
    color: var(--wf-bot-text);
}

.msg .wf-oid-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
}

.msg .wf-oid-hint {
    font-size: 12px;
    color: var(--wf-text-muted);
    margin-bottom: 10px;
    line-height: 1.45;
}

.msg .wf-oid-scroll {
    max-height: min(40vh, 320px);
    overflow-y: auto;
}

.msg .wf-oid-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: baseline;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.02);
}

.msg .wf-oid-id {
    font-weight: 800;
    font-size: 15px;
    color: var(--wf-primary);
    flex: 0 0 auto;
}

.msg .wf-oid-meta {
    font-size: 12px;
    color: var(--wf-text-muted);
    line-height: 1.4;
    flex: 1 1 140px;
}

.msg .wf-oid-msg {
    font-size: 13px;
    line-height: 1.5;
}

/* --- Wishlist (API list + View more) ---------------------------------------- */
.msg .wf-wl-root,
.wishlist-page__list .wf-wl-root {
    --wf-wl-accent: #ff3d6a;
}

.msg .wf-wl-title,
.wishlist-page__list .wf-wl-title {
    font-size: 15px;
    margin-bottom: 10px;
    color: var(--wf-bot-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.msg .wf-wl-title::before,
.wishlist-page__list .wf-wl-title::before {
    content: "♥";
    color: var(--wf-wl-accent);
    font-size: 14px;
}

.msg .wf-wl-msg,
.wishlist-page__list .wf-wl-msg {
    font-size: 14px;
    line-height: 1.5;
    color: var(--wf-bot-text);
}

.msg .wf-wl-scroll,
.wishlist-page__list .wf-wl-scroll {
    max-height: min(52vh, 420px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    -webkit-overflow-scrolling: touch;
}

.wishlist-page__list .wf-wl-scroll {
    max-height: none;
}

.msg .wf-wl-tail,
.wishlist-page__list .wf-wl-tail {
    padding: 14px 4px 8px;
    margin-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
}

[data-theme="dark"] .msg .wf-wl-tail,
[data-theme="dark"] .wishlist-page__list .wf-wl-tail {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.msg .wf-wl-card,
.wishlist-page__list .wf-wl-card {
    border: 1px solid rgba(255, 61, 106, 0.14);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    background: linear-gradient(145deg, rgba(255, 61, 106, 0.04), rgba(251, 84, 4, 0.03));
}

[data-theme="dark"] .msg .wf-wl-card,
[data-theme="dark"] .wishlist-page__list .wf-wl-card {
    border-color: rgba(255, 120, 150, 0.2);
    background: rgba(255, 61, 106, 0.06);
}

.msg .wf-wl-card-row,
.wishlist-page__list .wf-wl-card-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.msg .wf-wl-img,
.wishlist-page__list .wf-wl-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 8px;
    background: #f5f5f5;
    flex-shrink: 0;
}

.msg .wf-wl-img--placeholder,
.wishlist-page__list .wf-wl-img--placeholder {
    background: linear-gradient(135deg, #ffe8ef, #fff5f0);
}

.msg .wf-wl-card-body,
.wishlist-page__list .wf-wl-card-body {
    flex: 1;
    min-width: 0;
}

.msg .wf-wl-name,
.wishlist-page__list .wf-wl-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.35;
    color: var(--wf-bot-text);
    margin-bottom: 6px;
}

.msg .wf-wl-meta,
.wishlist-page__list .wf-wl-meta {
    font-size: 12px;
    color: var(--wf-text-muted);
    line-height: 1.45;
}

.msg .wf-wl-price--sale,
.wishlist-page__list .wf-wl-price--sale {
    font-weight: 700;
    color: var(--wf-primary);
}

.msg .wf-wl-price--base,
.wishlist-page__list .wf-wl-price--base {
    text-decoration: line-through;
    opacity: 0.75;
    margin-left: 4px;
}

.msg .wf-wl-meta--stock,
.wishlist-page__list .wf-wl-meta--stock {
    font-size: 11px;
}

.msg .wf-wl-link,
.wishlist-page__list .wf-wl-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--wf-wl-accent);
    text-decoration: none;
}

.msg .wf-wl-link:hover,
.wishlist-page__list .wf-wl-link:hover {
    text-decoration: underline;
}

.msg .wf-wl-more,
.wishlist-page__list .wf-wl-more {
    appearance: none;
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, #ff3d6a, #fb5404);
    color: #fff;
    width: 100%;
    max-width: 280px;
    display: block;
    margin: 0 auto;
    box-shadow: 0 4px 14px rgba(255, 61, 106, 0.28);
    touch-action: manipulation;
}

.msg .wf-wl-more__label {
    display: inline;
    pointer-events: none;
}

.msg .wf-wl-more:hover,
.wishlist-page__list .wf-wl-more:hover {
    filter: brightness(1.06);
}

.msg .wf-wl-more.wf-wl-more--loading,
.wishlist-page__list .wf-wl-more.wf-wl-more--loading {
    opacity: 0.62;
    cursor: wait;
    pointer-events: none;
}

/* Standalone wishlist page */
.wishlist-page {
    width: min(480px, 100%);
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--wf-surface);
    color: var(--wf-text);
}

.wishlist-page__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--wf-border);
    background: var(--wf-header-bg);
}

.wishlist-page__back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--wf-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

.wishlist-page__back:hover {
    color: var(--wf-primary);
}

.wishlist-page__title {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.wishlist-page__body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.wishlist-page__list .wf-wl-root {
    color: var(--wf-text);
}

.wishlist-page__list .wf-wl-name,
.wishlist-page__list .wf-wl-msg,
.wishlist-page__list .wf-wl-title {
    color: var(--wf-text);
}

/* Order details + invoice download (chat bubble) */
.msg .wf-od-root {
    color: var(--wf-bot-text);
    line-height: 1.55;
    font-size: 14px;
    max-width: 100%;
}

.msg .wf-od-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--wf-bot-text);
}

.msg .wf-od-hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--wf-text-muted);
}

.msg .wf-od-card {
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 12px 14px;
}

[data-theme="dark"] .msg .wf-od-card {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--wf-border);
}

.msg .wf-od-meta {
    margin-top: 6px;
    font-size: 13px;
    color: var(--wf-bot-text);
    word-break: break-word;
}

.msg .wf-od-meta:first-child {
    margin-top: 0;
}

.msg .wf-od-img-wrap {
    margin-top: 8px;
}

.msg .wf-od-img {
    max-width: 120px;
    max-height: 120px;
    border-radius: 8px;
    border: 1px solid #eee;
    display: block;
}

.msg .wf-od-link {
    display: inline-block;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--wf-primary);
    text-decoration: none;
}

.msg .wf-od-link:hover {
    text-decoration: underline;
}

.msg .wf-od-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg .wf-od-section {
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 12px 14px;
}

[data-theme="dark"] .msg .wf-od-section {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--wf-border);
}

.msg .wf-od-section__head {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--wf-text-muted);
    margin-bottom: 10px;
}

.msg .wf-od-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
}

@media (max-width: 420px) {
    .msg .wf-od-grid {
        grid-template-columns: 1fr;
    }
}

.msg .wf-od-kv {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.msg .wf-od-kv__k {
    font-size: 11px;
    color: var(--wf-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.msg .wf-od-kv__v {
    font-size: 13px;
    font-weight: 600;
    color: var(--wf-bot-text);
    word-break: break-word;
}

.msg .wf-od-kv__v--status {
    color: var(--wf-primary);
}

.msg .wf-od-kv__v--total {
    color: #0d9488;
}

.msg .wf-od-address__name {
    font-size: 15px;
    font-weight: 700;
    color: var(--wf-bot-text);
    margin-bottom: 6px;
}

.msg .wf-od-address__line {
    font-size: 13px;
    line-height: 1.5;
    color: var(--wf-bot-text);
    margin-top: 4px;
}

.msg .wf-od-product-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.msg .wf-od-product-row__img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #eee;
    flex-shrink: 0;
}

.msg .wf-od-product-row__img--ph {
    background: linear-gradient(135deg, #f0f0f0, #e8e8e8);
}

.msg .wf-od-product-row__name {
    font-size: 14px;
    font-weight: 700;
    color: var(--wf-bot-text);
    margin-bottom: 4px;
}

.msg .wf-od-meta--price {
    color: var(--wf-primary);
    margin-top: 4px;
}

.msg .wf-od-root--invoice .wf-invoice-card {
    background: linear-gradient(145deg, #fff8f4 0%, #ffffff 55%, #f6faf9 100%);
    border: 1px solid rgba(251, 84, 4, 0.22);
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 8px 24px rgba(251, 84, 4, 0.12);
}

[data-theme="dark"] .msg .wf-od-root--invoice .wf-invoice-card {
    background: linear-gradient(145deg, #1a1512 0%, #141a19 100%);
    border-color: rgba(251, 84, 4, 0.35);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.msg .wf-invoice-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(251, 84, 4, 0.12);
    color: var(--wf-primary);
    margin-bottom: 10px;
}

.msg .wf-invoice-card__oid {
    margin-bottom: 4px !important;
}

.msg a.wf-invoice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
    padding: 13px 22px;
    min-height: 48px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--wf-primary) 0%, #ff6a28 100%);
    color: #fff !important;
    font-family: var(--wf-font);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none !important;
    cursor: pointer;
    box-shadow: 0 6px 18px var(--wf-primary-glow);
    transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.msg a.wf-invoice-btn .wf-invoice-btn__label {
    letter-spacing: 0.02em;
}

.msg a.wf-invoice-btn:hover {
    background: linear-gradient(135deg, var(--wf-primary-hover) 0%, #ff7a3d 100%);
    color: #fff !important;
    text-decoration: none !important;
    transform: translateY(-2px);
    box-shadow: 0 10px 22px var(--wf-primary-glow);
}

.msg a.wf-invoice-btn:active {
    transform: translateY(0);
}

@media (min-width: 480px) {
    .msg a.wf-invoice-btn {
        width: auto;
        min-width: 220px;
    }
}
