/* Recompensated chat panel.
 *
 * Mirrors the token-led, flat visual system used by the .lp-* homepage and
 * workspace-shell.css: 1px borders instead of shadows, one emerald accent, no
 * glass, no decorative glows. Dark-only — this codebase has no light theme.
 *
 * Every colour resolves through theme-tokens.css. The only literal colours are
 * inside @keyframes, per the project hex allowlist.
 *
 * Positioning of the rail itself (#chatbox_sidebar, .chatbox-launcher,
 * body.has-live-rail) still lives in layouts/app.blade.php — this file styles
 * the panel's contents only.
 */

/* ==========================================================================
 * 1. Shell
 * ========================================================================== */

.cx-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--bg-base);
    color: var(--text-body);
}

.cx-panel__header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 0 0 auto;
    min-height: 3rem;
    padding: 0 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
}

.cx-panel__title {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.cx-panel__online {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    padding: 0.22rem 0.5rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cx-panel__online-dot {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0.2rem var(--accent-dim);
}

.cx-panel__close {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.cx-panel__close:hover {
    border-color: var(--border-strong);
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.cx-panel__close:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

/* ==========================================================================
 * 2. Tabs — segmented control, same treatment as the .lp-* system
 * ========================================================================== */

.cx-tabs {
    display: flex;
    justify-content: flex-start;
    gap: 0.25rem;
    flex: 0 0 auto;
    margin: 0;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.cx-tabs__button {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.15rem;
    padding-inline: 0.3rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 750;
    white-space: nowrap;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.cx-tabs__button i {
    font-size: 0.78rem;
}

.cx-tabs__button:hover {
    border-color: var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
}

.cx-tabs__button.is-active {
    border-color: var(--accent-border);
    background: var(--accent-dim);
    color: var(--text-primary);
}

.cx-tabs__button--staff.is-active {
    border-color: var(--bonus);
    background: var(--bonus-dim);
}

.cx-tabs__button:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

/* ==========================================================================
 * 3. Panes
 * ========================================================================== */

.cx-pane {
    display: none;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 !important;
}

.cx-pane.is-active {
    display: flex;
}

/* ==========================================================================
 * 4. Staff tools — <details>, the same primitive as .lp-faq__item
 * ========================================================================== */

.cx-tools {
    flex: 0 0 auto;
    border-bottom: 1px solid var(--border-subtle);
}

.cx-tools__summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.1rem;
    padding: 0 0.75rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.cx-tools__summary::-webkit-details-marker {
    display: none;
}

.cx-tools__summary i {
    font-size: 0.6rem;
    transition: transform 160ms ease;
}

.cx-tools[open] .cx-tools__summary i {
    transform: rotate(180deg);
}

.cx-tools__summary:hover {
    color: var(--text-primary);
}

.cx-tools__body,
.cx-tools--member {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0 0.75rem 0.55rem;
}

.cx-tools--member {
    padding-top: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.cx-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 1.9rem;
    padding: 0 0.6rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.cx-tool-btn:hover {
    border-color: var(--border-strong);
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.cx-tool-btn:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

.cx-tool-btn--danger:hover {
    border-color: var(--danger);
    background: var(--danger-dim);
}

.cx-tool-btn--toggle:hover {
    border-color: var(--warning);
    background: var(--warning-dim);
}

.cx-tool-btn--info:hover,
.cx-tool-btn--info.is-active {
    border-color: var(--accent-border);
    background: var(--accent-dim);
    color: var(--text-primary);
}

.cx-tool-btn.is-muted {
    border-color: var(--warning);
    color: var(--warning);
}

/* ==========================================================================
 * 5. Notices and banners
 * ========================================================================== */

.cx-staff-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex: 0 0 auto;
    margin: 0.45rem 0.75rem 0;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--bonus);
    border-radius: var(--radius-sm);
    background: var(--bonus-dim);
    color: var(--text-body);
    font-size: 0.72rem;
    line-height: 1.45;
}

.cx-staff-notice[hidden] {
    display: none;
}

.cx-staff-notice strong {
    color: var(--text-primary);
}

.cx-banner {
    flex: 0 0 auto;
    margin: 0 0.85rem 0.6rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-body);
    font-size: 0.74rem;
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
}

.cx-banner.is-success {
    border-color: var(--accent-border);
    background: var(--accent-dim);
    color: var(--text-primary);
}

.cx-banner.is-warning {
    border-color: var(--warning);
    background: var(--warning-dim);
    color: var(--text-primary);
}

.cx-banner.is-error {
    border-color: var(--danger);
    background: var(--danger-dim);
    color: var(--text-primary);
}

.cx-empty {
    padding: 1.6rem 1rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.55;
    text-align: center;
}

.cx-system {
    margin: 0.4rem 0.2rem;
    padding: 0.5rem 0.7rem;
    border: 1px dashed var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.74rem;
    line-height: 1.5;
}

/* ==========================================================================
 * 6. Message list
 * ========================================================================== */

.cx-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.55rem 0.75rem 0.85rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.cx-list::-webkit-scrollbar {
    width: 6px;
}

.cx-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--border-strong);
}

.cx-msg {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.65rem;
    padding: 0.62rem 0.58rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--bg-surface) 58%, transparent);
    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.cx-msg + .cx-msg {
    margin-top: 0.5rem;
}

.cx-msg:hover {
    border-color: var(--border-strong);
    background: var(--bg-surface-hover);
    transform: translateY(-1px);
}

.cx-msg__avatar {
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-surface);
}

.cx-msg__body {
    min-width: 0;
}

.cx-msg__topline {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.cx-msg__name {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
    flex-wrap: wrap;
}

.cx-msg__name b {
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 750;
}

.cx-msg__name b.admin {
    color: var(--chat-admin-name);
}

.cx-msg__time {
    margin-left: auto;
    color: var(--text-faint);
    font-size: 0.66rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cx-msg__text {
    margin: 0.3rem 0 0;
    color: var(--text-body);
    font-size: 0.8rem;
    line-height: 1.58;
    overflow-wrap: anywhere;
}

.cx-msg__media {
    display: inline-block;
    margin-top: 0.35rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.cx-msg__media img {
    display: block;
    max-width: 100%;
    max-height: 11rem;
}

.cx-msg__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.05rem 0.35rem;
    border-radius: var(--radius-sm);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.cx-msg__badge--announcement {
    border: 1px solid var(--warning);
    background: var(--warning-dim);
    color: var(--warning);
}

.cx-msg__badge--staff {
    border: 1px solid var(--bonus);
    background: var(--bonus-dim);
    color: var(--bonus);
}

.cx-msg--announcement {
    border-color: color-mix(in srgb, var(--warning) 34%, transparent);
    background: var(--warning-dim);
    box-shadow: inset 3px 0 0 var(--warning);
}

.cx-msg--staff {
    border-color: color-mix(in srgb, var(--bonus) 32%, transparent);
    box-shadow: inset 3px 0 0 var(--bonus);
}

.cx-msg--mention-you {
    border-color: var(--accent-border);
    background: var(--accent-dim);
    box-shadow: inset 3px 0 0 var(--accent), var(--shadow-sm);
}

/* Moderation actions stay out of the way until the message is hovered. */
.cx-msg__actions {
    display: inline-flex;
    gap: 0.15rem;
    opacity: 0;
    transition: opacity 120ms ease;
}

.cx-msg:hover .cx-msg__actions,
.cx-msg:focus-within .cx-msg__actions {
    opacity: 1;
}

/* Touch devices have no hover, so hover-only controls would be unreachable. */
@media (hover: none) {
    .cx-msg__actions {
        opacity: 1;
    }
}

.cx-msg__action {
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-card-end);
    color: var(--text-muted);
    font-size: 0.62rem;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.cx-msg__action:hover {
    border-color: var(--danger);
    background: var(--danger-dim);
    color: var(--text-primary);
}

.cx-msg__action:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

/* ==========================================================================
 * 7. Composer
 * ========================================================================== */

.cx-composer-wrap {
    position: relative;
    flex: 0 0 auto;
    padding: 0 0.75rem 0.75rem;
}

.cx-composer {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    transition: border-color 140ms ease;
}

.cx-composer:focus-within {
    border-color: var(--accent-border);
}

.cx-composer.is-locked {
    opacity: 0.55;
    pointer-events: none;
}

.cx-composer__tool {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 1.9rem;
    height: 1.9rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.cx-composer__tool--gif {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.cx-composer__tool:hover,
.cx-composer__tool.is-active {
    border-color: var(--border-subtle);
    background: var(--bg-surface-hover);
    color: var(--accent);
}

.cx-composer__tool:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

.cx-composer__field {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.35rem 0.35rem;
    border: 0;
    background: none;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: inherit;
}

.cx-composer__field::placeholder {
    color: var(--text-faint);
}

.cx-composer__field:focus {
    outline: none;
}

.cx-composer__field:disabled {
    cursor: not-allowed;
}

.cx-composer__chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.64rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cx-composer__chip[hidden] {
    display: none;
}

.cx-composer__send {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--bg-base);
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 140ms ease, opacity 140ms ease;
}

.cx-composer__send:hover:not(:disabled) {
    background: var(--accent-hover);
}

.cx-composer__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cx-composer__send:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

/* The FAQ bot composer reuses the same field and send button. */
.faq-bot__composer {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

/* ==========================================================================
 * 8. Slash command menu
 * ========================================================================== */

.cx-cmd {
    position: absolute;
    left: 0.85rem;
    right: 0.85rem;
    bottom: calc(100% - 0.4rem);
    z-index: 20;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-card-end);
    box-shadow: var(--shadow-lg);
}

.cx-cmd[hidden] {
    display: none;
}

.cx-cmd__list {
    max-height: 15rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.cx-cmd__item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.1rem 0.5rem;
    width: 100%;
    padding: 0.45rem 0.7rem;
    border: 0;
    border-bottom: 1px solid var(--border-subtle);
    background: none;
    text-align: left;
    cursor: pointer;
    transition: background 120ms ease;
}

.cx-cmd__item:last-child {
    border-bottom: 0;
}

.cx-cmd__item:hover,
.cx-cmd__item.is-active {
    background: var(--accent-dim);
}

.cx-cmd__name {
    color: var(--accent);
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 700;
}

.cx-cmd__args {
    color: var(--text-faint);
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.68rem;
    align-self: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cx-cmd__desc {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 0.7rem;
    line-height: 1.4;
}

.cx-cmd__empty {
    margin: 0;
    padding: 0.7rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-align: center;
}

.cx-cmd__hint {
    margin: 0;
    padding: 0.35rem 0.7rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-faint);
    font-size: 0.62rem;
    letter-spacing: 0.02em;
}

/* ==========================================================================
 * 9. States
 * ========================================================================== */

.cx-panel[data-state="muted"] .cx-composer,
.cx-panel[data-state="blocked"] .cx-composer,
.cx-panel[data-state="disabled"] .cx-composer {
    border-color: var(--border-subtle);
    background: var(--bg-base);
}

.cx-panel[data-state="muted"] .cx-panel__title::after {
    content: "";
    display: inline-block;
    width: 0.4rem;
    height: 0.4rem;
    margin-left: 0.4rem;
    border-radius: 50%;
    background: var(--warning);
    vertical-align: middle;
}

/* VIP platinum animated username, carried over from the old inline block. */
.chat-name--rainbow {
    background: linear-gradient(90deg, #ff4dcb, #ff9a3c, #f5e65b, #34f0b5, #5b8cff, #a45bff, #ff4dcb);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    font-weight: 800;
    animation: chatRainbow 6s linear infinite;
}

@keyframes chatRainbow {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

/* ==========================================================================
 * 10. Mobile — full-height sheet, not a floating drawer
 * ========================================================================== */

@media (max-width: 1180px) {
    #chatbox_sidebar.is-open .cx-panel {
        height: 100%;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .cx-panel__header,
    .cx-tabs,
    .cx-tools,
    .cx-composer-wrap {
        flex: 0 0 auto;
    }

    .cx-list {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Bottom sheet so the menu clears the on-screen keyboard. */
    .cx-cmd {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        border-bottom: 0;
    }

    .cx-cmd__list {
        max-height: 40vh;
    }

    /* Comfortable touch targets. */
    .cx-cmd__item {
        padding-block: 0.6rem;
    }

    .cx-msg__action {
        width: 1.75rem;
        height: 1.75rem;
    }

    .cx-composer__send {
        width: 2.25rem;
        height: 2.25rem;
    }

    /* iOS zooms the page when a focused input is under 16px. */
    .cx-composer__field {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cx-tabs__button,
    .cx-tool-btn,
    .cx-msg,
    .cx-msg__actions,
    .cx-msg__action,
    .cx-composer,
    .cx-composer__tool,
    .cx-composer__send,
    .cx-cmd__item,
    .cx-tools__summary i {
        transition: none;
    }

    .chat-name--rainbow {
        animation: none;
    }
}

/* hCaptcha inside the rain card. The rail is narrow, so the widget is rendered
   at data-size="compact" (164x144) rather than the 303px-wide default. */
.chat-rain__captcha {
    margin-top: 0.5rem;
    display: flex;
    justify-content: center;
}
