/* ══════════════════════════════════════════════════════════
   CHAT HUB — full redesign on project theme tokens
   Depends on: --saffron, --saffron-lt, --saffron-mid, --saffron-dk,
   --maroon, --gold, --slate*, --bg, --surface, --border*, --radius*,
   --shadow*, --grad-primary, --success, --error, --warn
══════════════════════════════════════════════════════════ */

/* ── Section head profile strip ───────────────────────── */
.chat-header-profile {
    font-size: 12.5px;
    color: var(--slate-mid);
    line-height: 1.4;
}

.chat-header-profile .pd-sub {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--slate-lt);
}

.chat-header-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--grad-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(249, 115, 22, .25);
}

.chat-header-name {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--slate);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-switch-btn {
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-soft);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--slate-mid);
    cursor: pointer;
    flex-shrink: 0;
    transition: all .15s;
}

.chat-switch-btn:hover {
    background: var(--saffron-lt);
    border-color: var(--saffron-mid);
    color: var(--saffron-dk);
}

.chat-wallet-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    color: var(--gold);
    background: var(--gold-lt);
    border: 1px solid #fde68a;
    padding: 3px 9px 3px 7px;
    border-radius: 99px;
    margin-left: auto;
    flex-shrink: 0;
}

.chat-wallet-badge i {
    font-size: 10px;
}

/* ── Section body → flex container once chat is active ── */
#chat-section-body {
    position: relative;
    height: 100%;
}

#chat-section-body.chat-active {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: none;

    /* background-image: url("../images/chat_bg.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat; */
}

#chat-main-view {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

#chat-section-body.chat-active #chat-main-view {
    display: flex !important;
}

/* ── No-profile empty state ─────────────────────────────── */
.no-profile-note {
    max-width: 320px;
    margin: 48px auto;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 24px;
    box-shadow: var(--shadow);
}

.no-profile-note i {
    font-size: 30px;
    color: var(--saffron);
    background: var(--saffron-lt);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
}

.no-profile-note p {
    font-size: 13.5px;
    color: var(--slate-mid);
    margin: 0 0 16px;
}

.no-profile-note button {
    background: var(--grad-primary);
    color: #fff;
    border: none;
    font-size: 13px;
    font-weight: 700;
    padding: 10px 22px;
    border-radius: 99px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(249, 115, 22, .3);
    transition: transform .15s;
}

.no-profile-note button:hover {
    transform: translateY(-1px);
}

/* ══════════════════════════════════════════════════════════
   MESSAGE LIST
══════════════════════════════════════════════════════════ */
.chat-msgs {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    margin: 0;
    /* padding: 16px 14px 10px !important; */
    -webkit-overflow-scrolling: touch;
}

.chat-msgs::-webkit-scrollbar { width: 4px; }
.chat-msgs::-webkit-scrollbar-thumb {
    background: var(--saffron-mid);
    border-radius: 99px;
}

/* ── Welcome / empty hero shown before first message ──── */
.chat-hero {
    max-width: 380px;
    margin: 10px auto 18px;
    text-align: center;
    padding: 26px 20px 22px;
    animation: fadeUp .3s ease;
}

.chat-hero-orb {
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--grad-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(249, 115, 22, .3);
}

.chat-hero-orb img { width: 30px; filter: brightness(0) invert(1); }

.chat-hero h3 {
    font-size: 16px;
    font-weight: 800;
    color: var(--slate);
    margin: 0 0 6px;
}

.chat-hero p {
    font-size: 12.5px;
    color: var(--slate-mid);
    margin: 0 0 18px;
    line-height: 1.5;
}

.chat-suggest-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-suggest-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--slate-mid);
    cursor: pointer;
    transition: all .15s;
}

.chat-suggest-chip i {
    color: var(--saffron);
    font-size: 13px;
    width: 16px;
    flex-shrink: 0;
}

.chat-suggest-chip:hover {
    border-color: var(--saffron-mid);
    background: var(--saffron-lt);
    color: var(--slate);
    transform: translateX(2px);
}

/* ── Date divider ──────────────────────────────────────── */
.chat-date-divider {
    align-self: center;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--slate-mid);
    background: var(--border-soft);
    padding: 4px 12px;
    border-radius: 99px;
    margin: 6px 0 16px;
}

/* ── Message bubbles ──────────────────────────────────── */
.msg-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 86%;
    animation: fadeUp .25s ease;
    margin-bottom: 14px;
}

.msg-wrap.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-wrap.ai {
    align-self: flex-start;
}

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}

.msg-avatar img.avatar-logo {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.msg-wrap.user .msg-avatar {
    background: var(--grad-primary);
    border: none;
}

.msg-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.bubble {
    padding: 11px 14px;
    font-size: 13.5px;
    line-height: 1.6;
    word-break: break-word;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(30, 41, 59, .04);
}

.bubble p { margin: 0 0 8px 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 6px 0; padding-left: 20px; }
.bubble strong { font-weight: 700; }

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

.msg-wrap.ai .bubble {
    background: var(--surface);
    border: 1px solid var(--saffron);
    color: var(--slate);
    border-bottom-left-radius: 5px;
}

.msg-time {
    font-size: 10px;
    color: var(--slate-lt);
    padding: 4px 4px 0;
}

.msg-wrap.user .msg-time { text-align: right; }

/* ── Typing indicator ──────────────────────────────────── */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 13px 16px;
    height: 18px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--saffron-mid);
    animation: bob 1.4s infinite ease-in-out;
}

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

