/* ---------------------------------------------------------------
   KredoikoUSM – Modern dark-sidebar theme
   --------------------------------------------------------------- */

:root {
    --sidebar-bg: #0f1117;
    --sidebar-width: 250px;
    --sidebar-accent: #6c63ff;
    --sidebar-hover: rgba(108,99,255,.15);
    --sidebar-text: #a8b2c8;
    --topbar-bg: #ffffff;
    --topbar-height: 60px;
    --body-bg: #f4f6fb;
    --card-bg: #ffffff;
    --card-border: #e8ecf4;
    --text-primary: #1a1f36;
    --text-muted: #6b7280;
    --accent: #6c63ff;
    --accent-light: rgba(108,99,255,.1);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,.1);
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    background: var(--body-bg);
    color: var(--text-primary);
    margin: 0; padding: 0;
    height: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4,h5,h6 { font-weight: 600; color: var(--text-primary); }
h1:focus { outline: none; }

/* Layout */
.page { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-row {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0; z-index: 50;
    box-shadow: var(--shadow-sm);
    gap: .75rem;
}

.top-row a { color: var(--text-muted); font-size: .85rem; }
.top-row a:hover { color: var(--accent); text-decoration: none; }
article.content { padding: 1.75rem; flex: 1; }

/* Sidebar brand */
.sidebar-brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-brand-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.1rem; flex-shrink: 0;
}

.sidebar-brand-text { font-size: .95rem; font-weight: 700; color: #fff; }
.sidebar-brand-sub { font-size: .7rem; color: var(--sidebar-text); margin-top: 1px; }

/* Sidebar nav */
.sidebar-nav {
    flex: 1; padding: .75rem .75rem 0;
    overflow-y: auto; overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.nav-section-label {
    font-size: .65rem; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; color: rgba(168,178,200,.45);
    padding: 1rem .5rem .35rem;
}

.nav-item { margin: 1px 0; }

.nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .85rem; border-radius: 8px;
    color: var(--sidebar-text) !important;
    font-size: .85rem; font-weight: 500;
    transition: background .15s, color .15s; white-space: nowrap;
}

.nav-link:hover { background: var(--sidebar-hover); color: #fff !important; text-decoration: none; }

.nav-link.active {
    background: linear-gradient(135deg, rgba(108,99,255,.35), rgba(108,99,255,.2));
    color: #fff !important;
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-link i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }

/* Sidebar footer */
.sidebar-footer { padding: .85rem .75rem; border-top: 1px solid rgba(255,255,255,.06); }

.sidebar-user {
    display: flex; align-items: center; gap: .65rem;
    padding: .5rem .6rem; border-radius: 8px;
    transition: background .15s; cursor: pointer;
}

.sidebar-user:hover { background: var(--sidebar-hover); }

.sidebar-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: .75rem; font-weight: 700; flex-shrink: 0;
}

.sidebar-user-info { flex: 1; overflow: hidden; min-width: 0; }
.sidebar-user-name { font-size: .8rem; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .68rem; color: var(--sidebar-text); }

/* Cards */
.usm-card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem;
}

.usm-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.usm-card-title { font-size: .95rem; font-weight: 600; color: var(--text-primary); margin: 0; }

/* Stat cards */
.stat-card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem; display: flex; align-items: center; gap: 1rem;
    transition: box-shadow .2s, transform .2s;
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
    width: 52px; height: 52px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.35rem; flex-shrink: 0;
}

