/* ========================================
   APEX Admin Panel - Azure DevOps / Fluent UI Design System
   ======================================== */

/* --- Design Tokens --- */
:root {
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;

    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;
    --radius-xl: 8px;
    --radius-full: 9999px;

    --sidebar-width: 220px;
    --topbar-height: 48px;

    --motion-fast: 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
    --motion-normal: 250ms cubic-bezier(0.2, 0.8, 0.2, 1);

    --shadow-soft: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-elevated: 0 4px 8px rgba(0, 0, 0, 0.08);

    /* Global header & sidebar - always dark like Azure DevOps */
    --topbar-bg: #0d1117;
    --topbar-text: rgba(255, 255, 255, 0.9);
    --topbar-text-muted: rgba(255, 255, 255, 0.6);
    --topbar-border: rgba(255, 255, 255, 0.08);

    /* Sidebar - always dark, independent of theme */
    --sidebar-bg: #1e1e1e;
    --sidebar-border: #2d2d2d;
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-text-muted: rgba(255, 255, 255, 0.45);
    --sidebar-text-active: #ffffff;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
    --sidebar-active-bg: rgba(255, 255, 255, 0.1);
    --sidebar-section-text: rgba(255, 255, 255, 0.4);
    --sidebar-footer-border: rgba(255, 255, 255, 0.08);

    --color-brand: #0078D4;
    --color-brand-light: #1890F1;
    --color-brand-hover: #106EBE;
    --color-brand-bg: rgba(0, 120, 212, 0.08);

    --color-success: #107C10;
    --color-warning: #FFB900;
    --color-danger: #D13438;
    --color-info: #0078D4;
}

/* --- Light Theme --- */
:root,
html[data-theme="light"] {
    --color-bg: #FAF9F8;
    --color-surface: #FFFFFF;
    --color-surface-hover: #F3F2F1;
    --color-surface-elevated: #F3F2F1;
    --color-surface-glass: rgba(255, 255, 255, 0.86);
    --color-text: #323130;
    --color-text-muted: #605E5C;
    --color-text-subtle: #A19F9D;
    --color-border: #EDEBE9;
    --color-table-header: #605E5C;
    --color-input-bg: #FFFFFF;
}

/* --- Dark Theme --- */
html[data-theme="dark"] {
    --color-bg: #1E1E1E;
    --color-surface: #252526;
    --color-surface-hover: #2D2D2D;
    --color-surface-elevated: #2D2D2D;
    --color-surface-glass: rgba(37, 37, 38, 0.86);
    --color-text: #CCCCCC;
    --color-text-muted: #A1A1AA;
    --color-text-subtle: #71717A;
    --color-border: #3E3E42;
    --color-table-header: #A1A1AA;
    --color-input-bg: #1E1E1E;

    --color-brand: #4BA0E8;

    --shadow-soft: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-elevated: 0 4px 8px rgba(0, 0, 0, 0.25);
}

/* --- Scrollbars (Fluent-style thin scrollbars) --- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-text-subtle) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--color-text-subtle);
    border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

/* --- Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100vh;
    overflow: hidden;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
}

a,
button,
input,
select,
textarea {
    font: inherit;
}

img {
    max-width: 100%;
    display: block;
}

#blazor-error-ui {
    display: none;
}

/* ========================================
   Layout - Azure DevOps style
   TopBar (full width, top) → Sidebar + Content below
   ======================================== */

.admin-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.admin-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* --- Sidebar (Azure DevOps: always dark, fixed-width) --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-3) 0;
    overflow-y: auto;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.sidebar-footer {
    border-top: 1px solid var(--sidebar-footer-border);
    padding: var(--space-2) 0;
}

/* --- Nav Group (collapsible, colored accent) --- */
.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    border-left: 2px solid var(--nav-group-accent, var(--sidebar-section-text));
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--nav-group-accent, var(--sidebar-section-text));
    padding: 8px var(--space-4);
    transition: background 80ms ease;
}

.nav-group-header:hover {
    background: var(--sidebar-hover-bg);
}

.nav-group-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-group-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-group-icon svg {
    width: 15px;
    height: 15px;
}

.nav-group-title {
    white-space: nowrap;
}

.nav-group-chevron {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    transition: transform 120ms ease;
    transform: rotate(-90deg);
    opacity: 0.5;
}

.nav-group-chevron.expanded {
    transform: rotate(0deg);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
}

