:root {
    color-scheme: dark;
}

html, body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #0d1117; /* GitHub-style dark */
    color: #c9d1d9;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    color: #f0f6fc;
    font-weight: 600;
}

a, .btn-link {
    color: #58a6ff;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover, .btn-link:hover {
    color: #79c0ff;
    text-decoration: underline;
}

.btn-primary {
    color: #ffffff;
    background-color: #238636; /* green-ish primary */
    border-color: rgba(240, 246, 252, 0.1);
    font-weight: 500;
    border-radius: 6px;
}

.btn-primary:hover {
    background-color: #2ea043;
    border-color: rgba(240, 246, 252, 0.1);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.3);
}

.content {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* Redesigning Layout structure to top-nav */
.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
}

.top-navbar {
    background-image: none;
    background-color: #161b22;
    border-bottom: 1px solid #30363d;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.top-row {
    display: none; /* Hide old sidebar top row */
}

/* Navbar overrides */
.navbar-brand {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #f0f6fc !important;
    display: flex;
    align-items: center;
}

.navbar-brand img {
    border-radius: 4px;
}

.nav-link {
    color: #8b949e !important;
    font-weight: 500;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
}

.nav-link i, .nav-link .bi {
    line-height: 1;
}

.nav-link:hover, .nav-link.active {
    color: #f0f6fc !important;
}

.nav-item {
    margin-right: 0.5rem;
}

/* Ensure navbar items are centered when collapsed */
@media (max-width: 991px) {
    .navbar-collapse {
        text-align: center;
        padding-bottom: 1rem;
    }
    .navbar-nav {
        align-items: center;
    }
    .nav-item {
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
}

/* Force horizontal nav on medium screens if desired, but respect Bootstrap expand */
@media (min-width: 768px) {
    .navbar-expand-md .navbar-nav {
        flex-direction: row;
    }
}

/* Responsive adjustment for top-nav */
@media (min-width: 992px) {
    .top-navbar {
        height: auto;
    }
}

/* Cards and containers */
.card {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
}

.card-header {
    background-color: #161b22;
    border-bottom: 1px solid #30363d;
    padding: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Footer redesign */
.site-footer {
    border-top: 1px solid #30363d;
    padding: 0.5rem 0;
    margin-top: auto;
    background-color: #0d1117;
    color: #ffffff;
    font-size: 0.8rem;
}

.site-footer .container {
    max-width: 900px;
}

.site-footer p {
    margin-bottom: 0 !important;
}

.site-footer a {
    color: #ffffff;
}

.site-footer a:hover {
    color: #58a6ff;
}

.version-string {
    font-family: monospace;
    opacity: 0.8;
    color: #ffffff;
}

/* Custom modern scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #0d1117;
}

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

.hero-section {
    background: linear-gradient(135deg, #161b22 0%, #0d1117 100%);
    border: 1px solid #30363d;
}

.transition-all {
    transition: all 0.2s ease-in-out;
}

.list-group-item-action:hover {
    background-color: rgba(110, 118, 129, 0.1) !important;
}

.text-primary { color: #58a6ff !important; }
.text-secondary { color: #8b949e !important; }

.btn-outline-light {
    color: #f0f6fc;
    border-color: #30363d;
}

.btn-outline-light:hover {
    background-color: #30363d;
    border-color: #8b949e;
}

.valid.modified:not([type=checkbox]) { outline: 1px solid #3fb950; }
.invalid { outline: 1px solid #ef4444; }
.validation-message { color: #f87171; }

/* Tables: dark-friendly */
.table { --bs-table-bg: transparent; --bs-table-striped-bg: rgba(255,255,255,0.06); --bs-table-color: #f0f6fc; --bs-table-border-color: #30363d; }
.table thead, .table .table-light, .table-light { background-color: #161b22 !important; color: #f0f6fc !important; font-weight: 600; }
.table tbody tr { background-color: transparent; }
.table-hover tbody tr:hover { background-color: rgba(255,255,255,0.04); }

/* Make external login names white for better readability */
#external-logins table td,
#external-auth-form table td,
.table td {
    color: #ffffff !important;
}

/* Make small/muted text more readable on dark */
.text-muted { color: #8b949e !important; }
.form-text { color: #8b949e; }

/* Forms */
.form-control, .form-select, .form-check-input, .form-control:disabled {
    background-color: #0d1117;
    color: #c9d1d9;
    border-color: #30363d;
    border-radius: 6px;
}
.form-control::placeholder { color: #484f58; }
.form-check-input:checked { background-color: #238636; border-color: rgba(240, 246, 252, 0.1); }
.form-dark-control { color: #ffffff; }

/* Alerts */
.alert { color: #c9d1d9; border-color: #30363d; border-radius: 6px; }
.alert-danger { background-color: rgba(248, 81, 73, 0.1); border-color: rgba(248, 81, 73, 0.4); color: #f85149; }
.alert-success { background-color: rgba(63, 185, 80, 0.1); border-color: rgba(63, 185, 80, 0.4); color: #3fb950; }
.alert-warning { background-color: rgba(210, 153, 34, 0.1); border-color: rgba(210, 153, 34, 0.4); color: #d29922; }

/* Ensure alerts are dark-themed for readability */
/* Boostrap 5 alerts use CSS variables; set both variables and properties for robustness */
.alert.alert-secondary,
.alert.alert-info {
    --bs-alert-bg: #161b22 !important;
    --bs-alert-border-color: #30363d !important;
    --bs-alert-color: #c9d1d9 !important;
    background-color: #161b22 !important;
    border-color: #30363d !important;
    color: #c9d1d9 !important;
}

/* Dedicated helper for any alert needing a dark background explicitly */
.alert.alert-dark {
    --bs-alert-bg: #0d1117 !important;
    --bs-alert-border-color: #30363d !important;
    --bs-alert-color: #c9d1d9 !important;
    background-color: #0d1117 !important;
    border-color: #30363d !important;
    color: #c9d1d9 !important;
}

/* Links inside alerts should remain readable */
.alert a { color: #58a6ff; }

/* Error boundary */
.blazor-error-boundary {
    background-color: #311c1c;
    padding: 1rem;
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.4);
    border-radius: 6px;
}
.blazor-error-boundary::after { content: "An error has occurred." }

.darker-border-checkbox.form-check-input { border-color: #484f58; }

/* Code styling for better legibility */
code, kbd {
    background-color: rgba(110, 118, 129, 0.4);
    color: #f0f6fc;
    padding: 0.2em 0.4em;
    border-radius: 6px;
    font-size: 85%;
}

kbd {
    background-color: #30363d;
    border: 1px solid #484f58;
    box-shadow: inset 0 -1px 0 #21262d;
}

pre code {
    display: block;
    padding: 1rem;
    overflow-x: auto;
    background-color: #161b22;
    border: 1px solid #30363d;
}

/* Badges: ensure secondary has contrast on dark */
.badge.bg-secondary { background-color: #30363d !important; color: #c9d1d9 !important; }

/* Blazor error UI - Hidden by default, shown by framework on fatal error */
#blazor-error-ui {
    background: #311c1c;
    color: #f85149;
    bottom: 0;
    box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.5);
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
    border-top: 1px solid rgba(248, 81, 73, 0.4);
}

#blazor-error-ui .reload {
    margin-left: 0.5rem;
    color: #58a6ff;
    font-weight: 600;
}

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

#blazor-error-ui .dismiss:hover {
    color: #f0f6fc;
}
