/* ── TemeninChat Admin Design Tokens ─────────────────────────────── */
:root {
    --tc-primary: #7C6FF7;
    --tc-primary-soft: rgba(124, 111, 247, 0.12);
    --tc-secondary: #F472B6;
    --tc-secondary-soft: rgba(244, 114, 182, 0.12);
    --tc-navy-900: #0f0f1e;
    --tc-navy-800: #1a1a2e;
    --tc-navy-700: #16213e;
    --tc-canvas: #F4F5FB;
    --tc-surface: #FFFFFF;
    --tc-text: #1E1E2E;
    --tc-text-muted: #6B6B80;
    --tc-border: rgba(30, 30, 46, 0.08);
    --tc-radius: 10px;
    --tc-radius-sm: 8px;
    --tc-radius-lg: 16px;
    --tc-space-page: 1.5rem;
    --tc-shadow-sm: 0 1px 2px 0 rgba(15, 15, 30, 0.04), 0 1px 3px 0 rgba(15, 15, 30, 0.06);
    --tc-shadow-md: 0 2px 4px -1px rgba(15, 15, 30, 0.05), 0 4px 8px -2px rgba(15, 15, 30, 0.06);
}

/* ── Base ────────────────────────────────────────────────────────── */
html, body {
    font-family: Roboto, Helvetica, Arial, sans-serif;
    height: 100%;
    width: 100%;
    margin: 0;
    background: var(--tc-canvas);
    color: var(--tc-text);
}

/* Soft canvas behind Mud main content */
.mud-layout {
    background: var(--tc-canvas) !important;
}

.mud-main-content {
    background: var(--tc-canvas);
    min-height: 100vh;
}

/* ── Page layout ─────────────────────────────────────────────────── */
.admin-page {
    padding-bottom: 2.5rem;
}

.admin-page-header {
    margin-bottom: 1.25rem;
}

.admin-page-header__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.admin-page-header__titles {
    min-width: 0;
    flex: 1 1 auto;
}

.admin-page-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
}

.admin-filter-bar {
    margin-bottom: 1rem;
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    background: var(--tc-surface);
}

.admin-section-card {
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    background: var(--tc-surface);
    overflow: hidden;
}

.admin-section-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--tc-border);
}

.admin-section-card__body {
    padding: 1.25rem;
}

.admin-section-card__body--flush {
    padding: 0;
}

.admin-stat-card {
    height: 100%;
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    background: var(--tc-surface);
    padding: 1.15rem 1.25rem;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.admin-stat-card:hover {
    box-shadow: var(--tc-shadow-sm);
    border-color: rgba(124, 111, 247, 0.2);
}

.admin-stat-card__label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--tc-text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.admin-stat-card__value {
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--tc-text);
}

.admin-stat-card__value--error {
    color: #EF4444;
}

.admin-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1.5rem;
    gap: 0.5rem;
    color: var(--tc-text-muted);
}

.admin-empty-state__icon {
    opacity: 0.45;
    margin-bottom: 0.25rem;
}

/* Leaflet popup lives outside Blazor scoped CSS */
.user-map-marker {
    background: none;
    border: none;
}

.user-map-popup {
    font-size: 0.85rem;
    line-height: 1.4;
    min-width: 140px;
}

.user-map-popup strong {
    display: block;
    margin-bottom: 0.15rem;
}

.user-map-open {
    margin-top: 0.5rem;
    border: 0;
    border-radius: 8px;
    padding: 0.3rem 0.65rem;
    background: var(--tc-primary);
    color: #fff;
    cursor: pointer;
    font-size: 0.8rem;
}

.user-map-card {
    margin-top: 0.75rem;
}

.user-map {
    height: calc(100vh - 280px);
    min-height: 360px;
    width: 100%;
}

.user-map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    padding-bottom: 0.35rem;
    color: var(--tc-text-muted);
    font-size: 0.8rem;
}

