/* Root CSS Variables for theming */
:root {
    /* Default light theme colors - Updated with warm greys */
    --theme-primary: #8b7355; /* Warm brown-grey instead of blue */
    --theme-secondary: #6c757d;
    --theme-success: #28a745;
    --theme-danger: #dc3545;
    --theme-warning: #ffc107;
    --theme-info: #17a2b8;
    --theme-background: #ffffff;
    --theme-surface: #f8f9fa;
    --theme-on-background: #212529;
    --theme-on-surface: #495057;
    --theme-border: #dee2e6;
    --theme-sidebar-background: #2c3e50;
    --theme-sidebar-text: #d7d7d7;
    --theme-sidebar-active: #9c8771; /* Warm grey for sidebar */
    --theme-topbar-background: #f7f7f7;
    --theme-topbar-border: #d6d5d5;
    
    /* Additional variables for better theming */
    --theme-text-muted: #6c757d;
    --theme-input-background: #ffffff;
    --theme-input-focus-background: #ffffff;
    --theme-list-item-background: #ffffff;
    --theme-list-item-hover: #f5f4f2; /* Warm light grey hover */
    --theme-list-item-active: #8b7355; /* Warm brown-grey active */
    --theme-list-item-active-text: #ffffff;
    --theme-button-edit: #5a4a39; /* Darker warm brown for edit buttons */
    --theme-button-edit-hover: #6d573f; /* Lighter hover state */
}

/* Dark theme CSS variables - IMPROVED CONTRAST */
.theme-dark {
    --theme-primary: #d4c0a1; /* Lighter warm beige for better contrast */
    --theme-secondary: #c9bdb3; /* Much lighter and warmer grey for better visibility */
    --theme-success: #51cf66;
    --theme-danger: #ff6b6b;
    --theme-warning: #ffd43b;
    --theme-info: #74c0fc;
    --theme-background: #1a1a1a;
    --theme-surface: *#2d3436;
    --theme-on-background: #ffffff;
    --theme-on-surface: #f0f0f0; /* Lighter text for better contrast */
    --theme-border: #495057;
    --theme-sidebar-background: #1e2328;
    --theme-sidebar-text: #e9ecef;
    --theme-sidebar-active: #d4c0a1; /* Match primary color */
    --theme-topbar-background: #2d3436;
    --theme-topbar-border: #495057;
    color-scheme: dark;
    /* Dark theme specific improvements with better contrast */
    --theme-text-muted: #c0b8b0; /* Warmer, lighter muted text */
    --theme-input-background: #3a3d41; /* Slightly lighter input background */
    --theme-input-focus-background: #454950; /* Better focus contrast */
    --theme-list-item-background: #3a3d41; /* Slightly lighter list background */
    --theme-list-item-hover: #4a4d52; /* Better hover contrast */
    --theme-list-item-active: #d4c0a1; /* Light warm beige for active items */
    --theme-list-item-active-text: #1a1a1a; /* Dark text on light active background */
    --theme-button-edit: #e6d3b8; /* Much lighter edit buttons for dark mode */
    --theme-button-edit-hover: #f0e5d0; /* Even lighter hover state */
}

/* Light theme CSS variables - explicit for clarity */
.theme-light {
    --theme-primary: #8b7355; /* Warm brown-grey */
    --theme-secondary: #6c757d;
    --theme-success: #28a745;
    --theme-danger: #dc3545;
    --theme-warning: #ffc107;
    --theme-info: #17a2b8;
    --theme-background: #ffffff;
    --theme-surface: #f8f9fa;
    --theme-on-background: #212529;
    --theme-on-surface: #495057;
    --theme-border: #dee2e6;
    --theme-sidebar-background: #2c3e50;
    --theme-sidebar-text: #d7d7d7;
    --theme-sidebar-active: #9c8771; /* Warm grey */
    --theme-topbar-background: #f7f7f7;
    --theme-topbar-border: #d6d5d5;
    color-scheme: light;
    
    /* Light theme specific */
    --theme-text-muted: #6c757d;
    --theme-input-background: #ffffff;
    --theme-input-focus-background: #ffffff;
    --theme-list-item-background: #ffffff;
    --theme-list-item-hover: #f5f4f2; /* Warm light grey hover */
    --theme-list-item-active: #8b7355; /* Warm brown-grey active */
    --theme-list-item-active-text: #ffffff;
    --theme-button-edit: #5a4a39; /* Darker warm brown for edit buttons */
    --theme-button-edit-hover: #6d573f; /* Lighter hover state */
}

/* Apply theme to body and html */
html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--theme-background);
    color: var(--theme-on-background);
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

.theme-dark a, .theme-dark .btn-link {
    color: #ffd43b; /* High-contrast yellow for dark theme links */
}



.btn-primary {
    color: #fff;
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
}

