/*
 * AutoDoc 360 - R5 Visual QA scoped stylesheet
 * Scope: authenticated commercial/admin surfaces + standalone error pages.
 * Public QR selectors are intentionally excluded.
 */

.r5v-page {
    --r5v-border: #dbe3ef;
    --r5v-soft: #f8fafc;
    --r5v-text: #172033;
    --r5v-muted: #64748b;
    --r5v-accent: #2563eb;
    --r5v-danger: #991b1b;
    --r5v-radius: 14px;
}

.r5v-page-header {
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 18px;
}

.r5v-card-stack {
    display: grid;
    gap: 14px;
}

.r5v-content-card,
.r5v-table-card,
.r5v-flow-card,
.r5v-conversation-card,
.r5v-reply-card {
    border-radius: var(--r5v-radius);
}

.r5v-section-title {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.35;
}

.r5v-muted,
.r5v-form-note {
    color: var(--r5v-muted);
    font-size: .92rem;
}

.r5v-readable-copy {
    max-width: 78ch;
    white-space: pre-line;
    color: #334155;
}

.r5v-empty-state {
    display: grid;
    gap: 4px;
    padding: 18px;
}

.r5v-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.r5v-table-wrap {
    border: 1px solid var(--r5v-border);
    border-radius: 12px;
    overflow: auto;
}

.r5v-table-empty {
    padding: 26px !important;
    text-align: center;
    color: var(--r5v-muted);
}

.r5v-status-badge,
.r5v-channel-badge {
    white-space: nowrap;
}

.r5v-form-stack {
    display: grid;
    gap: 14px;
}

.r5v-form-grid {
    display: grid;
    gap: 14px;
}

.r5v-form-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.r5v-field {
    display: grid;
    gap: 7px;
    min-width: 0;
    font-weight: 700;
    color: var(--r5v-text);
}

.r5v-field > span {
    font-size: .9rem;
}

.r5v-field input,
.r5v-field select,
.r5v-field textarea {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.r5v-field textarea {
    resize: vertical;
}

.r5v-field--compact {
    min-width: 210px;
}

.r5v-form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.r5v-editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 18px;
    align-items: start;
}

.r5v-editor-help {
    position: sticky;
    top: 18px;
}

.r5v-token-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.r5v-token-list code {
    display: block;
    padding: 8px 10px;
    border: 1px solid var(--r5v-border);
    border-radius: 8px;
    background: var(--r5v-soft);
    overflow-wrap: anywhere;
}

.r5v-support-page {
    min-width: 0;
}

.r5v-support-grid {
    display: grid;
    grid-template-columns: minmax(280px, .72fr) minmax(0, 1.28fr);
    gap: 18px;
    align-items: start;
}

.r5v-support-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.r5v-filter-bar {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.r5v-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--r5v-muted);
}

.r5v-message-list {
    display: grid;
    gap: 10px;
}

.r5v-message {
    max-width: 84%;
    padding: 13px 15px;
    border: 1px solid var(--r5v-border);
    border-radius: 12px;
    background: #fff;
}

.r5v-message--outbound {
    margin-left: auto;
    background: #f3f7ff;
    border-color: #cbdaf7;
}

.r5v-message--inbound {
    margin-right: auto;
    background: var(--r5v-soft);
}

.r5v-message-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 6px;
}

.r5v-message p {
    margin: 6px 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.r5v-message small {
    color: var(--r5v-muted);
}

.r5v-security-primary-grid {
    gap: 18px;
}

.r5v-security-card,
.r5v-security-dashboard .r5v-table-card {
    border-radius: var(--r5v-radius);
}

.r5v-security-danger-zone {
    border-color: #fecaca;
}

.r5v-security-flow {
    max-width: 980px;
}

.r5v-flow-card {
    display: grid;
    gap: 18px;
}

.r5v-flow-card--compact {
    max-width: 620px;
    margin-inline: auto;
}

.r5v-flow-heading {
    display: grid;
    gap: 5px;
}

.r5v-mfa-enroll-grid {
    display: grid;
    grid-template-columns: minmax(260px, .85fr) minmax(0, 1.15fr);
    gap: 22px;
    align-items: start;
}

.r5v-qr-box {
    display: grid;
    place-items: center;
    padding: 18px;
    overflow: auto;
}

.r5v-qr-box svg {
    max-width: 100%;
    height: auto;
}

.r5v-secret-box {
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.r5v-action-warning {
    display: grid;
    gap: 4px;
}

.r5v-protected-action {
    display: grid;
    gap: 3px;
    padding: 12px 14px;
    border: 1px solid var(--r5v-border);
    border-radius: 10px;
    background: var(--r5v-soft);
}

.r5v-protected-action span,
.r5v-protected-action small {
    color: var(--r5v-muted);
}

.r5v-recovery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.r5v-recovery-code {
    padding: 12px 14px;
    border: 1px solid var(--r5v-border);
    border-radius: 9px;
    background: var(--r5v-soft);
    font-size: .96rem;
    overflow-wrap: anywhere;
}

.r5v-impersonation-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: #7f1d1d;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.22);
}

.r5v-impersonation-bar span {
    opacity: .94;
}

.r5v-impersonation-stop-form {
    margin: 0;
}

.r5v-impersonation-stop {
    padding: 7px 11px;
    border: 1px solid rgba(255,255,255,.6);
    border-radius: 8px;
    background: #fff;
    color: #7f1d1d;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.r5v-impersonation-stop:focus-visible,
.r5v-page a:focus-visible,
.r5v-page button:focus-visible,
.r5v-page input:focus-visible,
.r5v-page select:focus-visible,
.r5v-page textarea:focus-visible,
.r5v-error-page a:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

/* Standalone HTTP errors. */
.r5v-error-page {
    min-height: 100vh;
    margin: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    box-sizing: border-box;
    background: #f4f7fb;
    color: #172033;
    font-family: Arial, Helvetica, sans-serif;
}

.r5v-error-shell {
    width: min(100%, 680px);
    background: #fff;
    border: 1px solid #dbe3ef;
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(15,23,42,.08);
    overflow: hidden;
}

.r5v-error-brand {
    display: block;
    padding: 20px 24px;
    background: #172033;
    color: #fff;
    text-decoration: none;
    font-size: 1.18rem;
    font-weight: 800;
}

.r5v-error-content {
    padding: 34px 30px 30px;
}

.r5v-error-code {
    display: inline-block;
    margin-bottom: 10px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2ff;
    color: #334155;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .08em;
}

.r5v-error-title {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    line-height: 1.12;
}

.r5v-error-message {
    max-width: 54ch;
    margin: 14px 0 22px;
    color: #475569;
    font-size: 1rem;
}

.r5v-error-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.r5v-error-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 9px;
    background: #172033;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
}

.r5v-error-action--secondary {
    background: #eef2f7;
    color: #172033;
}

@media (max-width: 1100px) {
    .r5v-editor-grid,
    .r5v-support-grid,
    .r5v-mfa-enroll-grid {
        grid-template-columns: 1fr;
    }

    .r5v-editor-help {
        position: static;
    }
}

@media (max-width: 820px) {
    .r5v-form-grid--2,
    .r5v-support-actions-grid,
    .r5v-recovery-grid {
        grid-template-columns: 1fr;
    }

    .r5v-message {
        max-width: 100%;
    }

    .r5v-card-heading,
    .r5v-message-head {
        align-items: stretch;
        flex-direction: column;
    }

    .r5v-page-header {
        align-items: stretch;
    }
}
