/* Root Variables */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-bg: #f8f9fc;
    --card-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    --sidebar-width: 250px;
}

/* Base Styles */
html, body {
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--light-bg);
    color: #333;
}

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

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--primary-color);
}

/* Buttons */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    background: var(--primary-gradient);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

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

.btn-outline-primary:hover {
    background: var(--primary-gradient);
    border-color: transparent;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Tab navigation (Reports page and similar) uses <button> elements as tabs
   instead of <a>. Bootstrap 5.3's .nav-tabs colors come from CSS custom
   properties (--bs-nav-tabs-link-active-color etc.) that resolve to white
   here, making the active tab's label invisible against its white background.
   !important is used deliberately - this must always win regardless of how
   those variables resolve, since invisible tab text is a real usability bug. */
.nav-tabs .nav-link {
    color: #495057 !important;
    background: none;
    border: 1px solid transparent;
}

.nav-tabs .nav-link.active {
    color: #495057 !important;
    background-color: #fff !important;
    border-color: #dee2e6 #dee2e6 #fff !important;
}

.nav-tabs .nav-link:hover:not(.active) {
    color: #667eea !important;
    border-color: #e9ecef #e9ecef #dee2e6 !important;
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 0.5rem 2rem rgba(58, 59, 69, 0.15);
}

.card-header {
    background-color: white;
    border-bottom: 1px solid #e3e6f0;
    font-weight: 600;
}

/* Forms */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #d1d3e2;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    min-height: 44px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Larger input fields in tables */
.table .form-control, .table .form-select {
    min-width: 120px;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
}

.table .form-control-sm, .table .form-select-sm {
    min-width: 100px;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    min-height: 40px;
}

/* Number inputs should be wider to show full values */
.table input[type="number"] {
    min-width: 110px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.form-label {
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.input-group-text {
    border-radius: 8px 0 0 8px;
    background-color: #f8f9fa;
    border: 1px solid #d1d3e2;
    color: #6c757d;
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table thead th {
    border-bottom: 2px solid #e3e6f0;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #e3e6f0;
}

.table-hover tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.5em 0.75em;
    border-radius: 6px;
}

.badge.bg-primary {
    background: var(--primary-gradient) !important;
}

.badge.bg-info {
    background-color: #36b9cc !important;
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.alert-info {
    background-color: #e7f4ff;
    color: #0c5460;
}

/* Content Area */
.content {
    padding-top: 1.5rem;
}

/* Validation Styles */
.valid.modified:not([type=checkbox]) {
    outline: 2px solid #28a745;
    outline-offset: -2px;
}

.invalid {
    outline: 2px solid #dc3545;
    outline-offset: -2px;
}

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

/* Error UI */
#blazor-error-ui {
    background: #fef3cd;
    bottom: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: none;
    left: 0;
    padding: 1rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    border-top: 3px solid #ffc107;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3NDEgMjM2LjA1MSA5NC4wODg2IDIzNi4xNDQgOTMuODE1MSAyMzYuMjU4IDkzLjQ1MDIgMjM2LjM4NyA5My4wOTE4IDIzNi41NiA5Mi43Mzk4TDI1OS40NzUgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OC40NTggNjguMjg5NyAyNTguNDU4IDcxLjEzNzkgMjU4LjQ1OCA3Mi4zMTA1IDI1OC43MDkgNzMuNDI5MSAyNTkuMTU2IDc0LjQzMDVMMjYwLjczMSA4MC4yMDMyQzI2MS4zMDQgODEuODAwNCAyNjIuNzkzIDgyLjk1NDQgMjY0LjUyNSA4Mi45NTQ0IDI2Ni4yNTggODIuOTU0NCAyNjcuNzQ3IDgxLjgwMDQgMjY4LjMyIDgwLjIwMzJMMjY5Ljg5NSA3NC40MzA1QzI3MC4zNDIgNzMuNDI5MSAyNzAuNTkzIDcyLjMxMDUgMjcwLjU5MyA3MS4xMzc5IDI3MC41OTMgNjguMjg5NyAyNjguMzE0IDY2LjAxODMgMjY1LjQ2NSA2Ni4wMTgzTDI2My41ODYgNjYuMDE4M1oiIGZpbGw9IiNGRjU1NTUiLz48L2c+PC9zdmc+) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: 8px;
}

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

/* Layout */
.page {
    position: relative;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    background-color: var(--light-bg);
}

/* Sidebar */
.sidebar {
    background: linear-gradient(180deg, #1a1f36 0%, #252d47 100%);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
}

/* Top Row */
.top-row {
    background-color: white;
    border-bottom: 1px solid #e3e6f0;
    justify-content: flex-end;
    height: 4rem;
    display: flex;
    align-items: center;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
}

.top-row ::deep a, .top-row ::deep .btn-link {
    white-space: nowrap;
    margin-left: 1.5rem;
    text-decoration: none;
}

.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
    text-decoration: underline;
}

.top-row ::deep a:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Spinner */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Stat Cards */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-card .stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-card .stat-icon.primary {
    background: var(--primary-gradient);
}

.stat-card .stat-icon.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.stat-card .stat-icon.warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
}

.stat-card .stat-icon.info {
    background: linear-gradient(135deg, #17a2b8 0%, #6610f2 100%);
}

/* Responsive Styles */
@media (max-width: 640.98px) {
    .top-row:not(.auth) {
        display: none;
    }

    .top-row.auth {
        justify-content: space-between;
    }

    .top-row ::deep a, .top-row ::deep .btn-link {
        margin-left: 0;
    }
}

@media (min-width: 641px) {
    .page {
        flex-direction: row;
    }

    .sidebar {
        width: var(--sidebar-width);
        height: 100vh;
        position: sticky;
        top: 0;
    }

    .top-row {
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .top-row.auth ::deep a:first-child {
        flex: 1;
        text-align: right;
        width: 0;
    }

    .top-row, article {
        padding-left: 2rem !important;
        padding-right: 1.5rem !important;
    }
}

/* Navigation */
.nav-scrollable {
    display: block;
    overflow-y: auto;
    height: calc(100vh - 60px);
}

.sidebar .nav-item ::deep a {
    color: #b8c5d6;
    border-radius: 8px;
    height: 3rem;
    display: flex;
    align-items: center;
    line-height: 3rem;
    margin: 0.25rem 0.75rem;
    padding: 0 1rem;
    transition: all 0.2s;
    font-weight: 500;
}

.sidebar .nav-item ::deep a.active {
    background: var(--primary-gradient);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.sidebar .nav-item ::deep a:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: white;
}

.sidebar .nav-item ::deep a .bi {
    margin-right: 0.75rem;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

@media (min-width: 641px) {
    .navbar-toggler {
        display: none;
    }

    .nav-scrollable {
        display: block !important;
    }

    .nav-scrollable.collapse {
        display: block !important;
    }
}

@media (max-width: 640.98px) {
    .nav-scrollable {
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: linear-gradient(180deg, #1a1f36 0%, #252d47 100%);
        z-index: 1000;
    }

    .nav-scrollable.collapse {
        display: none;
    }

    .nav-scrollable.collapse.show,
    .nav-scrollable:not(.collapse) {
        display: block;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .stat-card {
    animation: fadeIn 0.3s ease-out;
}

/* Utility Classes */
.text-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fw-medium {
    font-weight: 500 !important;
}