.btn-primary:hover {
    background-color: var(--theme-button-edit-hover);
    border-color: var(--theme-button-edit-hover);
}

.btn-secondary {
    color: #fff;
    background-color: var(--theme-button-edit);
    border-color: var(--theme-button-edit);
}

.btn-secondary:hover {
    background-color: var(--theme-button-edit-hover);
    border-color: var(--theme-button-edit-hover);
}

.btn-success {
    color: #fff;
    background-color: var(--theme-success);
    border-color: var(--theme-success);
}

.btn-danger {
    color: #fff;
    background-color: var(--theme-danger);
    border-color: var(--theme-danger);
}

.btn-warning {
    color: #212529;
    background-color: var(--theme-warning);
    border-color: var(--theme-warning);
}

.btn-info {
    background-color: var(--info-bg);
    border-color: var(--info-bg);
    color: var(--info-text);
}

.btn-info:hover {
    background-color: #d3d9df; /* Slightly darker grey on hover for light theme */
    border-color: #d3d9df;
    color: var(--info-text);
}

.theme-dark .btn-info:hover {
    background-color: #4a4f54; /* Slightly darker grey on hover for dark theme */
    border-color: #4a4f54;
    color: #ffffff;
}

.btn-outline-info {
    color: var(--info-bg);
    border-color: var(--info-bg);
    background-color: transparent;
}

.btn-outline-info:hover {
    background-color: var(--info-bg);
    border-color: var(--info-bg);
    color: var(--info-text);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem var(--theme-background), 0 0 0 0.25rem var(--theme-primary);
}

.content {
    padding-top: 1.1rem;
    background-color: var(--theme-background);
    color: var(--theme-on-background);
}

h1:focus {
    outline: none;
}

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

.invalid {
    outline: 1px solid var(--theme-danger);
}

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

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45OTMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZWQiLz48L2c+PC9zdmc+) no-repeat 1rem/1.8rem, var(--theme-danger);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

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

.darker-border-checkbox.form-check-input {
    border-color: var(--theme-secondary);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--theme-secondary);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Form controls - improved for dark theme */
.form-control {
    background-color: var(--theme-input-background);
    border-color: var(--theme-border);
    color: var(--theme-on-background);
}

.form-control:focus {
    background-color: var(--theme-input-focus-background);
    border-color: var(--theme-primary);
    color: var(--theme-on-background);
    box-shadow: 0 0 0 0.2rem rgba(139, 115, 85, 0.25); /* Warm brown shadow */
}

/* Dark theme specific form styling for better contrast */
.theme-dark .form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(212, 192, 161, 0.25); /* Lighter shadow for dark mode */
}

.form-control:disabled {
    background-color: var(--theme-surface);
    opacity: 0.65;
}

/* IMPROVED: Better disabled styling for dark theme contrast */
.theme-dark .form-control:disabled {
    background-color: #2a2e32; /* Darker background for better contrast */
    color: #b0b3b8; /* Lighter text color for better readability */
    border-color: #495057; /* Slightly lighter border */
    opacity: 0.9; /* Reduced opacity for better visibility */
}

.form-select {
    background-color: var(--theme-input-background);
    border-color: var(--theme-border);
    color: var(--theme-on-background);
}

.form-select:focus {
    background-color: var(--theme-input-focus-background);
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 0.2rem rgba(139, 115, 85, 0.25); /* Warm brown shadow */
}

/* Dark theme specific select styling */
.theme-dark .form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(212, 192, 161, 0.25); /* Lighter shadow for dark mode */
}

/* IMPROVED: Fix disabled select contrast in dark theme */
.form-select:disabled {
    background-color: var(--theme-surface);
    opacity: 0.65;
}

.theme-dark .form-select:disabled {
    background-color: #2a2e32; /* Darker background for better contrast */
    color: #b0b3b8; /* Lighter text color for better readability */
    border-color: #495057; /* Slightly lighter border */
    opacity: 0.9; /* Reduced opacity for better visibility */
}

/* Cards */
.card {
    background-color: var(--theme-surface);
    border-color: var(--theme-border);
    color: var(--theme-on-surface);
}

.card-header {
    background-color: var(--theme-surface);
    border-bottom-color: var(--theme-border);
    color: var(--theme-on-surface);
}

.card-body {
    background-color: var(--theme-surface);
    color: var(--theme-on-surface);
}

/* Tables */
.table {
    color: var(--theme-on-background);
}

.table th {
    border-color: var(--theme-border);
    background-color: var(--theme-surface);
    color: var(--theme-on-surface);
}

.table td {
    border-color: var(--theme-border);
}

/* Alerts - improved contrast for dark mode */
.alert-primary {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
    color: white;
}

.alert-secondary {
    background-color: var(--theme-surface);
    border-color: var(--theme-border);
    color: var(--theme-on-surface);
}

