:root {
    --brand: #1d9bf0;
    --brand-dark: #0b7fcc;
    --brand-grad: linear-gradient(135deg, #1d9bf0 0%, #6c63ff 100%);
    --sidebar-bg: #131a2a;
    --sidebar-bg2: #0e1422;
    --sidebar-text: #aab4c8;
    --sidebar-active: #1d9bf0;
    --content-bg: #f4f6fb;
    --card-shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
    --radius: 12px;
}

html, body {
    font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--content-bg);
    color: #1f2937;
}

a, .btn-link { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); }

h1:focus { outline: none; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 248px;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
    color: var(--sidebar-text);
    display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; left: 0;
    overflow-y: auto;
    transition: transform .2s ease;
    z-index: 100;
}
body.sidebar-collapsed .app-sidebar { transform: translateX(-248px); }
body.sidebar-collapsed .app-main { margin-left: 0; }

.app-main { flex: 1; margin-left: 248px; display: flex; flex-direction: column; transition: margin .2s ease; }

.app-topbar {
    height: 60px; background: #fff; border-bottom: 1px solid #e6e9f0;
    display: flex; align-items: center; gap: 16px; padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
}
.sidebar-toggle { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: #6b7280; }
.topbar-title { font-weight: 600; font-size: 1.1rem; flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%; background: var(--brand-grad);
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.user-info { line-height: 1.15; }
.user-name { font-weight: 600; font-size: .9rem; }
.user-role { font-size: .72rem; color: #9ca3af; }
.btn-logout { background: none; border: none; font-size: 1.2rem; color: #9ca3af; cursor: pointer; margin-left: 6px; }
.btn-logout:hover { color: #ef4444; }

.app-content { padding: 24px; flex: 1; }

.app-loading { display: flex; align-items: center; justify-content: center; height: 100vh; }
.spinner {
    width: 42px; height: 42px; border: 4px solid #e6e9f0; border-top-color: var(--brand);
    border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Sidebar nav ---------- */
.nav-brand {
    display: flex; align-items: center; gap: 10px; padding: 20px 22px; color: #fff;
    font-size: 1.25rem; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-logo { font-size: 1.5rem; }
.nav-sections { padding: 14px 12px; }
.nav-group { margin-bottom: 18px; }
.nav-group-title {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
    color: #5a6783; padding: 4px 12px 8px; font-weight: 600;
}
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0;
    border-radius: 9px; color: var(--sidebar-text); font-size: .9rem; cursor: pointer;
    transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(29,155,240,.35); }
.nav-icon { width: 20px; text-align: center; font-size: 1rem; }

/* ---------- Buttons ---------- */
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn { border-radius: 8px; }
.btn:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 .2rem rgba(29,155,240,.2);
    border-color: var(--brand);
}

/* ---------- Cards / tables ---------- */
.card { border: 1px solid #e9edf5; border-radius: var(--radius); box-shadow: var(--card-shadow); }
.table { --bs-table-hover-bg: #f0f6ff; }
.table > thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; border-bottom: 2px solid #eef1f6; }
.modal-content { border: none; border-radius: 14px; box-shadow: 0 20px 50px rgba(16,24,40,.2); }
.form-control, .form-select { border-radius: 8px; border-color: #d8dee9; }
.badge { font-weight: 600; }

h4 { font-weight: 700; }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--brand-grad); padding: 20px;
}
.login-card {
    background: #fff; border-radius: 18px; box-shadow: 0 24px 60px rgba(0,0,0,.25);
    width: 100%; max-width: 400px; padding: 40px 36px;
}
.login-logo { text-align: center; font-size: 2.6rem; margin-bottom: 6px; }
.login-title { text-align: center; font-weight: 700; font-size: 1.5rem; margin-bottom: 2px; }
.login-sub { text-align: center; color: #9ca3af; font-size: .9rem; margin-bottom: 26px; }

/* ---------- Misc ---------- */
.conv-item:hover { background: #f6f8fc; }
.quick-item:hover { background: #f0f6ff; }

#blazor-error-ui {
    background: #fff3cd; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.validation-message { color: #e50000; }

@media (max-width: 768px) {
    .app-sidebar { transform: translateX(-248px); }
    .app-main { margin-left: 0; }
    body:not(.sidebar-collapsed) .app-sidebar { transform: translateX(0); }
}