@keyframes bob {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

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

/* ── Scroll-to-bottom FAB ──────────────────────────────── */
.chat-scroll-fab {
    position: absolute;
    right: 16px;
    bottom: 90px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--saffron-dk);
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    z-index: 5;
    transition: transform .15s;
}

.chat-scroll-fab.visible { display: flex; }
.chat-scroll-fab:hover { transform: translateY(-2px); }

/* ══════════════════════════════════════════════════════════
   INPUT BAR
══════════════════════════════════════════════════════════ */
.chat-input-bar {
    flex-shrink: 0;
    position: relative;
}

.chat-quick-row {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 0 2px 8px;
    scrollbar-width: none;
}

.chat-quick-row::-webkit-scrollbar { display: none; }

.chat-quick-pill {
    flex-shrink: 0;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--saffron-dk);
    background: var(--saffron-lt);
    border: 1px solid var(--saffron-mid);
    padding: 6px 12px;
    border-radius: 99px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
}

.chat-quick-pill:hover {
    background: var(--saffron-mid);
    color: var(--maroon);
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 40px;
    padding: 8px 8px 8px 16px;
    transition: border-color .2s, box-shadow .2s;
}

.chat-input-row:focus-within {
    border-color: var(--saffron);
}

.chat-input-row textarea {
    flex: 1;
    resize: none;
    max-height: 100px;
    border: none;
    background: transparent;
    color: var(--slate);
    font-size: 13.5px;
    line-height: 1.5;
    padding: 6px 0;
    outline: none;
    font-family: inherit;
}

.chat-input-row textarea::placeholder { color: var(--slate-lt); }
.chat-input-row textarea:disabled { color: var(--slate-lt); }

.chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--grad-primary);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all .2s ease;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: .4;
    transform: none;
    box-shadow: none;
    cursor: default;
}

.chat-input-hint {
    text-align: center;
    font-size: 10px;
    color: var(--slate-lt);
    margin-top: 8px;
}

@media (max-width: 479.98px) {
    .chat-header-name { font-size: 12.5px; }
    .chat-header-profile .pd-sub { font-size: 10px; }
    .msg-wrap { max-width: 92%; }
}

/* ══════════════════════════════════════════════════════════
   PROCESSING MODAL
══════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 23, 18, .45);
    backdrop-filter: blur(2px);
    z-index: 1100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.visible { display: flex; }

.modal-box {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    animation: fadeUp .25s ease;
}

.modal-head {
    background: var(--saffron-lt);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 700;
    color: var(--slate);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-head i { color: var(--saffron); }

.modal-body-inner {
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.proc-step {
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: .4;
    transition: opacity .3s;
}

.proc-step.active, .proc-step.done { opacity: 1; }

.proc-step-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.proc-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--slate-mid);
    flex-shrink: 0;
    transition: background .3s, color .3s;
}

.proc-step.active .proc-icon { background: var(--saffron-lt); color: var(--saffron); }
.proc-step.done .proc-icon { background: #dcfce7; color: var(--success); }
.proc-step.error .proc-icon { background: #fee2e2; color: var(--error); }

.proc-label { font-size: 13px; font-weight: 700; color: var(--slate); }
.proc-sub { font-size: 11.5px; color: var(--slate-lt); margin-top: 2px; }

.proc-bar-wrap {
    height: 4px;
    background: var(--border-soft);
    border-radius: 99px;
    overflow: hidden;
    margin-left: 40px;
}

.proc-bar {
    height: 100%;
    border-radius: 99px;
    background: var(--grad-primary);
    transition: width .4s ease;
}

.proc-final {
    text-align: center;
    font-size: 12.5px;
    font-weight: 600;
    min-height: 18px;
}



/* ===== Chat Menu ===== */

.chat-menu-wrap{
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: auto;
}

.chat-menu-btn{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted, #888);
    font-size: 1rem;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}

.chat-menu-btn:hover{
    background: var(--bg-hover, #f5f5f7);
    color: var(--text-primary, #222);
}

.chat-menu-dropdown{
    position: absolute;
    top: calc(100% + 8px);
    right: 0;

    min-width: 150px;
    padding: 6px 0;

    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, #e5e5e5);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.12);

    display: none;
    overflow: hidden;
    z-index: 998;
}

.chat-menu-dropdown.visible{
    display: block;
}

.chat-menu-dropdown button{
    display: flex;
    align-items: center;
    gap: 10px;

    width: 100%;
    padding: 10px 16px;

    border: none;
    background: transparent;

    color: var(--text-primary, #222);
    font-size: .9rem;
    text-align: left;
    cursor: pointer;

    transition: background .15s ease;
}

.chat-menu-dropdown button:hover{
    background: var(--bg-hover, #f5f5f7);
}

.chat-menu-dropdown button i{
    width: 18px;
    text-align: center;
    color: var(--text-muted, #888);
    font-size: .9rem;
    flex-shrink: 0;
}