.nav-sub-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sidebar-text-muted);
    padding: 6px var(--space-4) 2px calc(var(--space-4) + 4px);
    margin-top: 2px;
}

/* --- Nav Item (Azure DevOps flat link) --- */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px var(--space-4);
    padding-left: calc(var(--space-4) + 2px);
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    transition: background 80ms ease, color 80ms ease;
    position: relative;
    border-left: 2px solid transparent;
    line-height: 1.4;
}

.nav-item:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 500;
    border-left-color: var(--color-brand);
}

.nav-item-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-item.active .nav-item-icon {
    opacity: 1;
}

.nav-item-icon svg {
    width: 15px;
    height: 15px;
}

.nav-item-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Top Bar (Azure DevOps global header - always dark) --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    flex-shrink: 0;
    padding: 0 var(--space-4);
    background: var(--topbar-bg);
    z-index: 200;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.topbar-brand-logo {
    width: 22px;
    height: 22px;
    border-radius: 3px;
    object-fit: contain;
}

.topbar-brand-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--topbar-text);
    letter-spacing: -0.3px;
}

.topbar-breadcrumb {
    font-size: 13px;
    color: var(--topbar-text-muted);
    font-weight: 400;
    display: flex;
    align-items: center;
}

.topbar-breadcrumb a {
    color: var(--topbar-text-muted);
}

.topbar-breadcrumb a:hover {
    color: var(--topbar-text);
}

.breadcrumb-separator {
    margin: 0 6px;
    color: var(--topbar-text-muted);
    opacity: 0.5;
}

.breadcrumb-current {
    color: var(--topbar-text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.topbar-search-container {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border: 1px solid var(--topbar-border);
    border-radius: var(--radius-md);
    padding: var(--space-1) var(--space-3);
    color: var(--topbar-text-muted);
    background: rgba(255, 255, 255, 0.06);
}

.topbar-search-container:focus-within {
    border-color: var(--color-brand);
    background: rgba(255, 255, 255, 0.1);
}

.topbar-search {
    border: none;
    outline: none;
    background: transparent;
    color: var(--topbar-text);
    font-size: 13px;
    width: 180px;
}

.topbar-search::placeholder {
    color: var(--topbar-text-muted);
}

.topbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--topbar-text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--motion-fast);
}

.topbar-icon-btn:hover {
    color: var(--topbar-text);
    background: rgba(255, 255, 255, 0.08);
}

.topbar-user {
    display: flex;
    align-items: center;
}

.topbar-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--color-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-weight: 600;
    font-size: 12px;
    overflow: hidden;
    flex-shrink: 0;
}

/* --- Admin Content --- */
.admin-content {
    flex: 1;
    padding: var(--space-5) var(--space-7) var(--space-7);
    overflow: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.admin-content:has(> .card-table) {
    overflow: hidden;
}

/* ========================================
   Cards
   ======================================== */

.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: var(--space-4);
}

.card.card-table {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}

.card-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* --- Stat Card --- */
.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: var(--space-4) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-brand-bg);
    color: var(--color-brand);
    flex-shrink: 0;
}

.stat-card-icon svg {
    width: 20px;
    height: 20px;
}

.stat-card-content {
    display: flex;
    flex-direction: column;
}

.stat-card-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
    letter-spacing: 0.3px;
}

.stat-card-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.2;
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

/* --- Dashboard --- */

/* Live online card */
.dash-live-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-success);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
}

.dash-live-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.dash-live-dot {
    width: 10px;
    height: 10px;
    background: var(--color-success);
    border-radius: 50%;
    animation: dash-pulse 2s ease-in-out infinite;
}

@keyframes dash-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 124, 16, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(16, 124, 16, 0); }
}

.dash-live-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-muted);
}

.dash-live-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1;
}

/* Alert banner */
.dash-alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: rgba(209, 52, 56, 0.06);
    border: 1px solid rgba(209, 52, 56, 0.15);
    border-radius: var(--radius-lg);
    color: var(--color-danger);
    font-size: 13px;
    margin-bottom: var(--space-5);
    text-decoration: none;
    transition: background 80ms ease;
}

.dash-alert:hover {
    background: rgba(209, 52, 56, 0.12);
}

.dash-alert-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Section */
.dash-section {
    margin-bottom: var(--space-5);
}

.dash-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.dash-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