/* Dark theme specific alert styling */
.theme-dark .alert-secondary {
    background-color: var(--theme-input-background);
    color: var(--theme-on-background);
}

.alert-success {
    background-color: var(--theme-success);
    border-color: var(--theme-success);
    color: white;
}

.alert-danger {
    background-color: var(--theme-danger);
    border-color: var(--theme-danger);
    color: white;
}

.alert-warning {
    background-color: var(--theme-warning);
    border-color: var(--theme-warning);
    color: #212529;
}

.alert-info {
    background-color: var(--theme-info);
    border-color: var(--theme-info);
    color: white;
}

/* Background utilities */
.bg-light {
    background-color: var(--theme-surface) !important;
    color: var(--theme-on-surface);
}

.bg-white {
    background-color: var(--theme-background) !important;
    color: var(--theme-on-background);
}

/* List group improvements for better dark mode support */
.list-group {
    background-color: transparent;
}

.list-group-item {
    background-color: var(--theme-list-item-background);
    border-color: var(--theme-border);
    color: var(--theme-on-background);
}

.list-group-item:hover {
    background-color: var(--theme-list-item-hover);
    color: var(--theme-on-background);
}

.list-group-item.active {
    background-color: var(--theme-list-item-active) !important;
    border-color: var(--theme-list-item-active) !important;
    color: var(--theme-list-item-active-text) !important;
    font-weight: 500;
}

/* === BOOTSTRAP OVERRIDE FOR LIST ITEMS === */
/* Ensure Bootstrap's active state uses our context-specific colors */
.list-group-item-action.active {
    background-color: var(--list-item-active-bg) !important;
    border-color: var(--list-item-active-bg) !important;
    color: var(--list-item-active-text) !important;
}

/* Job file list specific styling */
.list-group-flush .list-group-item.active {
    background-color: var(--list-item-active-bg) !important;
    border-color: var(--list-item-active-bg) !important;
    color: var(--list-item-active-text) !important;
    border-left: 3px solid var(--primary-btn-bg) !important;
}

.list-group-flush .list-group-item {
    border-left: 0;
    border-right: 0;
}

/* Text utilities improvements */
.text-muted {
    color: var(--theme-text-muted) !important;
}

.text-info {
    color: var(--info-text) !important;
}

small, .small {
    color: var(--theme-text-muted);
}

/* Dark theme specific text improvements */
.theme-dark small,
.theme-dark .small {
    color: var(--theme-text-muted);
    opacity: 0.9; /* Slightly more opaque for better readability */
}

/* Suggestion dropdown styles */
.suggestion-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--theme-border);
    background: var(--theme-surface);
    color: var(--theme-on-surface);
    transition: background-color 0.15s ease-in-out;
}

.suggestion-item:hover {
    background-color: var(--theme-list-item-hover);
}

.suggestion-item:active {
    background-color: var(--theme-border);
}

.suggestion-item:last-child {
    border-bottom: none;
    border-radius: 0 0 0.375rem 0.375rem;
}

/* Ensure input groups with suggestions have proper positioning context */
.input-group.position-relative {
    position: relative;
}

/* Style for PCL section - FIXED FOR DARK MODE */
.pcl-section {
    border: 1px solid var(--theme-border);
    border-radius: 0.375rem;
    background: var(--theme-surface);
}

.pcl-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    background: var(--theme-surface) !important;
    color: var(--theme-on-surface) !important;
    border: 1px solid var(--theme-border) !important;
}

.pcl-summary:hover {
    background: var(--theme-list-item-hover) !important;
}

.pcl-arrow-right::before {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid var(--theme-on-surface);
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.pcl-arrow-down::before {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 5px solid var(--theme-on-surface);
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.pcl-editor {
    padding: 1rem;
    border-top: 1px solid var(--theme-border);
    background: var(--theme-surface);
}

.pcl-label {
    font-weight: 500;
    color: var(--theme-on-surface);
}

/* Job details grid layout */
.job-details-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem 2rem;
    align-items: start;
}

.job-details-grid > div:nth-child(odd) {
    font-weight: 500;
    color: var(--theme-on-surface);
    text-align: right;
    white-space: nowrap;
}

.file-import-section {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 0.375rem;
}

/* Raw XML view styling to handle long PCL lists */
details pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
    overflow-x: auto;
    background: var(--theme-surface);
    color: var(--theme-on-surface);
    padding: 1rem;
    border: 1px solid var(--theme-border);
    border-radius: 0.375rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.4;
}

details pre code {
    white-space: inherit;
    word-wrap: inherit;
    word-break: inherit;
    overflow-wrap: inherit;
    color: inherit;
}

/* Ensure details/summary doesn't break layout */
details {
    max-width: 100%;
    overflow: hidden;
}

details summary {
    cursor: pointer;
    padding: 0.5rem;
    background: var(--theme-surface);
    color: var(--theme-on-surface);
    border: 1px solid var(--theme-border);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    user-select: none;
}

