/* TiviGlass support system styles.
   Loaded on every page by components.js (for the floating assistant widget) and
   used by the portal Support tab, the admin Support inbox, and the help center.
   Everything resolves through the shared design tokens in tokens.css so it
   tracks light/dark themes automatically. */

/* ===== Floating virtual-assistant widget ===== */

.tg-assistant {
    position: fixed;
    right: clamp(12px, 3vw, 28px);
    bottom: clamp(12px, 3vw, 28px);
    z-index: 1200;
    font-family: inherit;
}

.tg-assistant-launcher {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    border: none;
    cursor: pointer;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-pill);
    background: var(--brand-gradient);
    color: #fff;
    font-size: var(--fs-sm);
    font-weight: 600;
    box-shadow: var(--shadow-strong);
    transition:
        transform 140ms ease,
        box-shadow 140ms ease,
        opacity 140ms ease;
}

.tg-assistant-launcher:hover {
    transform: translateY(-1px);
}

.tg-assistant-launcher svg {
    width: 20px;
    height: 20px;
}

.tg-assistant-launcher-label {
    white-space: nowrap;
}

.tg-assistant.is-open .tg-assistant-launcher {
    opacity: 0;
    pointer-events: none;
}

.tg-assistant-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: min(380px, calc(100vw - 24px));
    height: min(560px, calc(100vh - 48px));
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-strong);
}

.tg-assistant.is-open .tg-assistant-panel {
    display: flex;
}

.tg-assistant-head {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--brand-gradient);
    color: #fff;
}

.tg-assistant-head-title {
    font-weight: 700;
    font-size: var(--fs-sm);
    line-height: 1.2;
}

.tg-assistant-head-sub {
    font-size: var(--fs-xs);
    opacity: 0.85;
}

.tg-assistant-close {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.16);
    border: none;
    color: #fff;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tg-assistant-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.tg-assistant-log {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    background: var(--surface-soft);
}

.tg-assistant-msg {
    max-width: 85%;
    padding: var(--sp-3);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.tg-assistant-msg--bot {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
}

.tg-assistant-msg--user {
    align-self: flex-end;
    background: var(--accent);
    color: var(--accent-ink);
}

.tg-assistant-sources {
    align-self: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    max-width: 85%;
}

.tg-assistant-source {
    font-size: var(--fs-xs);
    text-decoration: none;
    color: var(--accent-link, var(--accent));
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    padding: 2px var(--sp-2);
    background: var(--surface);
}

.tg-assistant-escalate {
    align-self: flex-start;
}

.tg-assistant-ticket {
    align-self: flex-start;
    max-width: 85%;
    font-size: var(--fs-xs);
    color: var(--text-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md, 8px);
    padding: var(--sp-2);
    background: var(--surface);
}

.tg-assistant-feedback {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-soft);
}

.tg-assistant-feedback-btn {
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface);
    cursor: pointer;
    line-height: 1;
    padding: 2px var(--sp-2);
    font-size: var(--fs-sm);
}

.tg-assistant-feedback-btn:hover,
.tg-assistant-feedback-btn:focus-visible {
    border-color: var(--accent);
}

.tg-assistant-typing {
    align-self: flex-start;
    color: var(--text-soft);
    font-size: var(--fs-xs);
    font-style: italic;
}

.tg-assistant-foot {
    border-top: 1px solid var(--line);
    padding: var(--sp-3);
    background: var(--surface);
}

.tg-assistant-form {
    display: flex;
    gap: var(--sp-2);
    align-items: flex-end;
}

.tg-assistant-input {
    flex: 1;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
}

.tg-assistant-input:focus {
    outline: none;
    border-color: var(--accent);
}

.tg-assistant-send {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--accent);
    color: var(--accent-ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tg-assistant-send:disabled {
    opacity: 0.5;
    cursor: default;
}

.tg-assistant-disclaimer {
    margin: var(--sp-2) 0 0;
    font-size: var(--fs-xs);
    color: var(--text-faint);
    text-align: center;
}

/* ===== Shared support pieces (portal + admin + help) ===== */

.support-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 2px var(--sp-2);
    border-radius: var(--radius-pill);
    border: 1px solid var(--line);
    text-transform: capitalize;
}

.support-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-faint);
}

.support-status--open::before,
.support-status--new::before {
    background: var(--brand-2);
}

.support-status--in_progress::before,
.support-status--triaged::before,
.support-status--planned::before {
    background: var(--warning);
}

.support-status--resolved::before,
.support-status--done::before {
    background: var(--success);
}

.support-status--closed::before,
.support-status--declined::before {
    background: var(--text-faint);
}

.support-ticket-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    text-align: left;
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--sp-3) var(--sp-4);
    color: var(--text);
}

.support-ticket-row:hover {
    border-color: var(--accent);
}

/* A ticket with an unread support reply: highlighted row + leading dot + chip. */
.support-ticket-row.is-unread {
    border-color: var(--accent-strong, var(--accent));
    background: var(--accent-soft, var(--surface));
}

.support-unread-dot {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--accent);
}

.support-unread-chip {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-bright, #fff);
    font-size: var(--fs-xs);
    font-weight: 700;
    white-space: nowrap;
}

.support-ticket-row-main {
    min-width: 0;
    flex: 1;
}

.support-ticket-row.is-unread .support-ticket-subject {
    color: var(--text);
}

.support-ticket-subject {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.support-ticket-meta {
    font-size: var(--fs-xs);
    color: var(--text-soft);
}

.support-thread {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin: var(--sp-4) 0;
    max-height: 420px;
    overflow-y: auto;
}

.support-msg {
    padding: var(--sp-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--surface-soft);
    font-size: var(--fs-sm);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 88%;
}

.support-msg--agent {
    align-self: flex-end;
    background: var(--accent-soft, var(--surface));
    border-color: var(--accent-strong, var(--line));
}

.support-msg-author {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 4px;
}

.support-feedback-row {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface);
}

.support-feedback-row-head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
    flex-wrap: wrap;
}

.support-rating {
    color: var(--brand-3);
    letter-spacing: 1px;
}

/* ===== Help center ===== */

.help-search {
    display: flex;
    gap: var(--sp-2);
    margin-bottom: var(--sp-6);
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--sp-4);
}

.help-card-link {
    display: block;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: var(--sp-5);
    background: var(--surface);
    transition: border-color 140ms ease, transform 140ms ease;
}

.help-card-link:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.help-card-cat {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent-link, var(--accent));
    font-weight: 600;
}

.help-card-title {
    font-size: var(--fs-md);
    font-weight: 700;
    margin: var(--sp-2) 0;
}

.help-card-excerpt {
    color: var(--text-soft);
    font-size: var(--fs-sm);
    line-height: 1.5;
}

.help-article {
    max-width: 760px;
    margin: 0 auto;
}

.help-article h1 {
    margin-bottom: var(--sp-3);
}

.help-article-body {
    font-size: var(--fs-base);
    line-height: 1.7;
    white-space: pre-wrap;
}

.help-empty {
    color: var(--text-soft);
    padding: var(--sp-8) 0;
    text-align: center;
}