.dash-section-title svg {
    color: var(--color-text-muted);
}

.dash-section-link {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-brand);
    text-decoration: none;
}

.dash-section-link:hover {
    text-decoration: underline;
}

/* Suspect card grid */
.dash-card-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-3);
}

.dash-suspect-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    cursor: pointer;
    transition: border-color 80ms ease, box-shadow 80ms ease;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    position: relative;
    overflow: hidden;
}

.dash-suspect-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.dash-danger-critical::before { background: var(--color-danger); }
.dash-danger-high::before { background: #FF8C42; }
.dash-danger-medium::before { background: var(--color-warning); }
.dash-danger-low::before { background: var(--color-text-subtle); }

.dash-suspect-card:hover {
    border-color: var(--color-text-subtle);
    box-shadow: var(--shadow-elevated);
}

.dash-suspect-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dash-suspect-id {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    font-family: monospace;
}

.dash-suspect-score {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-danger);
    font-family: monospace;
}

.dash-danger-medium .dash-suspect-score { color: var(--color-warning); }
.dash-danger-low .dash-suspect-score { color: var(--color-text-muted); }

.dash-suspect-stats {
    display: flex;
    gap: var(--space-4);
}

.dash-suspect-stat {
    display: flex;
    flex-direction: column;
}

.dash-suspect-stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    font-family: monospace;
}

.dash-suspect-pending {
    color: var(--color-warning);
}

.dash-suspect-stat-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.dash-suspect-footer {
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
}

.dash-suspect-time {
    font-size: 11px;
    color: var(--color-text-subtle);
    font-family: monospace;
}

/* Ticket card list */
.dash-ticket-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-3);
}

.dash-ticket-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    cursor: pointer;
    transition: border-color 80ms ease, box-shadow 80ms ease;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.dash-ticket-card:hover {
    border-color: var(--color-text-subtle);
    box-shadow: var(--shadow-elevated);
}

.dash-ticket-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dash-ticket-id {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    font-family: monospace;
}

.dash-ticket-time {
    font-size: 11px;
    color: var(--color-text-subtle);
    font-family: monospace;
}

.dash-ticket-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-ticket-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.dash-ticket-player {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Empty state */
.dash-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-8) var(--space-4);
    color: var(--color-text-subtle);
    font-size: 13px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

/* ========================================
   Data Table
   ======================================== */

.table-container {
    overflow: auto;
    flex: 1;
    min-height: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-table-header);
    text-align: left;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    user-select: none;
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 1;
}

.data-table thead th.sortable {
    cursor: pointer;
}

.data-table thead th.sortable:hover {
    color: var(--color-text);
}

.sort-indicator {
    margin-left: var(--space-1);
    font-size: 10px;
}

.data-table tbody td {
    padding: var(--space-2) var(--space-3);
    color: var(--color-text);
    font-size: 13px;
    font-weight: 400;
    border-bottom: 1px solid var(--color-border);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background var(--motion-fast);
}

.data-table tbody tr:hover {
    background: var(--color-surface-hover);
}

.data-table tbody tr.clickable {
    cursor: pointer;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-5);
}

.tab {
    padding: var(--space-2) var(--space-4);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: 14px;
    transition: all var(--motion-fast);
    white-space: nowrap;
}

.tab:hover {
    color: var(--color-text);
}

.tab.active {
    color: var(--color-brand);
    border-bottom-color: var(--color-brand);
    font-weight: 600;
}

/* --- Detail Page Header --- */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}

.detail-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.detail-header-left h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.detail-header-actions {
    display: flex;
    gap: var(--space-2);
}

/* --- Stat Cards --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    border: 1px solid var(--color-border);
}

.stat-card .stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
    letter-spacing: 0.3px;
    margin-bottom: var(--space-1);
}

.stat-card .stat-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--color-text);
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0 0;
    font-size: 13px;
    color: var(--color-text-muted);
    flex-shrink: 0;
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-3);
}

.pagination-info {
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--color-text);
    transition: all var(--motion-fast);
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--color-brand);
    color: var(--color-brand);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-page {
    font-weight: 600;
    color: var(--color-text);
    padding: 0 var(--space-2);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: 14px;
    font-weight: 400;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--motion-fast);
    white-space: nowrap;
    text-decoration: none;
}

.btn:disabled,
.btn.btn-loading {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-brand {
    background: var(--color-brand);
    color: #FFFFFF;
    border-color: var(--color-brand);
}

.btn-brand:hover:not(:disabled) {
    background: var(--color-brand-hover);
    border-color: var(--color-brand-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-surface-hover);
}

.btn-danger {
    background: var(--color-danger);
    color: #FFFFFF;
    border-color: var(--color-danger);
}

.btn-danger:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.btn-outline {
    background: transparent;
    color: var(--color-brand);
    border: 1px solid var(--color-brand);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-brand-bg);
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: 13px;
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: 16px;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ========================================
   Form Inputs
   ======================================== */

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.form-input {
    padding: var(--space-2) var(--space-3);
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 14px;
    outline: none;
    transition: all var(--motion-fast);
}