details summary:hover {
    background: var(--theme-list-item-hover);
}

details[open] summary {
    margin-bottom: 0.5rem;
    border-radius: 0.375rem 0.375rem 0 0;
    border-bottom: none;
}

details[open] pre {
    margin: 0;
    border-radius: 0 0 0.375rem 0.375rem;
    border-top: none;
}

/* Logo styling in navbar */
.navbar-brand img {
    transition: opacity 0.2s ease-in-out;
}

.navbar-brand img:hover {
    opacity: 0.8;
}

/* Dark theme specific adjustments */
.theme-dark {
    color-scheme: dark;
}

.theme-dark .table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: rgba(255, 255, 255, 0.05);
}

.theme-dark .form-control::placeholder {
    color: var(--theme-text-muted);
    opacity: 0.8;
}

.theme-dark .form-select::placeholder {
    color: var(--theme-text-muted);
    opacity: 0.8;
}

/* Bootstrap icon override for theme support */
.theme-dark .bi-sun-fill {
    color: var(--theme-warning) !important;
}

.theme-dark .bi-moon-fill {
    color: var(--theme-info) !important;
}

.theme-light .bi-sun-fill {
    color: var(--theme-warning) !important;
}

.theme-light .bi-moon-fill {
    color: var(--theme-secondary) !important;
}

/* Dark theme adjustments for blazor error UI */
.theme-dark #blazor-error-ui {
    color-scheme: dark only;
    background: var(--theme-danger, #dc3545);
    color: white;
}

/* Input file styling for dark theme */
.form-control[type="file"] {
    background-color: var(--theme-input-background);
    border-color: var(--theme-border);
    color: var(--theme-on-background);
}

.form-control[type="file"]:focus {
    background-color: var(--theme-input-focus-background);
    border-color: var(--theme-primary);
}

/* Button outline styles for dark mode - Enhanced for better contrast */
.btn-outline-primary {
    color: #ababab; /* Light grey outline color */
    border-color: #ababab; /* Light grey border */
    background-color: transparent;
}

.btn-outline-primary:hover {
    background-color: #2a2a2a; /* Dark grey background on hover */
    border-color: #ababab; /* Keep light grey border */
    color: #ababab; /* Light grey text on hover */
}

/* Dark theme specific button outline styling */
.theme-dark .btn-outline-primary {
    color: var(--theme-button-edit);
    border-color: var(--theme-button-edit);
}

.theme-dark .btn-outline-primary:hover {
    background-color: var(--theme-button-edit);
    border-color: var(--theme-button-edit);
    color: var(--theme-list-item-active-text);
}

.btn-outline-secondary {
    color: var(--theme-button-edit);
    border-color: var(--theme-button-edit);
    font-weight: 500;
}

