/* ============================================================
   VANTORA: CUSTOMER ASSISTANT (the public chat page)
   Uses the tokens from vantora.css, so it follows light and dark.
   Text sizes are set for people reading on a phone: 15px messages,
   16px input (stops iOS zooming in on focus).
   ============================================================ */

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
    color: var(--text);
}

/* ---------- Card ---------- */
.assistant-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(860px, 100%);
    height: min(840px, 92vh);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
}

/* ---------- Header ---------- */
.assistant-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 68px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.assistant-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: var(--text);
}

.assistant-brand .vt-mark {
    width: 32px;
    height: 32px;
}

.assistant-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.24em;
    line-height: 1.1;
    color: var(--text);
}

.assistant-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-pill,
.secure-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-chip);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.live-pill {
    border-color: var(--green-border);
    background: var(--green-soft);
    color: var(--green-strong);
}

.live-pill i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}

/* ---------- Progress ---------- */
.progress-wrap {
    padding: 12px 20px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.progress-wrap > div:first-child {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

#progressPercent {
    font-variant-numeric: tabular-nums;
    color: var(--text-soft);
}

.progress-track {
    height: 3px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--surface-sunken);
}

.progress-track i {
    display: block;
    width: 8%;
    height: 100%;
    border-radius: 99px;
    background: var(--ink);
    transition: width 0.3s ease;
}

/* ---------- Conversation ---------- */
.chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px 22px;
    overflow-y: auto;
    background: var(--surface-soft);
    scroll-behavior: smooth;
}

.message-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: messageRise 0.18s ease-out;
}

.message-row.user {
    justify-content: flex-end;
}

/* the box holding a bubble and its small label: this is what gets the width limit,
   so short replies stay on one line instead of breaking letter by letter */
.message-row > div:not(.message-avatar) {
    min-width: 0;
    max-width: min(80%, 560px);
}

.message-row.user > div:not(.message-avatar) {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.bubble {
    display: inline-block;
    max-width: 100%;
    padding: 12px 15px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.message-row.ai .bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text);
}

.message-row.user .bubble {
    background: var(--ink);
    border: 1px solid var(--ink);
    border-bottom-right-radius: 4px;
    color: var(--on-ink);
}

/* the assistant's avatar is the Vantora star (the script writes "AI" inside; it is replaced) */
.message-avatar {
    position: relative;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-dark);
    border-radius: 9px;
    background: var(--surface);
    color: transparent;
    font-size: 0;
}

.message-avatar::before {
    content: "";
    position: absolute;
    inset: 7px;
    background: var(--text);
    -webkit-mask: url("/brand/vantora-star.svg") center / contain no-repeat;
    mask: url("/brand/vantora-star.svg") center / contain no-repeat;
}

.time {
    margin: 4px 4px 0;
    color: var(--muted);
    font-size: 12px;
}

.message-row.user .time {
    text-align: right;
}

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 15px 16px;
}

.typing-bubble i {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--faint);
    animation: typingBounce 1s infinite ease-in-out;
}

.typing-bubble i:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-bubble i:nth-child(3) {
    animation-delay: 0.3s;
}

/* ---------- Composer ---------- */
.composer {
    padding: 14px 18px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.quick-replies:empty {
    display: none;
}

.quick-reply {
    padding: 8px 14px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-chip);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.quick-reply:hover {
    border-color: var(--ink);
    background: var(--surface-soft);
}

.quick-reply:active {
    background: var(--surface-sunken);
}

.input-row {
    display: flex;
    gap: 8px;
}

.input-row input {
    flex: 1;
    min-width: 0;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-row input::placeholder {
    color: var(--faint);
}

.input-row input:hover {
    border-color: var(--border-hover);
}

.input-row input:focus {
    border-color: var(--accent-focus);
    box-shadow: var(--focus-ring);
}

.input-row button {
    height: 46px;
    padding: 0 20px;
    border: 1px solid var(--ink);
    border-radius: 12px;
    background: var(--ink);
    color: var(--on-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.input-row button span {
    margin-left: 4px;
}

.input-row button:hover {
    opacity: 0.88;
}

.input-row button:active {
    opacity: 0.8;
}

.input-row button:disabled,
.input-row input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.composer-note {
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

/* ---------- Finished ---------- */
.success-card {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--green-border);
    background: var(--green-soft);
    color: var(--text);
}

.success-card.show {
    display: flex;
    animation: successIn 0.2s ease-out;
}

.success-icon {
    display: grid;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 50%;
    background: var(--green);
    color: var(--on-ink);
    font-weight: 700;
}

.success-card strong {
    display: block;
    font-size: 14px;
}

.success-card p {
    margin: 2px 0 0;
    color: var(--text-soft);
    font-size: 13px;
}

.success-card button {
    margin-left: auto;
    padding: 9px 14px;
    border: 1px solid var(--border-dark);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.success-card button:hover {
    border-color: var(--border-hover);
    background: var(--surface-soft);
}

/* ---------- Scrollbar ---------- */
.chat::-webkit-scrollbar {
    width: 8px;
}

.chat::-webkit-scrollbar-track {
    background: transparent;
}

.chat::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: var(--scroll);
}

.chat::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-hover);
}

/* ---------- Motion (only where it shows something changing) ---------- */
@keyframes messageRise {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

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

@keyframes successIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---------- Phone ---------- */
@media (max-width: 700px) {
    body {
        padding: 0;
    }

    .assistant-shell {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .chat {
        padding: 18px 14px;
    }

    .message-row > div:not(.message-avatar) {
        max-width: 88%;
    }
}

@media (max-width: 420px) {
    .header-right {
        display: none;
    }

    .assistant-header {
        justify-content: flex-start;
    }
}
