﻿/* "Chat to register" assistant of the pair-registration page: Views/Tournament/_RegistrationAgentV2.cshtml (see Docs/features/pair-registration.md).
   Floating launcher + docked chat panel (bottom sheet on mobile). Theme tokens only (theme-v2.css) - no literal colours.
   --rag-lift is set by registration-agent-v2.js to the height of the mobile sticky submit bar (.rpv-submit) so the launcher never covers it. */

.rag { --rag-lift: 0px; }

.rag-launch {
    position: fixed;
    right: 16px;
    bottom: calc(var(--bottom-nav-offset, 0px) + var(--rag-lift) + 16px + env(safe-area-inset-bottom, 0px));
    z-index: var(--z-dropdown);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-size: var(--font-size-md);
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
}
.rag-launch:hover { background: var(--color-primary-hover); }
.rag-launch:active { background: var(--color-primary-active); }
.rag-launch:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.rag.is-open .rag-launch { display: none; }

.rag-panel {
    position: fixed;
    right: 16px;
    bottom: calc(var(--bottom-nav-offset, 0px) + 16px + env(safe-area-inset-bottom, 0px));
    z-index: var(--z-dropdown);
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-overlay);
}
.rag-panel[hidden] { display: none; }

/* ---- header ---- */
.rag-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-secondary);
}
.rag-head__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-circle);
    background: var(--color-primary);
    color: var(--color-text-inverse);
}
.rag-head__text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.rag-head__text strong { font-size: var(--font-size-lg); color: var(--color-text-primary); }
.rag-head__text small { font-size: var(--font-size-sm); color: var(--color-text-muted); }
.rag-close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--radius-circle);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--font-size-lg);
    cursor: pointer;
}
.rag-close:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.rag-close:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* ---- conversation ---- */
.rag-log {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    padding: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.rag-msg {
    max-width: 88%;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-md);
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.rag-msg--bot { align-self: flex-start; background: var(--color-surface-secondary); color: var(--color-text-primary); border-bottom-left-radius: var(--radius-xs); }
.rag-msg--user { align-self: flex-end; background: var(--color-primary); border-color: var(--color-primary); color: var(--color-text-inverse); border-bottom-right-radius: var(--radius-xs); }
.rag-msg--wait { color: var(--color-text-muted); font-style: italic; }
.rag-msg--error { border-color: var(--color-danger); color: var(--color-danger); }
.rag-msg--ok { border-color: var(--color-success); color: var(--color-success); }

/* ---- confirmation card (the only thing that registers) ---- */
.rag-card {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}
.rag-card.is-done { border-color: var(--color-border); opacity: 0.65; }
.rag-card__title { margin: 0; font-size: var(--font-size-lg); font-weight: 700; color: var(--color-text-primary); }
.rag-card__rows { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.rag-card__row { display: flex; justify-content: space-between; gap: 12px; font-size: var(--font-size-md); }
.rag-card__row dt { margin: 0; font-weight: 400; color: var(--color-text-muted); }
.rag-card__row dd { margin: 0; text-align: right; font-weight: 600; color: var(--color-text-primary); overflow-wrap: anywhere; }
.rag-card__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rag-card__actions .sc-btn { flex: 1 1 auto; }

/* ---- input / login ---- */
.rag-form { display: flex; gap: 8px; padding: 10px 12px 6px; border-top: 1px solid var(--color-border); }
.rag-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-md);
    background: var(--color-input-bg);
    color: var(--color-input-text);
    font-size: var(--font-size-md);
}
.rag-input::placeholder { color: var(--color-input-placeholder); }
.rag-input:focus { outline: none; border-color: var(--color-input-focus-border); box-shadow: var(--shadow-focus); }
.rag-send { flex: 0 0 auto; width: 44px; padding: 0; }
.rag-login { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 12px 8px; border-top: 1px solid var(--color-border); text-align: center; }
.rag-login p { margin: 0; color: var(--color-text-secondary); font-size: var(--font-size-md); }
.rag-note { margin: 0; padding: 0 12px 10px; font-size: var(--font-size-xs); color: var(--color-text-muted); text-align: center; }

/* ---- mobile: bottom sheet above the bottom navigation ---- */
@media (max-width: 767px) {
    .rag-panel {
        left: 0;
        right: 0;
        bottom: var(--bottom-nav-offset, 0px);
        width: auto;
        max-width: none;
        height: 78vh;
        height: 78dvh;
        max-height: none;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .rag-msg { max-width: 92%; }
}

/* the page behind a mobile bottom sheet does not scroll */
@media (max-width: 767px) {
    body.rag-lock { overflow: hidden; }
}
