/* Customer support: account tabs, tickets and the live chat widget. Uses the tokens from store.css. */

.account-tabs { display: flex; gap: .4rem; margin: 1rem 0 .5rem; border-bottom: 1px solid var(--border); }
.account-tabs a { padding: .55rem 1rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.account-tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 500; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head small { color: var(--muted); font-size: .8em; font-weight: 400; }

.ticket-new, .status.ticket-new { background: #fff4e5; }
.status.ticket-open { background: #e3f2fd; }
.status.ticket-waitingoncustomer { background: #fdf2c4; }
.status.ticket-resolved { background: var(--tint); }
.status.ticket-closed { background: #eceef1; }

.ticket-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.ticket-thread { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: .75rem; }
.ticket-reply { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; background: var(--surface); }
.ticket-reply.from-staff { background: var(--tint); border-color: color-mix(in srgb, var(--primary) 25%, var(--border)); }
.ticket-reply.from-system { background: transparent; border-style: dashed; color: var(--muted); font-size: .9rem; padding: .5rem 1rem; }
.ticket-reply p { margin: .4rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ticket-reply-head { display: flex; justify-content: space-between; gap: 1rem; font-size: .85rem; color: var(--muted); }
.ticket-files { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.ticket-files a { border: 1px solid var(--border); border-radius: 10px; padding: .25rem .6rem; font-size: .85rem; background: #fff; }
.ticket-form { display: grid; gap: .8rem; max-width: 720px; }
.ticket-form label { display: grid; gap: .35rem; font-size: .9rem; }
.ticket-form select { font: inherit; padding: .55rem .6rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.ticket-form h2 { margin: 0; }
.ticket-actions { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 1rem; }
.order-support { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1.5rem; padding: .8rem 1rem; border: 1px dashed var(--border); border-radius: var(--radius); }

/* Live chat widget (js/chat.js) */
#st-chat { position: fixed; inset-inline-end: 16px; bottom: 16px; z-index: 60; }
.chat-launcher {
    position: relative; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
    background: var(--muted); box-shadow: var(--shadow); display: grid; place-items: center;
}
.chat-launcher.is-online { background: var(--primary); }
.chat-launcher.is-online::after {
    content: ""; position: absolute; top: 4px; inset-inline-start: 4px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--mint); border: 2px solid #fff;
}
.chat-badge {
    position: absolute; top: -4px; inset-inline-end: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
    background: var(--danger); color: #fff; font-size: .75rem; line-height: 22px; text-align: center;
}
.chat-panel {
    position: absolute; bottom: 68px; inset-inline-end: 0; width: min(370px, calc(100vw - 32px)); height: min(540px, calc(100vh - 110px));
    display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(6, 19, 15, .18); overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem; background: var(--primary-deep); color: #fff; }
.chat-title { flex: 1; display: grid; }
.chat-status { font-size: .78rem; opacity: .85; }
.chat-head button { font: inherit; background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .35); border-radius: 10px; cursor: pointer; padding: .2rem .55rem; font-size: .8rem; }
.chat-head .chat-x { border: 0; font-size: 1.4rem; line-height: 1; }
.chat-messages { flex: 1; overflow-y: auto; padding: .8rem; display: flex; flex-direction: column; gap: .5rem; background: #f7fbf9; }
.chat-msg { max-width: 85%; padding: .5rem .7rem; border-radius: 14px; background: #fff; border: 1px solid var(--border); font-size: .9rem; }
.chat-msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg time { display: block; font-size: .7rem; color: var(--muted); margin-top: .2rem; }
.chat-customer { align-self: flex-start; background: var(--tint); border-color: transparent; }
.chat-staff { align-self: flex-end; }
.chat-system { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: .78rem; text-align: center; }
.chat-author { display: block; font-size: .72rem; color: var(--primary); margin-bottom: .15rem; }
.chat-product { display: flex; gap: .6rem; align-items: center; color: var(--text); }
.chat-product img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; }
.chat-product span { display: grid; }
.chat-price { color: var(--primary); font-size: .85rem; }
.chat-notice { margin: 0 .8rem; padding: .45rem .7rem; border-radius: 10px; background: #fdecea; color: var(--danger); font-size: .85rem; }
.chat-form { display: flex; gap: .5rem; padding: .6rem; border-top: 1px solid var(--border); }
.chat-form[hidden], .chat-offline[hidden], .chat-restart[hidden], .chat-notice[hidden], .chat-end[hidden] { display: none; }
.chat-form textarea { resize: none; flex: 1; }
.chat-offline { display: grid; gap: .5rem; padding: .8rem; border-top: 1px solid var(--border); font-size: .88rem; }
.chat-offline p { margin: 0; color: var(--muted); }
.chat-ticket { font-size: .85rem; }
.chat-restart { margin: .6rem; }
/* مشاور هوشمند: its answers, the "talk to a person" bar and the typing dots. */
.chat-assistant { align-self: flex-end; background: #f1f7ff; border-color: #d6e6fb; }
.chat-assistant .chat-author { color: #2f6db5; }
.chat-assistant .chat-author::before { content: "✦ "; }
.chat-human { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem .8rem; background: #f1f7ff; border-top: 1px solid #d6e6fb; font-size: .8rem; color: var(--muted); }
.chat-human button { font: inherit; font-size: .8rem; border: 1px solid var(--primary); color: var(--primary); background: #fff; border-radius: 10px; padding: .2rem .6rem; cursor: pointer; white-space: nowrap; }
.chat-human[hidden], .chat-typing[hidden] { display: none; }
.chat-draft p::after { content: "▍"; color: #2f6db5; animation: chat-blink 1s steps(2, start) infinite; }
@keyframes chat-blink { to { visibility: hidden; } }
.chat-typing { align-self: flex-end; color: var(--muted); font-size: .8rem; padding: 0 .8rem .4rem; }
.chat-typing::after { content: "…"; display: inline-block; animation: chat-dots 1.2s steps(3, end) infinite; width: 1em; overflow: hidden; vertical-align: bottom; }
@keyframes chat-dots { from { width: 0; } to { width: 1em; } }
@media (max-width: 480px) {
    .chat-panel { position: fixed; inset: auto 8px 80px 8px; width: auto; height: calc(100vh - 100px); }
}
@media print { #st-chat { display: none; } }

/* A line where staff changed the visitor's cart. */
.chat-cart-change p { white-space: pre-line; }
.chat-cart-link { display: inline-block; margin-top: .35rem; font-weight: 700; text-decoration: underline; }

/* مشاوره آنلاین in the chat popup: topic chips, chat-or-call choice and the phone-call form (js/chat.js). */
.chat-messages[hidden], .chat-topics[hidden], .chat-choose[hidden], .chat-call[hidden] { display: none; }
.chat-topics { display: flex; flex-wrap: wrap; gap: .35rem; padding: .55rem .7rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.chat-chip { font: inherit; font-size: .8rem; padding: .25rem .65rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.chat-chip:hover, .chat-chip.is-active { border-color: var(--primary); color: var(--primary); background: var(--tint); }
.chat-chip-call { margin-inline-start: auto; }
.chat-choose, .chat-call { flex: 1; display: grid; align-content: start; gap: .6rem; padding: 1rem .9rem; overflow-y: auto; font-size: .9rem; }
.chat-choose-title { margin: 0 0 .2rem; font-weight: 700; }
.chat-call input, .chat-call select, .chat-call textarea, .chat-offline input, .chat-offline textarea {
    font: inherit; width: 100%; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
.chat-call textarea { resize: none; }
.chat-call-hint { color: var(--muted); }
.chat-back { justify-self: start; padding: 0; color: var(--muted); background: none; border: 0; font-size: .85rem; text-decoration: underline; }

/* The portal has more sections than fit a phone's width: the tabs scroll sideways. */
.account-tabs { overflow-x: auto; white-space: nowrap; scrollbar-width: thin; }
.account-tabs a { flex: none; display: inline-flex; align-items: center; gap: .3rem; }