.form-input:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 1px var(--color-brand);
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

.form-input.form-input-error {
    border-color: var(--color-danger);
}

.form-error {
    font-size: 12px;
    color: var(--color-danger);
    font-weight: 500;
}

/* --- Color Picker --- */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.color-picker-native {
    width: 42px;
    height: 42px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 2px;
    cursor: pointer;
    background: var(--color-input-bg);
    flex-shrink: 0;
}

.color-picker-native::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker-native::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.color-picker-native::-moz-color-swatch {
    border: none;
    border-radius: 2px;
}

.color-picker-text {
    flex: 1;
    font-family: monospace;
}

.form-select {
    padding: var(--space-2) var(--space-3);
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 14px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23605E5C' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    transition: all var(--motion-fast);
}

.form-select:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 1px var(--color-brand);
}

/* --- Checkbox --- */
.checkbox-wrapper {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    user-select: none;
}

.checkbox-input {
    width: 18px;
    height: 18px;
    accent-color: var(--color-brand);
    cursor: pointer;
}

.checkbox-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

/* ========================================
   Badge
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-md);
    white-space: nowrap;
}

.badge-success {
    background: rgba(16, 124, 16, 0.1);
    color: var(--color-success);
}

.badge-warning {
    background: rgba(255, 185, 0, 0.1);
    color: var(--color-warning);
}

.badge-danger {
    background: rgba(209, 52, 56, 0.1);
    color: var(--color-danger);
}

.badge-info {
    background: var(--color-brand-bg);
    color: var(--color-brand);
}

.badge-default {
    background: var(--color-surface-elevated);
    color: var(--color-text-muted);
}

/* ========================================
   Modal
   ======================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn var(--motion-fast) ease-out;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-elevated);
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp var(--motion-normal) ease-out;
}

.modal-sm { width: 400px; }
.modal-md { width: 560px; }
.modal-lg { width: 720px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 20px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--motion-fast);
}

.modal-close:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.modal-body {
    padding: var(--space-5);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--color-border);
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-elevated);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 300px;
    max-width: 420px;
    pointer-events: auto;
    animation: slideInRight var(--motion-normal) ease-out;
    border-left: 4px solid;
}

.toast-success { border-left-color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-info { border-left-color: var(--color-brand); }

.toast-message {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.toast-close {
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: var(--space-1);
    font-size: 16px;
}

.toast.toast-exit {
    animation: slideOutRight var(--motion-fast) ease-in forwards;
}

/* ========================================
   Loading Spinner
   ======================================== */

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-8);
}

.spinner {
    border: 3px solid var(--color-border);
    border-top-color: var(--color-brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loading-sm .spinner { width: 20px; height: 20px; border-width: 2px; }
.loading-md .spinner { width: 32px; height: 32px; }
.loading-lg .spinner { width: 48px; height: 48px; border-width: 4px; }

.loading-message {
    font-size: 14px;
    color: var(--color-text-muted);
    font-weight: 500;
}

.page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.page-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ========================================
   Login Page
   ======================================== */

.login-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: var(--space-6);
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-elevated);
    padding: var(--space-8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-7);
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

.login-logo {
    margin-bottom: var(--space-2);
}

.login-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.3px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--color-text-muted);
    font-weight: 400;
}

.login-discord-btn {
    width: 100%;
    padding: var(--space-3) var(--space-5);
    font-size: 15px;
}

/* ========================================
   Access Denied
   ======================================== */

.access-denied {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.access-denied-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.access-denied-card h2 {
    font-size: 24px;
    font-weight: 600;
}

/* ========================================
   Detail Pages
   ======================================== */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-5);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.detail-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
    letter-spacing: 0.3px;
}

