/* CoreVMS admin panel theme (Bootstrap 5 + these tokens) */
:root {
    --vms-bg: #f4f6fb;
    --vms-surface: #ffffff;
    --vms-border: #e4e8f0;
    --vms-text: #0f172a;
    --vms-muted: #64748b;
    --vms-primary: #2563eb;
    --vms-primary-dark: #1d4ed8;
    --vms-sidebar: #0f172a;
    --vms-sidebar-text: #cbd5e1;
    --vms-sidebar-muted: #64748b;
    --vms-radius: 12px;
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-body-font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

html, body {
    background: var(--vms-bg);
    color: var(--vms-text);
    font-family: var(--bs-body-font-family);
    font-size: 15px;
}

a {
    color: var(--vms-primary);
    text-decoration: none;
}

a:hover {
    color: var(--vms-primary-dark);
}

h1:focus {
    outline: none;
}

.btn {
    border-radius: 8px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--vms-primary);
    border-color: var(--vms-primary);
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--vms-primary-dark);
    border-color: var(--vms-primary-dark);
}

.form-control, .form-select {
    border-radius: 8px;
    border-color: #d5dbe6;
    padding: 0.5rem 0.75rem;
}

.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: #93b4f5;
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: #334155;
    margin-bottom: 0.3rem;
}

.form-text {
    color: var(--vms-muted);
}

.validation-message {
    color: #dc2626;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.invalid {
    border-color: #f87171 !important;
}

.icon {
    flex-shrink: 0;
}

/* ---------- Shell ---------- */
.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--vms-sidebar);
    color: var(--vms-sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 14px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 20px;
    color: #fff;
}

.sidebar-brand:hover {
    color: #fff;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    color: #fff;
}

.brand-name {
    display: block;
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.1;
}

.brand-sub {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--vms-sidebar-muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-section {
    margin: 18px 10px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--vms-sidebar-muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--vms-sidebar-text);
    font-size: 0.92rem;
}

.sidebar-link:hover {
    background: rgba(148, 163, 184, 0.12);
    color: #fff;
}

.sidebar-link.active {
    background: rgba(59, 130, 246, 0.18);
    color: #fff;
    box-shadow: inset 3px 0 0 #3b82f6;
}

.admin-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    height: 64px;
    background: var(--vms-surface);
    border-bottom: 1px solid var(--vms-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-context {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #334155;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #dbeafe;
    color: var(--vms-primary-dark);
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.78rem;
    color: var(--vms-muted);
}

.admin-content {
    padding: 28px;
    max-width: 1280px;
    width: 100%;
}

/* ---------- Page building blocks ---------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.page-subtitle {
    color: var(--vms-muted);
    margin: 4px 0 0;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.panel {
    background: var(--vms-surface);
    border: 1px solid var(--vms-border);
    border-radius: var(--vms-radius);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    margin-bottom: 20px;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--vms-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.panel-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.panel-hint {
    color: var(--vms-muted);
    font-size: 0.85rem;
    margin: 2px 0 0;
}

.panel-body {
    padding: 20px;
}

.panel-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--vms-border);
    background: #fafbfd;
    border-radius: 0 0 var(--vms-radius) var(--vms-radius);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.table-vms {
    margin: 0;
}

.table-vms > :not(caption) > * > * {
    padding: 12px 20px;
    border-bottom-color: var(--vms-border);
}

.table-vms thead th {
    background: #f8fafc;
    color: var(--vms-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table-vms tbody tr:hover {
    background: #f8fafc;
}

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

.cell-main {
    font-weight: 600;
    color: var(--vms-text);
}

.cell-sub {
    display: block;
    font-size: 0.82rem;
    color: var(--vms-muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-ok { background: #dcfce7; color: #15803d; }
.status-info { background: #dbeafe; color: #1d4ed8; }
.status-warn { background: #fef3c7; color: #b45309; }
.status-bad { background: #fee2e2; color: #b91c1c; }
.status-muted { background: #e2e8f0; color: #475569; }

.role-pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 6px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.78rem;
    font-weight: 600;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--vms-surface);
    border: 1px solid var(--vms-border);
    border-radius: var(--vms-radius);
    padding: 18px 20px;
    display: flex;
    gap: 14px;
    align-items: center;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    color: var(--vms-primary);
}

.stat-icon.green { background: #ecfdf5; color: #059669; }
.stat-icon.amber { background: #fffbeb; color: #d97706; }
.stat-icon.red { background: #fef2f2; color: #dc2626; }
.stat-icon.violet { background: #f5f3ff; color: #7c3aed; }

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    color: var(--vms-muted);
    font-size: 0.85rem;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--vms-muted);
}

.form-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--vms-muted);
    margin: 0 0 12px;
}

.subscription-banner {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 20px;
    border-radius: var(--vms-radius);
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: #fff;
    margin-bottom: 20px;
}

.subscription-banner.warn {
    background: linear-gradient(135deg, #92400e, #d97706);
}

.subscription-banner .big {
    font-size: 1.6rem;
    font-weight: 700;
}

.search-box {
    position: relative;
}

.search-box .icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--vms-muted);
}

.search-box input {
    padding-left: 34px;
    min-width: 240px;
}

/* ---------- Sign-in (split screen) ---------- */
.auth-split {
    display: flex;
    min-height: 100vh;
}

.auth-hero {
    flex: 1.1;
    background: radial-gradient(circle at 15% 20%, #1d4ed8 0%, #0f172a 60%);
    color: #e2e8f0;
    padding: 40px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.auth-hero-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
}

.auth-hero-copy h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    max-width: 520px;
}

.auth-hero-copy p {
    color: #cbd5e1;
    max-width: 480px;
    font-size: 1.05rem;
}

.auth-hero-copy ul {
    list-style: none;
    padding: 0;
    margin: 24px 0 0;
}

.auth-hero-copy li {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    color: #e2e8f0;
}

.auth-hero-copy li .icon {
    color: #22d3ee;
}

.auth-hero-foot {
    color: #64748b;
    font-size: 0.85rem;
}

.auth-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: 40px 24px;
}

.auth-form-wrap {
    width: 100%;
    max-width: 380px;
}

.auth-form-wrap h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-form-wrap .lead-text {
    color: var(--vms-muted);
    margin-bottom: 24px;
}

/* ---------- Small screens ---------- */
@media (max-width: 991.98px) {
    .admin-shell {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
        padding: 10px 12px;
    }

    .sidebar-brand {
        padding: 0 8px 0 0;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-section {
        display: none;
    }

    .admin-topbar {
        position: static;
        padding: 0 16px;
    }

    .admin-content {
        padding: 18px 14px;
    }

    .auth-hero {
        display: none;
    }
}

/* Blazor's "An unhandled error has occurred" bar, hidden until Blazor shows it */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    color: #000;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

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

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

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