.user-map-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.user-map-legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.user-map-legend__dot--online { background: #22c55e; }
.user-map-legend__dot--busy { background: #f59e0b; }
.user-map-legend__dot--offline { background: #94a3b8; }
.user-map-legend__dot--banned { background: #ef4444; }

.leaflet-container {
    font-family: inherit;
    z-index: 1;
    height: 100%;
    width: 100%;
}

/* ── Drawer brand ────────────────────────────────────────────────── */
.admin-drawer-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.15rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-drawer-brand__mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--tc-primary) 0%, var(--tc-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(124, 111, 247, 0.35);
}

.admin-drawer-brand__title {
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    line-height: 1.2 !important;
}

.admin-drawer-brand__subtitle {
    color: rgba(255, 255, 255, 0.5) !important;
    font-size: 0.7rem !important;
    line-height: 1.2 !important;
}

.admin-nav-section {
    color: rgba(255, 255, 255, 0.4) !important;
    font-size: 0.7rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase;
    padding: 1rem 1.25rem 0.4rem !important;
}

/* Active nav polish */
.mud-nav-link.active {
    background: rgba(124, 111, 247, 0.18) !important;
    border-radius: 8px;
    color: #fff !important;
}

.mud-nav-link:hover:not(.active) {
    background: rgba(255, 255, 255, 0.06) !important;
    border-radius: 8px;
}

.mud-navmenu {
    padding: 0.5rem 0.65rem 1rem !important;
}

.mud-nav-link {
    margin-bottom: 2px;
}

/* ── App bar ─────────────────────────────────────────────────────── */
.admin-appbar-title {
    font-weight: 600 !important;
    letter-spacing: -0.01em;
}

.admin-user-chip {
    background: rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.92) !important;
}

/* ── Tables ──────────────────────────────────────────────────────── */
.admin-table-wrap .mud-table {
    background: transparent;
}

.admin-table-wrap .mud-table-container {
    border-radius: 0 0 var(--tc-radius) var(--tc-radius);
}

/* ── Chat media ──────────────────────────────────────────────────── */
.chat-thread {
    max-height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-bubble {
    max-width: 72%;
    border-radius: var(--tc-radius-sm);
}

.chat-bubble__content {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-media-img {
    max-width: 100%;
    max-height: 240px;
    border-radius: 6px;
    display: block;
}

.chat-media-video {
    max-width: 100%;
    max-height: 240px;
    border-radius: 6px;
    display: block;
}

.chat-media-video-note {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.chat-media-sticker {
    width: 128px;
    height: 128px;
    object-fit: contain;
    display: block;
}

.chat-media-audio {
    width: 100%;
}

.media-grid-tile {
    height: 100%;
}

.media-grid-preview {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 6px;
    background: var(--tc-navy-800);
}

.media-grid-preview img,
.media-grid-preview video {
    max-width: 100%;
    max-height: 140px;
    object-fit: contain;
}

.media-grid-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-avatar {
    border-radius: var(--tc-radius-sm);
    border: 1px solid var(--tc-border);
}

/* ── Login ───────────────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--tc-navy-800) 0%, var(--tc-navy-700) 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: var(--tc-radius-lg) !important;
    overflow: hidden;
}

.login-card__hero {
    background: linear-gradient(135deg, var(--tc-primary) 0%, var(--tc-secondary) 100%);
    padding: 2.5rem 2rem;
    text-align: center;
}

.login-card__hero-icon {
    display: block;
    margin: 0 auto 1rem;
}

.login-card__hero-title {
    color: white;
    font-size: 1.4rem;
    font-weight: 700;
    font-family: Roboto, sans-serif;
    margin-bottom: 0.25rem;
}

.login-card__hero-subtitle {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.875rem;
    font-family: Roboto, sans-serif;
}

.login-card__body {
    padding: 2rem;
}

/* ── Misc ────────────────────────────────────────────────────────── */
.word-break {
    word-break: break-word;
}

.max-w-320 {
    max-width: 320px;
}

.max-w-300 {
    max-width: 300px;
}

.mono-block {
    background: var(--tc-canvas);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
    border-radius: var(--tc-radius-sm);
    padding: 0.75rem 1rem;
}

/* Blazor error boundary */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 1.25rem;
    color: white;
    border-radius: var(--tc-radius-sm);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

#blazor-error-ui {
    color-scheme: light only;
    background: #fff8dc;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

/* ── User / Session workbench ───────────────────────────────── */
.wb-hero {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
    background: var(--tc-surface);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    margin-bottom: 0.75rem;
}

.wb-hero__avatar {
    width: 88px;
    height: 88px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--tc-border);
    flex-shrink: 0;
    background: var(--tc-canvas);
}

.wb-hero__body { flex: 1 1 220px; min-width: 0; }
.wb-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
    justify-content: flex-end;
}

.wb-risk-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    padding: 0.9rem 1.15rem;
    background: linear-gradient(90deg, rgba(239,68,68,0.06), rgba(245,158,11,0.05));
    border: 1px solid rgba(239, 68, 68, 0.14);
    border-radius: var(--tc-radius);
    margin-bottom: 1rem;
}

.wb-risk-strip__item-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--tc-text-muted);
    margin-bottom: 0.2rem;
}

