/* ── Variables ───────────────────────────────────────────── */
:root {
    --bg:        #0f1117;
    --surface:   #181c27;
    --border:    #252a38;
    --accent:    #4f7dff;
    --accent-hi: #7fa0ff;
    --danger:    #ff4f6a;
    --success:   #3ecf8e;
    --text:      #e8eaf2;
    --muted:     #8891aa;
    --sidebar-w: 220px;
    --font-body: 'DM Sans', sans-serif;
    --font-disp: 'Syne', sans-serif;
    --radius:    10px;
    --shadow:    0 4px 24px rgba(0,0,0,.4);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 15px; }
a { color: var(--accent-hi); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: fixed;
    top: 0; left: 0; bottom: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 2rem;
    padding: 0 .5rem;
}

.brand-icon { font-size: 1.6rem; color: var(--accent); }
.brand-name { font-family: var(--font-disp); font-size: .9rem; font-weight: 800; letter-spacing: .02em; }

.sidebar-links { flex: 1; display: flex; flex-direction: column; gap: .25rem; }

.nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem .75rem;
    border-radius: var(--radius);
    color: var(--muted);
    transition: background .15s, color .15s;
    font-size: .9rem;
    font-weight: 500;
}
.nav-item:hover, .nav-item.active {
    background: rgba(79,125,255,.12);
    color: var(--accent-hi);
    text-decoration: none;
}
.nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 1rem; display: flex; flex-direction: column; gap: .5rem; }

.user-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
}
.user-avatar {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; color: #fff;
    flex-shrink: 0;
}
.user-name { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: .4rem .75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .8rem;
    transition: color .15s, border-color .15s;
    font-family: var(--font-body);
}
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }

/* ── Main content ────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; }
.page-container { padding: 2.5rem 2rem; max-width: 1100px; }

/* ── Auth shell ──────────────────────────────────────────── */
.auth-shell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 60% 50% at 20% 30%, rgba(79,125,255,.12) 0%, transparent 70%),
        radial-gradient(ellipse 40% 60% at 80% 70%, rgba(79,125,255,.07) 0%, transparent 70%),
        var(--bg);
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}
.auth-card--wide { max-width: 580px; }

.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-logo { font-size: 2.5rem; color: var(--accent); margin-bottom: .75rem; }
.auth-header h1 { font-family: var(--font-disp); font-size: 1.75rem; font-weight: 800; margin-bottom: .3rem; }
.auth-header p { color: var(--muted); font-size: .9rem; }

.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .875rem; color: var(--muted); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-input {
    background: rgba(255,255,255,.04);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-body);
    font-size: .95rem;
    padding: .6rem .85rem;
    transition: border-color .2s, box-shadow .2s;
    width: 100%;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,125,255,.2); }
.form-input::placeholder { color: var(--muted); }

.form-check { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.25rem; font-size: .875rem; color: var(--muted); }
.form-check input { accent-color: var(--accent); }

.validation-message { color: var(--danger); font-size: .8rem; margin-top: .2rem; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: .75rem 1.5rem;
    font-family: var(--font-disp);
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, transform .1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}
.btn-save {
    width: 20%;
    margin: 0 auto;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hi); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert-error {
    background: rgba(255,79,106,.1);
    border: 1px solid rgba(255,79,106,.3);
    color: #ff8fa0;
    border-radius: var(--radius);
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    font-size: .875rem;
}
.alert-success {
    background: rgba(62,207,142,.1);
    border: 1px solid rgba(62,207,142,.3);
    color: var(--success);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    font-size: .875rem;
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page headers ────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
}
.page-header h1 { font-family: var(--font-disp); font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.subtitle { color: var(--muted); margin-top: .25rem; font-size: .95rem; }

/* ── Stats grid ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex; flex-direction: column; gap: .3rem;
}
.stat-icon { font-size: 1.3rem; color: var(--accent); margin-bottom: .25rem; }
.stat-value { font-family: var(--font-disp); font-size: 1.5rem; font-weight: 800; }
.stat-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── Content card ────────────────────────────────────────── */
.content-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}
.content-card h2 { font-family: var(--font-disp); font-size: 1.15rem; font-weight: 700; margin-bottom: .75rem; }
.content-card p { color: var(--muted); line-height: 1.6; margin-bottom: .75rem; }

.feature-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; padding: 0; }
.feature-list li { color: var(--muted); padding-left: 1.25rem; position: relative; line-height: 1.5; }
.feature-list li::before { content: '→'; position: absolute; left: 0; color: var(--accent); }
.feature-list li strong { color: var(--text); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .25rem .65rem;
    border-radius: 100px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.badge--role   { background: rgba(79,125,255,.15);  color: var(--accent-hi); }
.badge--admin  { background: rgba(255,200,79,.15);  color: #ffc84f; }
.badge--active { background: rgba(62,207,142,.15);  color: var(--success); }
.badge--inactive { background: rgba(255,79,106,.1); color: #ff8fa0; }

/* ── Profile ─────────────────────────────────────────────── */
.profile-card { display: flex; align-items: flex-start; gap: 2rem; }
.profile-avatar {
    width: 80px; height: 80px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-disp); font-size: 2rem; font-weight: 800;
    color: #fff; flex-shrink: 0;
}
.profile-details { flex: 1; display: flex; flex-direction: column; gap: .75rem; }
.detail-row { display: flex; align-items: center; gap: 1rem; border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.detail-label { width: 100px; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; flex-shrink: 0; }
.detail-value { color: var(--text); }

/* ── Config Item ─────────────────────────────────────────────── */
.config-card {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
}

.config-avatar {
    width: 80px;
    height: 80px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-disp);
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.config-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: .75rem;
}

.config-label {
    width: 100px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    flex-shrink: 0;
}

.config-value {
    color: var(--text);
}

.config-valueedit {
    color: black;
    width: 700px
}

/* ── Data table ──────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
    text-align: left; padding: .6rem .75rem;
    font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); border-bottom: 1px solid var(--border);
}
.data-table td { padding: .75rem; border-bottom: 1px solid rgba(255,255,255,.04); color: var(--text); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }

/* ── Blazor error UI ─────────────────────────────────────── */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--danger); color: #fff;
    padding: .75rem 1rem; font-size: .875rem; z-index: 1000;
}
#blazor-error-ui .reload, #blazor-error-ui .dismiss { color: #fff; margin-left: 1rem; text-decoration: underline; cursor: pointer; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .profile-card { flex-direction: column; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
}
