/* ========== CSS Variables ========== */
:root {
    --primary: #0077be;
    --primary-dark: #005a91;
    --primary-light: #e6f3fa;
    --accent: #00b74a;
    --accent-dark: #008c38;
    --warning: #ff6b6b;
    --dark: #1a1a2e;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --white: #ffffff;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-lg: 12px;
}

/* ========== Reset & Base ========== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-100);
    min-height: 100vh;
}

/* ========== Loading Screen ========== */
.loading-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.loading-content {
    text-align: center;
    color: var(--white);
}

.loading-content h2 {
    margin-top: 20px;
    font-weight: 600;
}

.loading-content p {
    opacity: 0.8;
    font-size: 14px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

.sidebar {
    width: 260px;
    background: var(--dark);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 160px;
    height: auto;
    filter: brightness(0) invert(1);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.sidebar-header p {
    font-size: 11px;
    opacity: 0.6;
    margin: 2px 0 0 0;
}

.nav-menu {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-section {
    padding: 8px 20px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    margin-top: 16px;
}

.nav-section:first-child {
    margin-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.nav-item.active {
    background: var(--primary);
    color: var(--white);
}

.nav-item span {
    font-size: 18px;
}

.nav-emoji {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-icon {
    width: 18px;
    height: 18px;
    filter: brightness(0) invert(1);
    opacity: 0.75;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.nav-item:hover .nav-icon {
    opacity: 1;
}

.nav-item.active .nav-icon {
    opacity: 1;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px;
    min-height: 100vh;
}

/* ========== Page Header ========== */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-header p {
    color: var(--gray-600);
    margin-top: 4px;
    font-size: 14px;
}

/* ========== Cards ========== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

.card-header span {
    font-size: 20px;
}

/* ========== Form Elements ========== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group input,
.input-group select {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-group .unit {
    padding: 10px 14px;
    background: var(--gray-200);
    border: 1px solid var(--gray-300);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 13px;
    color: var(--gray-600);
    min-width: 50px;
    text-align: center;
}

select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--white);
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-success {
    background: var(--accent);
    color: var(--white);
}

.btn-success:hover {
    background: var(--accent-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* ========== Results ========== */
.results-section {
    margin-top: 24px;
}

.result-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.result-card h3 {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.8;
    margin-bottom: 8px;
}

.result-card .value {
    font-size: 32px;
    font-weight: 700;
}

.result-card .unit {
    font-size: 16px;
    opacity: 0.8;
    margin-left: 4px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.result-item {
    background: var(--gray-100);
    padding: 16px;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.result-item label {
    font-size: 12px;
    color: var(--gray-600);
    display: block;
    margin-bottom: 4px;
}

.result-item .value {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
}

.result-item.success {
    border-left-color: var(--accent);
}

.result-item.warning {
    border-left-color: var(--warning);
    background: #fff5f5;
}

/* ========== Tables ========== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
}

tr:hover td {
    background: var(--gray-100);
}

/* ========== Home Page ========== */
.hero {
    background: linear-gradient(135deg, #1e5a8a 0%, #2980b9 100%);
    color: white;
    padding: 40px 20px;
    text-align: center;
    border-radius: 12px;
    margin-bottom: 30px;
}

.hero h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 16px;
}

.hero p {
    font-size: 18px;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.module-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 32px;
    text-align: center;
    transition: all 0.3s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.module-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.module-card .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.module-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-800);
}

.module-card p {
    font-size: 14px;
    color: var(--gray-600);
}

.module-card .badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    margin-top: 16px;
}

/* ========== Alerts ========== */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #28a745;
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border: 1px solid #dc3545;
    color: #721c24;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .hero h1 {
        font-size: 28px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== Blazor Error UI ========== */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

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

.not-found {
    text-align: center;
    padding: 60px 20px;
}

.not-found h1 {
    font-size: 72px;
    color: var(--primary);
}

.not-found p {
    font-size: 18px;
    color: var(--gray-600);
    margin: 16px 0 24px;
}

.not-found a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
