/* ==========================================================================
   OMNITRACE — STRICT MONOCHROME SaaS DESIGN SYSTEM
   Palette: Deep Pitch Black (#000), Matte Dark Gray (#0A0A0A, #121212, #171717), Crisp White (#FFF)
   Aesthetic: Linear / Figma / Vercel flat monochrome vector UI
   ========================================================================== */

:root {
    /* Backgrounds */
    --bg-root: #000000;
    --bg-surface: #0a0a0a;
    --bg-surface-elevated: #121212;
    --bg-surface-hover: #1c1c1c;
    --bg-surface-active: #262626;
    --bg-surface-highlight: #333333;

    /* Borders */
    --border-subtle: #1a1a1a;
    --border-default: #262626;
    --border-strong: #404040;
    --border-white: #ffffff;
    --border-focus: #ffffff;

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    --text-dim: #525252;
    --text-inverse: #000000;

    /* Accent & Inverted Tokens */
    --accent-solid: #ffffff;
    --accent-solid-text: #000000;
    --accent-subtle: #171717;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Geist Mono', 'SFMono-Regular', Consolas, Menlo, monospace;

    /* Geometry */
    --radius-xs: 2px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-pill: 9999px;

    /* Layout */
    --sidebar-width: 260px;
    --navbar-height: 56px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body {
    background-color: var(--bg-root);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-root);
}
::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: var(--radius-xs);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.02em;
}

p {
    color: var(--text-secondary);
}

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover {
    color: var(--text-secondary);
}

code, pre, .mono {
    font-family: var(--font-mono);
}

/* ==========================================================================
   NAVBAR
   ========================================================================== */
.navbar {
    height: var(--navbar-height);
    background: var(--bg-root);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-weight: 700;
    text-decoration: none;
}

.brand-logo-badge {
    width: 28px;
    height: 28px;
    background: var(--text-primary);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: var(--radius-xs);
    letter-spacing: 0.05em;
}

.brand-logo-img {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-default);
    object-fit: cover;
    display: block;
}

.brand-title {
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.08em;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.user-avatar {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-xs);
    object-fit: cover;
    border: 1px solid var(--border-default);
}

.nav-logout-btn {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    padding-left: 8px;
    border-left: 1px solid var(--border-default);
    text-decoration: none;
    transition: color 0.15s ease;
}
.nav-logout-btn:hover {
    color: var(--text-primary);
}

/* ==========================================================================
   APP LAYOUT & SIDEBAR
   ========================================================================== */
.app-container {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-root);
    border-right: 1px solid var(--border-default);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.guild-header-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    overflow: hidden;
}

.guild-icon-badge {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.guild-header-card > div:last-child {
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.guild-header-card h3 {
    font-size: 0.88rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.guild-header-card span {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.12s ease;
    text-decoration: none;
}

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

.nav-link.active {
    color: var(--text-inverse);
    background: var(--text-primary);
    font-weight: 600;
    border-color: var(--text-primary);
}

.nav-link.active .nav-svg-icon {
    stroke: var(--text-inverse);
}

.nav-svg-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 2;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 32px;
    background: var(--bg-root);
}

/* ==========================================================================
   PAGE HEADERS & BUTTONS
   ========================================================================== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-default);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.12s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--text-inverse);
    border-color: var(--text-primary);
}
.btn-primary:hover {
    background: #e5e5e5;
    border-color: #e5e5e5;
    color: var(--text-inverse);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-default);
}
.btn-secondary:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-freeze {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-default);
}
.btn-freeze.active {
    background: var(--text-primary);
    color: var(--text-inverse);
    border-color: var(--text-primary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.78rem;
}

.btn-danger {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn-danger:hover {
    background: var(--text-primary);
    color: var(--text-inverse);
    border-color: var(--text-primary);
}

.admin-tab-btn.active {
    background: var(--text-primary);
    color: var(--text-inverse);
    border-color: var(--text-primary);
}

/* ==========================================================================
   CARDS & PANELS
   ========================================================================== */
.card, .stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 20px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

/* Status Pill / Badges */
.status-pill, .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    font-weight: 600;
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-solid {
    background: var(--text-primary);
    color: var(--text-inverse);
    border-color: var(--text-primary);
}

.badge-outline {
    border-color: var(--border-strong);
    color: var(--text-primary);
    background: transparent;
}

.badge-alert {
    border-color: var(--border-white);
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    font-weight: 700;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-primary);
}

/* ==========================================================================
   FILTER TABS & TOOLBARS
   ========================================================================== */
.filter-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.filter-tab {
    padding: 5px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-tab:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.filter-tab.active {
    background: var(--text-primary);
    color: var(--text-inverse);
    border-color: var(--text-primary);
    font-weight: 600;
}

/* ==========================================================================
   EVENT STREAM & CARDS (LIVE FEED)
   ========================================================================== */
.stream-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.event-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    transition: border-color 0.12s ease, background 0.12s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.event-card:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--border-strong);
}

