/* Clean Theme CSS Variables that work with MudBlazor */
:root {
    /* Light theme base colors */
    --primary-color: #0d6efd;
    --secondary-color: #6610f2;
    --tertiary-color: #0dcaf0;
    --success-color: #198754;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    --info-color: #0dcaf0;
    
    /* Light theme backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    
    /* Light theme text */
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    
    /* Borders and shadows */
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Dark theme overrides */
[data-theme="dark"] {
    /* Primary colors stay mostly the same but lighter variants */
    --primary-color: #4dabf7;
    --secondary-color: #9775fa;
    --tertiary-color: #22d3ee;
    --success-color: #40c057;
    --warning-color: #ffd43b;
    --error-color: #fa5252;
    --info-color: #22d3ee;
    
    /* Dark theme backgrounds */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    
    /* Dark theme text */
    --text-primary: #ffffff;
    --text-secondary: #e9ecef;
    --text-muted: #adb5bd;
    
    /* Dark borders and shadows */
    --border-color: #495057;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* Base body and html styling */
html, body {
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
    margin: 0;
    padding: 0;
}

/* Ensure MudBlazor components inherit proper theming */
.mud-theme-light,
.mud-theme-dark {
    transition: all 0.3s ease;
}

/* Focus styles for accessibility */
.btn:focus, 
.btn:active:focus, 
.btn-link.nav-link:focus, 
.form-control:focus, 
.form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

h1:focus {
    outline: none;
}

/* Legacy form styles for non-MudBlazor components */
.form-control::placeholder {
    color: var(--text-muted);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--success-color);
}

.invalid {
    outline: 1px solid var(--error-color);
}

.validation-message {
    color: var(--error-color);
}

/* Error boundary */
.blazor-error-boundary {
    background: var(--error-color);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: 4px;
    margin: 1rem;
    box-shadow: 0 2px 4px var(--shadow-color);
}

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

/* Theme-aware scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* MudBlazor specific theme fixes */

/* Ensure proper background colors */
.mud-layout {
    background-color: var(--bg-primary);
}

.mud-drawer {
    background-color: var(--bg-primary);
}

.mud-main-content {
    background-color: var(--bg-primary);
}

/* Dark mode specific MudBlazor fixes */
[data-theme="dark"] .mud-layout {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mud-drawer {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mud-drawer-header {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mud-main-content {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mud-paper {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mud-card {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mud-typography {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mud-nav-link {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .mud-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mud-nav-link.active {
    color: var(--primary-color) !important;
    background-color: rgba(77, 171, 247, 0.15) !important;
}

[data-theme="dark"] .mud-divider {
    background-color: var(--border-color) !important;
}

[data-theme="dark"] .mud-icon-root {
    color: inherit !important;
}

/* Light mode specific fixes to ensure consistency */
[data-theme="light"] .mud-layout {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .mud-drawer {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .mud-main-content {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .mud-typography {
    color: var(--text-primary) !important;
}

[data-theme="light"] .mud-nav-link {
    color: var(--text-secondary) !important;
}

[data-theme="light"] .mud-nav-link:hover {
    background-color: rgba(13, 110, 253, 0.1) !important;
    color: var(--primary-color) !important;
}

[data-theme="light"] .mud-nav-link.active {
    color: var(--primary-color) !important;
    background-color: rgba(13, 110, 253, 0.15) !important;
}

/* Enhanced component styling */
.mud-card {
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.mud-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.mud-button-root {
    transition: all 0.2s ease;
}

.mud-button-root:hover {
    transform: translateY(-1px);
}

.mud-button-root:active {
    transform: translateY(0);
}

/* Input field enhancements */
.mud-input-outlined {
    transition: all 0.2s ease;
}

.mud-input-outlined:hover {
    box-shadow: 0 2px 4px var(--shadow-color);
}

.mud-input-outlined.mud-input-focused {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Navigation enhancements */
.mud-nav-link {
    transition: all 0.2s ease;
    border-radius: 8px;
    margin: 2px 8px;
}

.mud-nav-link:hover {
    transform: translateX(4px);
}

.mud-nav-link.active {
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
}

/* Alert enhancements */
.mud-alert {
    border-radius: 8px;
    border-left: 4px solid;
}

.mud-alert.mud-alert-info {
    border-left-color: var(--info-color);
}

.mud-alert.mud-alert-success {
    border-left-color: var(--success-color);
}

.mud-alert.mud-alert-warning {
    border-left-color: var(--warning-color);
}

.mud-alert.mud-alert-error {
    border-left-color: var(--error-color);
}

/* Table enhancements */
.mud-table {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px var(--shadow-color);
}

/* Progress indicators */
.mud-progress-circular {
    color: var(--primary-color);
}

.mud-progress-linear {
    background-color: var(--bg-tertiary);
}

.mud-progress-linear .mud-progress-linear-bar {
    background-color: var(--primary-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mud-nav-link:hover {
        transform: none;
    }
    
    .mud-card:hover {
        transform: none;
    }
}

/* Monaco Editor theme integration */
#my-editor-id,
.my-editor-class,
.monaco-editor-container {
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px var(--shadow-color);
}

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

@keyframes slideIn {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Apply animations to new components */
.mud-card,
.mud-paper,
.mud-alert {
    animation: fadeIn 0.3s ease-out;
}

.mud-nav-link {
    animation: slideIn 0.2s ease-out;
}

/* Print styles */
@media print {
    .mud-appbar,
    .mud-drawer,
    .theme-toggle-button {
        display: none;
    }
    
    .mud-main-content {
        margin: 0;
        padding: 0;
    }
    
    .mud-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

.e-richtexteditor img {
    max-width: 100%;
    height: auto;
    display: block;
}