.btn-outline-secondary:hover {
    background-color: var(--theme-button-edit);
    border-color: var(--theme-button-edit);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Dark theme specific secondary button styling */
.theme-dark .btn-outline-secondary {
    color: var(--theme-button-edit);
    border-color: var(--theme-button-edit);
}

.theme-dark .btn-outline-secondary:hover {
    background-color: var(--theme-button-edit);
    border-color: var(--theme-button-edit);
    color: var(--theme-list-item-active-text);
}

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

.btn-outline-danger:hover {
    background-color: var(--theme-danger);
    color: white;
}

/* Enhanced button styling for better UX */
.btn {
    transition: all 0.2s ease-in-out;
    font-weight: 500;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Ensure proper contrast for disabled elements */
.btn:disabled,
.btn.disabled {
    opacity: 0.65;
    transform: none !important;
    box-shadow: none !important;
}

/* Page title styling that respects theme */
.page-title {
    color: var(--theme-on-background) !important;
}

/* Context-Specific Color System for Perfect Contrast */
:root {
    /* === LIGHT THEME === */
    
    /* Base Colors - Foundation */
    --color-warm-grey-100: #f8f6f4;
    --color-warm-grey-200: #ede9e5;
    --color-warm-grey-300: #d9d1cc;
    --color-warm-grey-400: #b8aca5;
    --color-warm-grey-500: #9c8771;
    --color-warm-grey-600: #8b7355;
    --color-warm-grey-700: #6d573f;
    --color-warm-grey-800: #5a4a39;
    --color-warm-grey-900: #3d312a;
    
    /* Status Colors */
    --color-success: #28a745;
    --color-danger: #dc3545;
    --color-warning: #ffc107;
    --color-info: #e9ecef; /* Light grey instead of blue for light theme */
    
    /* === PRIMARY ELEMENT COLORS === */
    /* Primary Button */
    --primary-btn-bg: #2a2a2a; /* Dark grey instead of warm brown */
    --primary-btn-text: #ffffff;
    --primary-btn-hover-bg: #1a1a1a; /* Even darker on hover */
    --primary-btn-hover-text: #ffffff;
    --primary-btn-disabled-bg: var(--color-warm-grey-300);
    --primary-btn-disabled-text: var(--color-warm-grey-500);
    
    /* Primary as Text Color */
    --primary-text-on-light: #2a2a2a; /* Dark grey for text */
    --primary-text-on-surface: #2a2a2a;
    --primary-text-on-dark: #ababab; /* Light grey for dark backgrounds */
    
    /* === SECONDARY ELEMENT COLORS === */
    /* Secondary Button */
    --secondary-btn-bg: var(--color-warm-grey-400);
    --secondary-btn-text: #ffffff;
    --secondary-btn-hover-bg: var(--color-warm-grey-500);
    --secondary-btn-hover-text: #ffffff;
    
    /* Secondary as Text Color */
    --secondary-text-on-light: #6c757d;
    --secondary-text-on-surface: #5a6268;
    --secondary-text-on-dark: #8d9499;
    
    /* === BACKGROUND SYSTEM === */
    --bg-main: #ffffff;
    --bg-surface: var(--color-warm-grey-100);
    --bg-elevated: #ffffff;
    --bg-input: #ffffff;
    --bg-input-focus: #ffffff;
    
    /* === TEXT SYSTEM === */
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --text-disabled: var(--color-warm-grey-400);
    --text-on-primary: #ffffff;
    --text-on-secondary: #ffffff;
    --text-on-surface: #495057;
    
    /* === BORDER SYSTEM === */
    --border-light: #dee2e6;
    --border-medium: var(--color-warm-grey-300);
    --border-strong: var(--color-warm-grey-400);
    --border-focus: var(--color-warm-grey-600);
    
    /* === LIST ITEM SYSTEM === */
    --list-item-bg: #ffffff;
    --list-item-text: #212529;
    --list-item-hover-bg: var(--color-warm-grey-100);
    --list-item-hover-text: #212529;
    --list-item-active-bg: var(--color-warm-grey-200); /* Even lighter warm grey - matches background tone */
    --list-item-active-text: #495057; /* Dark text for excellent contrast */
    
    /* === SIDEBAR SYSTEM === */
    --sidebar-bg: #2c3e50;
    --sidebar-text: #d7d7d7;
    --sidebar-text-hover: #2d3436; /* Changed from #ffffff to dark color for better readability in light mode */
    --sidebar-active-bg: var(--color-warm-grey-300); /* Lighter warm grey instead of brown */
    --sidebar-active-text: #495057; /* Dark text for better contrast */
    --sidebar-hover-bg: var(--color-warm-grey-200); /* Even lighter for hover */
    
    /* === TOPBAR SYSTEM === */
    --topbar-bg: #f7f7f7;
    --topbar-text: #212529;
    --topbar-border: #d6d5d5;
    
    /* === EDIT BUTTON SYSTEM === */
    --edit-btn-bg: #2a2a2a; /* Dark grey for edit buttons */
    --edit-btn-text: #ababab; /* Light grey text */
    --edit-btn-hover-bg: #1a1a1a; /* Even darker on hover */
    --edit-btn-hover-text: #ababab;
    
    /* === STATUS SYSTEM === */
    --success-bg: var(--color-success);
    --success-text: #ffffff;
    --danger-bg: var(--color-danger);
    --danger-text: #ffffff;
    --warning-bg: var(--color-warning);
    --warning-text: #212529;
    --info-bg: #e9ecef; /* Light grey instead of blue */
    --info-text: #495057; /* Dark grey text for good contrast */
}

/* === DARK THEME === */
.theme-dark {
    /* Base Dark Colors */
    --color-dark-grey-100: #1a1a1a;
    --color-dark-grey-200: #2d3436;
    --color-dark-grey-300: #3a3d41;
    --color-dark-grey-400: #454950;
    --color-dark-grey-500: #5a5f65;
    --color-dark-grey-600: #6c757d;
    --color-dark-grey-700: #adb5bd;
    --color-dark-grey-800: #c9bdb3;
    --color-dark-grey-900: #f0e8dd;
    
    /* Warm accent colors for dark mode */
    --color-warm-accent-100: #f5ede4;
    --color-warm-accent-200: #e8d5c4;
    --color-warm-accent-300: #d4c0a1;
    --color-warm-accent-400: #c0a882;
    --color-warm-accent-500: #a08b73;
    
    /* Status Colors - adjusted for dark mode */
    --color-success: #51cf66;
    --color-danger: #ff6b6b;
    --color-warning: #ffd43b;
    --color-info: #5a5f65; /* Medium dark grey instead of blue for dark theme */
    
    /* === PRIMARY ELEMENT COLORS === */
    /* Primary Button - dark grey instead of warm colors */
    --primary-btn-bg: #2a2a2a; /* Dark grey background */
    --primary-btn-text: #ababab; /* Light grey text */
    --primary-btn-hover-bg: #1a1a1a; /* Even darker on hover */
    --primary-btn-hover-text: #ababab;
    --primary-btn-disabled-bg: var(--color-dark-grey-400);
    --primary-btn-disabled-text: var(--color-dark-grey-600);
    
    /* Primary as Text Color - light grey for excellent contrast */
    --primary-text-on-light: #ababab; /* Light grey text */
    --primary-text-on-surface: #ababab;
    --primary-text-on-dark: #ababab;
    
    /* Secondary Button - clearly visible */
    --secondary-btn-bg: var(--color-dark-grey-600);
    --secondary-btn-text: #ffffff;
    --secondary-btn-hover-bg: var(--color-dark-grey-700);
    --secondary-btn-hover-text: #ffffff;
    
    /* Secondary as Text Color - perfect readability */
    --secondary-text-on-light: var(--color-dark-grey-700);
    --secondary-text-on-surface: var(--color-dark-grey-800);
    --secondary-text-on-dark: var(--color-dark-grey-700);
    
    /* === BACKGROUND SYSTEM === */
    --bg-main: var(--color-dark-grey-100);
    --bg-surface: var(--color-dark-grey-200);
    --bg-elevated: var(--color-dark-grey-300);
    --bg-input: var(--color-dark-grey-300);
    --bg-input-focus: var(--color-dark-grey-400);
    
    /* === TEXT SYSTEM === */
    --text-primary: #ffffff;
    --text-secondary: var(--color-dark-grey-800);
    --text-muted: var(--color-dark-grey-700);
    --text-disabled: var(--color-dark-grey-500);
    --text-on-primary: var(--color-dark-grey-100);
    --text-on-secondary: #ffffff;
    --text-on-surface: var(--color-dark-grey-900);
    
    /* === BORDER SYSTEM === */
    --border-light: var(--color-dark-grey-400);
    --border-medium: var(--color-dark-grey-500);
    --border-strong: var(--color-dark-grey-600);
    --border-focus: var(--color-warm-accent-300);
    
    /* === LIST ITEM SYSTEM === */
    --list-item-bg: var(--color-dark-grey-300);
    --list-item-text: #ffffff;
    --list-item-hover-bg: var(--color-dark-grey-400);
    --list-item-hover-text: #ffffff;
    --list-item-active-bg: var(--color-dark-grey-500); /* Lighter dark grey - matches background tone */
    --list-item-active-text: #ffffff; /* White text for good contrast */
    
    /* === SIDEBAR SYSTEM === */
    --sidebar-bg: #1e2328;
    --sidebar-text: #e9ecef;
    --sidebar-text-hover: #ffffff; /* Keep white for dark theme as it works well */
    --sidebar-active-bg: var(--color-dark-grey-400); /* Lighter dark grey instead of warm accent */
    --sidebar-active-text: #ffffff; /* White text for good contrast */
    --sidebar-hover-bg: var(--color-dark-grey-300); /* Subtle hover */
    
    /* === TOPBAR SYSTEM === */
    --topbar-bg: var(--color-dark-grey-200);
    --topbar-text: #ffffff;
    --topbar-border: var(--color-dark-grey-400);
    
    /* === EDIT BUTTON SYSTEM === */
    --edit-btn-bg: #2a2a2a; /* Dark grey for edit buttons */
    --edit-btn-text: #ababab; /* Light grey text */
    --edit-btn-hover-bg: #1a1a1a; /* Even darker on hover */
    --edit-btn-hover-text: #ababab;
    
    /* === STATUS SYSTEM === */
    --success-bg: var(--color-success);
    --success-text: var(--color-dark-grey-100);
    --danger-bg: var(--color-danger);
    --danger-text: #ffffff;
    --warning-bg: var(--color-warning);
    --warning-text: var(--color-dark-grey-100);
    --info-bg: var(--color-dark-grey-500); /* Medium dark grey instead of blue */
    --info-text: #ffffff; /* White text for good contrast */
    
    color-scheme: dark;
}

/* === APPLY CONTEXT-SPECIFIC COLORS === */

/* Base HTML */
html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Links */
a, .btn-link {
    color: var(--primary-text-on-light);
}

/* === BUTTON SYSTEM === */
.btn-primary {
    background-color: var(--primary-btn-bg);
    border-color: var(--primary-btn-bg);
    color: var(--primary-btn-text);
}

.btn-primary:hover {
    background-color: var(--primary-btn-hover-bg);
    border-color: var(--primary-btn-hover-bg);
    color: var(--primary-btn-hover-text);
}

.btn-primary:disabled {
    background-color: var(--primary-btn-disabled-bg);
    border-color: var(--primary-btn-disabled-bg);
    color: var(--primary-btn-disabled-text);
}

.btn-secondary {
    background-color: var(--secondary-btn-bg);
    border-color: var(--secondary-btn-bg);
    color: var(--secondary-btn-text);
}

.btn-secondary:hover {
    background-color: var(--secondary-btn-hover-bg);
    border-color: var(--secondary-btn-hover-bg);
    color: var(--secondary-btn-hover-text);
}

.btn-outline-primary {
    color: #ababab; /* Light grey outline color */
    border-color: #ababab; /* Light grey border */
    background-color: transparent;
}

.btn-outline-primary:hover {
    background-color: #2a2a2a; /* Dark grey background on hover */
    border-color: #ababab; /* Keep light grey border */
    color: #ababab; /* Light grey text on hover */
}

.btn-outline-secondary {
    color: var(--secondary-btn-bg);
    border-color: var(--secondary-btn-bg);
    background-color: transparent;
}

.btn-outline-secondary:hover {
    background-color: var(--secondary-btn-bg);
    border-color: var(--secondary-btn-bg);
    color: var(--secondary-btn-text);
}

/* Status buttons */
.btn-success {
    background-color: var(--success-bg);
    border-color: var(--success-bg);
    color: var(--success-text);
}

.btn-danger {
    background-color: var(--danger-bg);
    border-color: var(--danger-bg);
    color: var(--danger-text);
}

.btn-warning {
    background-color: var(--warning-bg);
    border-color: var(--warning-bg);
    color: var(--warning-text);
}

.btn-info {
    background-color: var(--info-bg);
    border-color: var(--info-bg);
    color: var(--info-text);
}

.btn-info:hover {
    background-color: #d3d9df; /* Slightly darker grey on hover for light theme */
    border-color: #d3d9df;
    color: var(--info-text);
}

.theme-dark .btn-info:hover {
    background-color: #4a4f54; /* Slightly darker grey on hover for dark theme */
    border-color: #4a4f54;
    color: #ffffff;
}

.btn-outline-info {
    color: var(--info-bg);
    border-color: var(--info-bg);
    background-color: transparent;
}

.btn-outline-info:hover {
    background-color: var(--info-bg);
    border-color: var(--info-bg);
    color: var(--info-text);
}

/* Button focus */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus {
    box-shadow: 0 0 0 0.2rem rgba(139, 115, 85, 0.25);
}

.theme-dark .btn:focus, .theme-dark .btn:active:focus {
    box-shadow: 0 0 0 0.2rem rgba(212, 192, 161, 0.25);
}

/* === FORM SYSTEM === */
.form-control {
    background-color: var(--bg-input);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.form-control:focus {
    background-color: var(--bg-input-focus);
    border-color: var(--border-focus);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(139, 115, 85, 0.25);
}

.theme-dark .form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(212, 192, 161, 0.25);
}

.form-control:disabled {
    background-color: var(--bg-surface);
    color: var(--text-disabled);
    opacity: 0.8;
}

/* IMPROVED: Better disabled styling for dark theme contrast */
.theme-dark .form-control:disabled {
    background-color: #2a2e32; /* Darker background for better contrast */
    color: #b0b3b8; /* Lighter text color for better readability */
    border-color: #495057; /* Slightly lighter border */
    opacity: 0.9; /* Reduced opacity for better visibility */
}

.form-select {
    background-color: var(--bg-input);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.form-select:focus {
    background-color: var(--bg-input-focus);
    border-color: var(--border-focus);
}

/* Dark theme specific select styling */
.theme-dark .form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(212, 192, 161, 0.25); /* Lighter shadow for dark mode */
}

/* IMPROVED: Fix disabled select contrast in dark theme */
.form-select:disabled {
    background-color: var(--theme-surface);
    opacity: 0.65;
}

.theme-dark .form-select:disabled {
    background-color: #2a2e32; /* Darker background for better contrast */
    color: #b0b3b8; /* Lighter text color for better readability */
    border-color: #495057; /* Slightly lighter border */
    opacity: 0.9; /* Reduced opacity for better visibility */
}

/* === CARD SYSTEM === */
.card {
    background-color: var(--bg-surface);
    border-color: var(--border-light);
    color: var(--text-on-surface);
}

.card-header {
    background-color: var(--bg-surface);
    border-bottom-color: var(--border-light);
    color: var(--text-on-surface);
}

.card-body {
    background-color: var(--bg-surface);
    color: var(--text-on-surface);
}

/* === LIST SYSTEM === */
.list-group-item {
    background-color: var(--list-item-bg);
    border-color: var(--border-light);
    color: var(--list-item-text);
}

.list-group-item:hover {
    background-color: var(--list-item-hover-bg);
    color: var (--list-item-hover-text);
}

.list-group-item.active {
    background-color: var(--list-item-active-bg) !important;
    border-color: var(--list-item-active-bg) !important;
    color: var(--list-item-active-text) !important;
    font-weight: 500;
}

/* === BOOTSTRAP OVERRIDE FOR LIST ITEMS === */
/* Ensure Bootstrap's active state uses our context-specific colors */
.list-group-item-action.active {
    background-color: var(--list-item-active-bg) !important;
    border-color: var(--list-item-active-bg) !important;
    color: var(--list-item-active-text) !important;
}

/* Job file list specific styling */
.list-group-flush .list-group-item.active {
    background-color: var(--list-item-active-bg) !important;
    border-color: var(--list-item-active-bg) !important;
    color: var(--list-item-active-text) !important;
    border-left: 3px solid var(--primary-btn-bg) !important;
}

.list-group-flush .list-group-item {
    border-left: 0;
    border-right: 0;
}

/* === ALERT SYSTEM === */
.alert-primary {
    background-color: var(--primary-btn-bg);
    border-color: var(--primary-btn-bg);
    color: var(--primary-btn-text);
}

.alert-secondary {
    background-color: var(--bg-surface);
    border-color: var(--border-medium);
    color: var(--text-on-surface);
}

.alert-success {
    background-color: var(--success-bg);
    border-color: var(--success-bg);
    color: var(--success-text);
}

.alert-danger {
    background-color: var(--danger-bg);
    border-color: var (--danger-bg);
    color: var(--danger-text);
}

.alert-warning {
    background-color: var(--warning-bg);
    border-color: var(--warning-bg);
    color: var(--warning-text);
}

.alert-info {
    background-color: var(--info-bg);
    border-color: var(--info-bg);
    color: var(--info-text);
}

/* === TEXT UTILITIES === */
.text-muted {
    color: var(--text-muted) !important;
}

.text-info {
    color: var(--info-text) !important;
}

small, .small {
    color: var(--text-muted);
}

/* === BACKGROUND UTILITIES === */
.bg-light {
    background-color: var(--bg-surface) !important;
    color: var(--text-on-surface);
}

.bg-white {
    background-color: var(--bg-main) !important;
    color: var(--text-primary);
}

/* === LEGACY COMPATIBILITY === */
/* Keep old variables for backward compatibility during transition */
:root {
    --theme-primary: var(--primary-text-on-light);
    --theme-secondary: var(--secondary-text-on-light);
    --theme-success: var(--success-bg);
    --theme-danger: var(--danger-bg);
    --theme-warning: var(--warning-bg);
    --theme-info: var(--info-bg);
    --theme-background: var(--bg-main);
    --theme-surface: var(--bg-surface);
    --theme-on-background: var(--text-primary);
    --theme-on-surface: var(--text-on-surface);
    --theme-border: var(--border-light);
    --theme-text-muted: var(--text-muted);
    --theme-sidebar-background: var(--sidebar-bg);
    --theme-sidebar-text: var(--sidebar-text);
    --theme-sidebar-active: var(--sidebar-active-bg);
    --theme-sidebar-text-hover: var(--sidebar-text-hover); /* Add the missing hover text variable */
}

.theme-dark {
    --theme-primary: var(--primary-text-on-light);
    --theme-secondary: var(--secondary-text-on-light);
    --theme-success: var(--success-bg);
    --theme-danger: var(--danger-bg);
    --theme-warning: var(--warning-bg);
    --theme-info: var(--info-bg);
    --theme-background: var(--bg-main);
    --theme-surface: var(--bg-surface);
    --theme-on-background: var(--text-primary);
    --theme-on-surface: var(--text-on-surface);
    --theme-border: var(--border-light);
    --theme-text-muted: var(--text-muted);
    --theme-sidebar-background: var(--sidebar-bg);
    --theme-sidebar-text: var(--sidebar-text);
    --theme-sidebar-active: var(--sidebar-active-bg);
    --theme-sidebar-text-hover: var(--sidebar-text-hover); /* Add the missing hover text variable */
}

/* Enhanced button styling for better UX */
.btn {
    transition: all 0.2s ease-in-out;
    font-weight: 500;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.65;
    transform: none !important;
    box-shadow: none !important;
}

.content {
    padding-top: 1.1rem;
    background-color: var(--bg-main);
    color: var(--text-primary);
}

/* Page title styling that respects theme */
.page-title {
    color: var(--text-primary) !important;
}

.theme-dark .bg-light {
    background-color: #e9ecef !important;
    color: #212529 !important; /* Optional: dunkle Schrift */
}

/* === FORM HELP TEXT - IMPROVED VISIBILITY IN DARK MODE === */
.form-text {
    color: #6c757d; /* Default Bootstrap text-muted for light theme */
}

.theme-dark .form-text {
    color: #adb5bd !important; /* Much brighter in dark mode for better visibility */
    font-weight: 400; /* Ensure normal font weight for better readability */
}