.event-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.event-card-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.event-icon-box {
    width: 24px;
    height: 24px;
    background: var(--bg-root);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.event-type-badge {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-default);
    background: var(--bg-root);
    color: var(--text-primary);
    letter-spacing: 0.04em;
}

.event-title-text {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-timestamp {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.event-body-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
    word-break: break-word;
}

.event-body-text strong {
    color: var(--text-primary);
}

.event-meta-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.event-meta-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-root);
    border: 1px solid var(--border-subtle);
    padding: 2px 6px;
    border-radius: var(--radius-xs);
}

/* ==========================================================================
   DATA TABLES (EXPLORER)
   ========================================================================== */
.table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    text-align: left;
}

.data-table th {
    background: var(--bg-surface-elevated);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.1s ease;
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: var(--bg-surface-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ==========================================================================
   FORMS, INPUTS & CONTROLS
   ========================================================================== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.12s ease;
}

.form-control:focus {
    border-color: var(--border-white);
}

.form-control::placeholder {
    color: var(--text-dim);
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border-default);
    border-radius: var(--radius-xs);
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: var(--radius-xs);
    background: var(--text-primary);
    cursor: pointer;
    border: 1px solid var(--bg-root);
}

/* Checkbox */
input[type="checkbox"] {
    accent-color: var(--text-primary);
    cursor: pointer;
}

/* ==========================================================================
   VOICE RADAR ROOMS GRID
   ========================================================================== */
.voice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.voice-room-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.voice-room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.voice-room-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
}

.voice-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

.voice-member-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

/* ==========================================================================
   DOSSIER & HEATMAP (MONOCHROME 5-TIER)
   ========================================================================== */
.dossier-header-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.dossier-avatar {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    object-fit: cover;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: 32px repeat(24, 1fr);
    gap: 4px;
    margin-top: 12px;
    align-items: center;
    min-width: 680px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 1px;
    border: 1px solid var(--border-subtle);
    background: #0d0d0d;
}
.heatmap-cell[data-level="1"] { background: #262626; }
.heatmap-cell[data-level="2"] { background: #525252; }
.heatmap-cell[data-level="3"] { background: #a3a3a3; }
.heatmap-cell[data-level="4"] { background: #ffffff; }

/* ==========================================================================
   SIDE DRAWER (INSPECTOR)
   ========================================================================== */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 200;
    display: none;
}
.drawer-overlay.active {
    display: block;
}

.drawer {
    position: fixed;
    top: 0;
    right: -480px;
    width: 480px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-root);
    border-left: 1px solid var(--border-default);
    z-index: 201;
    display: flex;
    flex-direction: column;
    transition: right 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer.active {
    right: 0;
}

.drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.json-viewer {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 280px;
    overflow-y: auto;
}

.json-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
}
.json-toggle-btn:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-white);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toast-in 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toast-in {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