.detail-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

.faction-detail-card {
    flex: 2;
    min-width: 380px;
}

.faction-preview-card {
    flex: 1;
    min-width: 240px;
}

/* --- Outfit Editor --- */
.outfit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

@media (max-width: 1024px) {
    .outfit-grid {
        grid-template-columns: 1fr;
    }
}

.outfit-table {
    width: 100%;
    border-collapse: collapse;
}

.outfit-section-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    text-align: left;
    padding: var(--space-3) 0 var(--space-1);
}

.outfit-section-props {
    padding-top: var(--space-5);
}

.outfit-table thead th.outfit-col-name,
.outfit-table thead th.outfit-col-val {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-subtle);
    text-align: left;
    padding: var(--space-1) 0;
    border-bottom: 1px solid var(--color-border);
}

.outfit-table thead th.outfit-col-val {
    width: 90px;
    text-align: center;
}

.outfit-table tbody td {
    padding: 3px 0;
    border: none;
}

.outfit-table tbody td:hover {
    background: none;
}

.outfit-table tbody tr:hover {
    background: none;
}

.outfit-slot-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    padding-right: var(--space-3);
}

.outfit-input {
    width: 100%;
    padding: 4px 8px;
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 13px;
    font-family: monospace;
    text-align: center;
    outline: none;
    transition: border-color var(--motion-fast);
}

.outfit-input:focus {
    border-color: var(--color-brand);
}

.outfit-input::placeholder {
    color: var(--color-text-subtle);
}

/* ========================================
   Utility Classes
   ======================================== */

.text-muted { color: var(--color-text-muted); }
.text-brand { color: var(--color-brand); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ========================================
   Animations
   ======================================== */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        bottom: 0;
        z-index: 200;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    color: var(--color-text-muted);
    font-size: 14px;
}

/* --- Language Toggle --- */
.lang-toggle {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.lang-label {
    color: inherit;
}

/* --- Page Header Icon Button --- */
.btn-icon {
    padding: var(--space-1) !important;
    min-width: unset !important;
}

/* --- Discord Embed Preview --- */
.discord-embed {
    background: #2b2d31;
    border-radius: 4px;
    border-left: 4px solid #5865f2;
    padding: 12px 16px;
    max-width: 520px;
    font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #dbdee1;
    line-height: 1.375;
}

.discord-embed-title {
    font-weight: 700;
    font-size: 16px;
    color: #f2f3f5;
    margin-bottom: 8px;
}

.discord-embed-description {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 8px;
}

.discord-embed-description strong { color: #f2f3f5; }
.discord-embed-description code {
    background: #1e1f22;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 13px;
}
.discord-embed-description pre {
    background: #1e1f22;
    padding: 8px;
    border-radius: 4px;
    margin: 4px 0;
    overflow-x: auto;
}
.discord-embed-description pre code {
    background: none;
    padding: 0;
}
.discord-embed-description a {
    color: #00a8fc;
    text-decoration: none;
}
.discord-embed-description a:hover { text-decoration: underline; }
.discord-embed-description h3,
.discord-embed-description h4,
.discord-embed-description h5 {
    color: #f2f3f5;
    margin: 8px 0 4px;
    font-size: 15px;
}
.discord-embed-description ul {
    margin: 4px 0;
    padding-left: 20px;
}

.discord-embed-fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.discord-embed-field {
    grid-column: span 3;
    min-width: 0;
}

.discord-embed-field.inline {
    grid-column: span 1;
}

.discord-embed-field-name {
    font-weight: 700;
    font-size: 14px;
    color: #f2f3f5;
    margin-bottom: 2px;
}

.discord-embed-field-value {
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.discord-embed-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #949ba4;
    margin-top: 8px;
}

.discord-embed-footer-sep { margin: 0 4px; }

/* --- Discord Markdown Editor --- */
.discord-markdown-editor {
    display: flex;
    flex-direction: column;
}

.discord-markdown-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.md-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    transition: background var(--motion-fast), color var(--motion-fast);
}

.md-toolbar-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.md-toolbar-btn code { font-size: 11px; }

.md-toolbar-sep {
    width: 1px;
    height: 18px;
    background: var(--color-border);
    margin: 0 4px;
}

.discord-markdown-textarea {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    resize: vertical;
    min-height: 120px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.5;
}