.wb-risk-strip__item-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--tc-text);
}

.wb-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 960px) {
    .wb-layout { grid-template-columns: 1fr; }
}

.wb-rail {
    position: sticky;
    top: 80px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.wb-rail-card {
    background: var(--tc-surface);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    padding: 1rem 1.1rem;
}

.wb-rail-card__title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--tc-text-muted);
    margin-bottom: 0.65rem;
}

.wb-main {
    background: var(--tc-surface);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    overflow: hidden;
    min-height: 420px;
}

.wb-segment-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.85rem;
}

.wb-case-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.15rem 1.35rem;
    background: var(--tc-surface);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    margin-bottom: 0.75rem;
}

.wb-case-header__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.45rem;
}

.wb-report-alert {
    border-radius: var(--tc-radius);
    margin-bottom: 0.75rem;
}

.wb-investigation {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 960px) {
    .wb-investigation { grid-template-columns: 1fr; }
}

.wb-participant {
    background: var(--tc-surface);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    padding: 0.95rem 1rem;
}

.wb-participant + .wb-participant { margin-top: 0.65rem; }

.wb-evidence {
    background: var(--tc-surface);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    overflow: hidden;
    min-height: 480px;
}

.wb-chat-thread {
    max-height: 560px;
    overflow-y: auto;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    background: #F8F8FC;
}

.wb-chat-day {
    align-self: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tc-text-muted);
    background: rgba(30,30,46,0.06);
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    margin: 0.35rem 0;
}

.wb-chat-row { display: flex; width: 100%; }
.wb-chat-row--a { justify-content: flex-start; }
.wb-chat-row--b { justify-content: flex-end; }

.wb-chat-bubble {
    max-width: min(72%, 480px);
    padding: 0.55rem 0.8rem;
    border-radius: 12px;
    border: 1px solid var(--tc-border);
    background: #fff;
    box-shadow: var(--tc-shadow-sm);
}

.wb-chat-row--a .wb-chat-bubble {
    border-bottom-left-radius: 4px;
    background: #fff;
}

.wb-chat-row--b .wb-chat-bubble {
    border-bottom-right-radius: 4px;
    background: rgba(124, 111, 247, 0.08);
    border-color: rgba(124, 111, 247, 0.18);
}

.wb-chat-bubble__meta {
    font-size: 0.7rem;
    color: var(--tc-text-muted);
    margin-bottom: 0.25rem;
}

.wb-chat-bubble__text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.875rem;
}

.triage-row--banned { background: rgba(239, 68, 68, 0.05) !important; }
.triage-row--risk { background: rgba(245, 158, 11, 0.06) !important; }
.triage-row--pending { background: rgba(245, 158, 11, 0.06) !important; }

.risk-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.risk-progress__bar {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: rgba(30,30,46,0.08);
    overflow: hidden;
}

.risk-progress__fill {
    height: 100%;
    border-radius: 999px;
    background: var(--tc-primary);
    transition: width 0.2s ease;
}

.risk-progress__fill--warn { background: #F59E0B; }
.risk-progress__fill--danger { background: #EF4444; }

.copyable {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
}

.metric-pair {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.25rem 0;
}

.metric-pair + .metric-pair {
    border-top: 1px solid var(--tc-border);
}