.stat-icon.purple { background: rgba(108,99,255,.12); color: #6c63ff; }
.stat-icon.green  { background: rgba(34,197,94,.12);  color: #22c55e; }
.stat-icon.blue   { background: rgba(59,130,246,.12); color: #3b82f6; }
.stat-icon.orange { background: rgba(245,158,11,.12); color: #f59e0b; }
.stat-icon.red    { background: rgba(239,68,68,.12);  color: #ef4444; }
.stat-icon.teal   { background: rgba(20,184,166,.12); color: #14b8a6; }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--text-primary); }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }
.stat-sub   { font-size: .72rem; margin-top: .15rem; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem; }
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-subtitle { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }

/* Badges */
.usm-badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge-success { background: rgba(34,197,94,.12);  color: #16a34a; }
.badge-danger  { background: rgba(239,68,68,.12);  color: #dc2626; }
.badge-warning { background: rgba(245,158,11,.12); color: #d97706; }
.badge-info    { background: rgba(59,130,246,.12); color: #2563eb; }
.badge-muted   { background: rgba(107,114,128,.1); color: #6b7280; }
.badge-purple  { background: rgba(108,99,255,.12); color: #6c63ff; }

/* Buttons */
.btn-usm-primary {
    background: linear-gradient(135deg, #6c63ff, #a78bfa); color: #fff; border: none;
    border-radius: 8px; padding: .5rem 1.1rem; font-size: .85rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
    transition: opacity .15s, transform .15s;
}
.btn-usm-primary:hover { opacity: .9; transform: translateY(-1px); color: #fff; }

.btn-usm-outline {
    background: transparent; color: var(--accent); border: 1.5px solid var(--accent);
    border-radius: 8px; padding: .45rem 1rem; font-size: .85rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
    transition: background .15s, color .15s;
}
.btn-usm-outline:hover { background: var(--accent-light); color: var(--accent); text-decoration: none; }

.btn-icon {
    width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--card-border);
    background: var(--card-bg); display: inline-flex; align-items: center; justify-content: center;
    font-size: .85rem; color: var(--text-muted); cursor: pointer; transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--accent-light); color: var(--accent); }

/* Tables */
.usm-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.usm-table th {
    background: #f8fafc; border-bottom: 1.5px solid var(--card-border);
    padding: .7rem 1rem; font-size: .72rem; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--text-muted); text-align: left; white-space: nowrap;
}
.usm-table td { padding: .75rem 1rem; border-bottom: 1px solid #f0f2f8; color: var(--text-primary); vertical-align: middle; }
.usm-table tr:last-child td { border-bottom: none; }
.usm-table tbody tr:hover td { background: #f8faff; }

/* Status dots */
.online-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--success);
    display: inline-block; box-shadow: 0 0 0 2px rgba(34,197,94,.25);
    animation: pulse-dot 2s infinite;
}
.offline-dot { width: 8px; height: 8px; border-radius: 50%; background: #d1d5db; display: inline-block; }

@keyframes pulse-dot {
    0%,100% { box-shadow: 0 0 0 2px rgba(34,197,94,.25); }
    50%      { box-shadow: 0 0 0 4px rgba(34,197,94,.1); }
}

/* Forms */
.usm-form-control {
    width: 100%; padding: .55rem .85rem; border: 1.5px solid var(--card-border);
    border-radius: 8px; font-size: .85rem; color: var(--text-primary);
    background: var(--card-bg); transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.usm-form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,99,255,.12); }
.usm-form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-primary); margin-bottom: .35rem; }

/* Login */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1117 0%, #1a1f36 50%, #0f1117 100%);
    display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.login-card {
    background: #fff; border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
    width: 100%; max-width: 400px; padding: 2.5rem 2rem;
}
.login-logo {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    border-radius: 14px; display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: #fff; margin: 0 auto 1.25rem;
}

/* Misc */
.text-muted-sm { font-size: .78rem; color: var(--text-muted); }
.divider { border: none; border-top: 1px solid var(--card-border); margin: 1rem 0; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; opacity: .3; margin-bottom: .75rem; display: block; }

.skeleton {
    background: linear-gradient(90deg, #f0f2f8 25%, #e8ecf4 50%, #f0f2f8 75%);
    background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 0; }
    main { margin-left: 0; }
    .sidebar.open { width: var(--sidebar-width); }
}

/* Blazor overrides */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); font-size: .78rem; margin-top: .2rem; }

.blazor-error-boundary {
    background: #fef2f2; border: 1px solid #fecaca;
    border-radius: var(--radius); padding: 1rem 1rem 1rem 3rem; color: #991b1b; font-size: .85rem;
}
.blazor-error-boundary::after { content: "An unhandled error has occurred."; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #1a1f36; color: #fff; padding: .75rem 1.5rem;
    font-size: .85rem; z-index: 9999; align-items: center; justify-content: space-between;
}
#blazor-error-ui a { color: #a78bfa; }
#blazor-error-ui .dismiss { cursor: pointer; font-size: 1.1rem; }

/* -- Layout overflow fix -- */
html, body { overflow-x: hidden; }

main {
    min-width: 0;
    overflow-x: hidden;
}

article.content {
    min-width: 0;
    overflow-x: auto;
}

.usm-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* -- Modal -- */
.usm-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,17,23,.55);
    backdrop-filter: blur(4px);
    z-index: 1040;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    animation: fadeIn .15s ease;
}

@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }

.usm-modal {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0,0,0,.25);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp .18s ease;
}

.usm-modal-lg { max-width: 720px; }
.usm-modal-sm { max-width: 400px; }

@keyframes slideUp { from { transform: translateY(16px); opacity:0 } to { transform: translateY(0); opacity:1 } }

.usm-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--card-border);
    flex-shrink: 0;
}

.usm-modal-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin: 0; }

.usm-modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.usm-modal-footer {
    display: flex; align-items: center; justify-content: flex-end; gap: .6rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--card-border);
    flex-shrink: 0;
}

/* Detail rows inside modals */
.detail-row { display: flex; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid #f0f2f8; font-size: .85rem; }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); min-width: 130px; flex-shrink: 0; font-weight: 500; }
.detail-value { color: var(--text-primary); font-weight: 600; word-break: break-all; }

/* Actions column */
.actions-col { display: flex; align-items: center; gap: .35rem; }
