/* Modern Control Panel Design System */
:root {
    /* Primary Colors */
    --primary-50: #f0f9ff;
    --primary-100: #e0f2fe;
    --primary-200: #bae6fd;
    --primary-500: #0ea5e9;
    --primary-600: #0284c7;
    --primary-700: #0369a1;
    --primary-800: #075985;
    --primary-900: #0c4a6e;

    /* Neutral Colors */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Semantic Colors */
    --success-50: #f0fdf4;
    --success-500: #22c55e;
    --success-600: #16a34a;
    --error-50: #fef2f2;
    --error-500: #ef4444;
    --error-600: #dc2626;
    --warning-50: #fffbeb;
    --warning-500: #f59e0b;
    --warning-600: #d97706;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

html, body {
    font-family: 'Inter', 'Segoe UI', 'Roboto', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    background-color: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    font-size: 0.875rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--gray-900);
    margin-bottom: var(--space-4);
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

/* Links */
a, .btn-link {
    color: var(--primary-600);
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}

a:hover, .btn-link:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

/* Modern Button System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

.btn-primary:hover {
    background-color: var(--primary-700);
    border-color: var(--primary-700);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--gray-200);
}

.btn-secondary:hover {
    background-color: var(--gray-200);
    border-color: var(--gray-300);
    color: var(--gray-800);
}

.btn-success {
    background-color: var(--success-600);
    color: white;
    border-color: var(--success-600);
}

.btn-success:hover {
    background-color: var(--success-700);
    border-color: var(--success-700);
    color: white;
}

.btn-danger {
    background-color: var(--error-600);
    color: white;
    border-color: var(--error-600);
}

.btn-danger:hover {
    background-color: var(--error-700);
    border-color: var(--error-700);
    color: white;
}

/* Form Controls */
.form-control, .form-select {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    background-color: white;
    color: var(--gray-900);
    transition: all 0.2s ease-in-out;
    font-size: 0.875rem;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

/* Cards */
.card {
    background-color: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.2s ease-in-out;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card-header {
    background-color: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: var(--space-4) var(--space-6);
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: var(--space-6);
}

/* Tables */
.table {
    background-color: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.table th {
    background-color: var(--gray-50);
    color: var(--gray-700);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--gray-200);
}

.table td {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-900);
}

.table tbody tr:hover {
    background-color: var(--gray-50);
}

/* Modern Dashboard Cards */
.dashboard-card {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border: none;
    border-radius: var(--radius-xl);
    overflow: hidden;
    position: relative;
}

.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

.dashboard-card .card-title {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0;
}

.dashboard-card .card-text {
    font-size: 2.25rem;
    font-weight: 700;
    margin: 0;
}

/* Content Spacing */
.content {
    padding: var(--space-8);
    background-color: var(--gray-50);
    min-height: calc(100vh - 3.5rem);
}

/* Focus States */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px var(--primary-100);
    outline: none;
}

h1:focus {
    outline: none;
}

/* Form Validation */
.valid.modified:not([type=checkbox]) {
    border-color: var(--success-500);
    box-shadow: 0 0 0 3px var(--success-50);
}

.invalid {
    border-color: var(--error-500);
    box-shadow: 0 0 0 3px var(--error-50);
}

.validation-message {
    color: var(--error-600);
    font-size: 0.75rem;
    margin-top: var(--space-1);
}

/* Error Boundary */
.blazor-error-boundary {
    background: linear-gradient(135deg, var(--error-500), var(--error-600));
    padding: var(--space-4) var(--space-6);
    color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin: var(--space-4);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* Utility Classes */
.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--gray-500);
}

.text-primary {
    color: var(--primary-600);
}

.text-success {
    color: var(--success-600);
}

.text-error {
    color: var(--error-600);
}

.text-warning {
    color: var(--warning-600);
}

/* Responsive Utilities */
@media (max-width: 768px) {
    .content {
        padding: var(--space-4);
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
    
    /* Mobile-friendly tables */
    .table-responsive {
        font-size: 0.8rem;
    }
    
    /* Mobile dashboard cards */
    .dashboard-card .card-text {
        font-size: 1.75rem;
    }
    
    /* Mobile navigation improvements */
    .navbar-brand {
        font-size: 1rem;
    }
    
    /* Mobile form spacing */
    .card-body {
        padding: var(--space-4);
    }
}

@media (max-width: 576px) {
    .content {
        padding: var(--space-3);
    }
    
    /* Smaller cards on mobile */
    .dashboard-card .card-text {
        font-size: 1.5rem;
    }
    
    /* Stack elements vertically on very small screens */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .d-flex.justify-content-between .btn {
        align-self: stretch;
    }
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--gray-300);
    border-radius: 50%;
    border-top-color: var(--primary-600);
    animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-card {
    background: linear-gradient(90deg, var(--gray-100) 25%, rgba(255, 255, 255, 0.5) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Enhanced Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.3s ease-in-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .card {
        border-width: 0.5px;
    }
    
    .table th {
        border-width: 0.5px;
    }
}