/*
 * common.css - Shared Form Styles
 *
 * Consolidates all common styling for form pages, including layout, form fields, validation, buttons, alerts, and responsive design.
 * Used by all forms for consistent look and feel. Reduces duplication across form-specific CSS files.
 *
 * Extension points: Add new shared form styles in appropriate sections; override in form-specific CSS as needed.
 * Best practices: Use section comments for clarity; keep selectors modular and DRY; prefer variables for colors if expanding.
 */

/* Common Form Styles */
/* Consolidated shared styling for all form pages - extracted from individual form CSS files */
/* Maintains existing functionality while reducing duplication */

/* === REAL-TIME VALIDATION STYLES === */
/* Visual feedback for form validation */
.form-field {
    transition: all 0.3s ease;
}

/* REMOVED OLD VALIDATION STYLES - Using is-valid/is-invalid classes instead */

/* Section-level validation icons positioned in top-right of container */
.section-validation-icon {
    position: absolute !important;
    right: 15px !important;
    top: 15px !important;
    font-size: 24px !important;
    z-index: 15 !important;
    pointer-events: none !important;
}

.section-validation-icon.valid {
    color: #28a745 !important;
}

.section-validation-icon.invalid {
    color: #dc3545 !important;
}

/* Removed special dynamic row icon styling - using consistent section-level icons */

/* Ensure containers can position icons properly */
.container,
.form-section,
.section,
.fullscreen-container > .container,
.strain-entry-row,
.tote-entry-row,
.product-entry-row,
[data-strain-index],
[data-tote-index],
[data-product-index] {
    position: relative !important;
}

/* Ensure headers don't interfere with icon positioning */
h1, h2, h3, h4, h5, h6 {
    position: relative;
}

/* Remove field-level icon spacing since we're not using them anymore */
.form-group {
    position: relative;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding-right: 15px; /* Reset to normal padding */
}

/* Error message styling */
.validation-error-summary {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    animation: slideIn 0.3s ease-out;
}

.validation-error-summary h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: bold;
}

.validation-error-summary ul {
    margin: 0;
    padding-left: 20px;
}

.validation-error-summary li {
    margin-bottom: 5px;
}

/* Dark mode error styling */
body:not(.light-mode) .validation-error-summary {
    background-color: rgba(220, 53, 69, 0.2);
    border-color: #dc3545;
    color: #ff6b7a;
}

/* Field-level error messages (created by JavaScript validation) */
.field-error-message {
    color: #d32f2f;
    font-size: 0.9em;
    margin-top: 5px;
    display: block;
    font-weight: 500;
}

body.light-mode .field-error-message {
    color: #c62828 !important;
    font-weight: 600 !important;
}

body:not(.light-mode) .field-error-message {
    color: #ff6b7a !important;
    font-weight: 500 !important;
}

/* Animation for error message */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reset & Base Styles for Form Pages */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: 'Arial', sans-serif;
    background-color: #222;
    color: #eee;
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
}

body.light-mode {
    background-color: #f5f5f5;
    color: #333;
}

/* Fullscreen Wrapper */
.fullscreen-container {
    width: 100%;
    min-height: calc(100vh - 30px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    position: relative;
    overflow-y: auto;
}

/* Form Container */
.container {
    width: 95%;
    max-width: 500px;
    background-color: #333;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    position: relative;
    z-index: 1;
    overflow-y: visible;
    margin: 20px auto;
    max-height: none;
}

body.light-mode .container {
    background-color: #fff !important;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1) !important;
    color: #222 !important;
}

/* Application header with logo - maintained for forms that use it */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    text-align: center;
    padding: 15px;
    border: 1px solid #4CAF50;
    border-radius: 8px;
    background-color: #444;
    flex-wrap: wrap;
}

body.light-mode .app-header {
    background-color: #f9f9f9;
}

.app-logo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.light-mode .app-logo {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    flex: 1;
    min-width: 200px;
}

.app-title h1 {
    margin: 0;
    font-size: 24px;
    color: #fff;
    font-weight: 600;
    letter-spacing: -0.5px;
}

body.light-mode .app-title h1 {
    color: #333;
}

.app-subtitle {
    margin: 0;
    font-size: 16px;
    color: #ccc;
    font-weight: 400;
}

body.light-mode .app-subtitle {
    color: #666;
}

/* Form Sections */
.form-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.form-section {
    border: 1px solid #555;
    border-radius: 8px;
    padding: 15px;
    background-color: #3a3a3a;
}

body.light-mode .form-section {
    border-color: #e0e0e0 !important;
    background-color: #fafafa !important;
}

.section-title {
    font-size: 18px;
    margin-bottom: 15px;
    color: #ddd;
    padding-bottom: 8px;
    border-bottom: 1px solid #555;
}

body.light-mode .section-title {
    color: #222 !important;
    border-bottom-color: #e0e0e0;
}

/* Form Fields */
.form-group {
    margin-bottom: 12px;
    width: 100%;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.form-group.half {
    flex: 1;
    min-width: 150px;
}

/* Form labels */
label,
.form-section label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
    display: block;
    color: #ccc;
}

body.light-mode label,
body.light-mode .form-section label {
    color: #444 !important;
}

/* Add icons to labels */
label i {
    margin-right: 5px;
    color: #4CAF50;
}

/* Required field indicator */
label.required::after {
    content: "*";
    color: #dc3545;
    margin-left: 2px;
}

.field-header {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 6px;
    margin-top: 8px;
}

body.light-mode .field-header {
    color: #222;
}

/* Form inputs */
input, 
select, 
textarea,
.form-section input,
.form-section select,
.form-section textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #555;
    border-radius: 6px;
    font-size: 16px;
    background-color: #444;
    color: #eee;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    font-family: 'Arial', sans-serif;
}

body.light-mode input, 
body.light-mode select, 
body.light-mode textarea,
body.light-mode .form-section input,
body.light-mode .form-section select,
body.light-mode .form-section textarea {
    border-color: #ccc !important;
    background-color: #fff !important;
    color: #333 !important;
}

input:focus, 
select:focus, 
textarea:focus,
.form-section input:focus,
.form-section select:focus,
.form-section textarea:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3);
}

body.light-mode input:focus,
body.light-mode select:focus,
body.light-mode textarea:focus,
body.light-mode .form-section input:focus,
body.light-mode .form-section select:focus,
body.light-mode .form-section textarea:focus {
    border-color: #4CAF50 !important;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1) !important;
}

/* Textarea specific styling */
textarea {
    resize: vertical;
    min-height: 60px;
}

/* Select dropdown styling */
select {
    background-color: #444;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%23eee' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
}

body.light-mode select {
    background-color: #fff;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%23333' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
}

/* Error states */
.error-field {
    border-color: #dc3545 !important;
    background-color: rgba(220, 53, 69, 0.1);
}

body.light-mode .error-field {
    border-color: #dc3545 !important;
    background-color: #ffe6e6 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.15) !important;
}

/* REMOVED: error-message styling - using validation.js for visual feedback only */

/* Button styling */
.btn {
    background-color: #4CAF50;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: background-color 0.3s ease, transform 0.1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background-color: #45a049;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.btn i {
    font-size: 18px;
}

body.light-mode .btn {
    background-color: #4CAF50 !important;
    color: #fff !important;
}

body.light-mode .btn:hover {
    background-color: #45a049 !important;
}

body.light-mode .btn:disabled {
    background-color: #cccccc !important;
}

/* Alert/Flash message styling */
.alert {
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert::before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    margin-right: 8px;
}

.alert-success {
    background-color: rgba(21, 87, 36, 0.3);
    color: #c6f6d5;
    border-color: #155724;
}

body.light-mode .alert-success {
    background-color: #d4edda !important;
    color: #155724 !important;
    border-color: #c3e6cb !important;
    font-weight: 600 !important;
}

body.light-mode .alert-success::before {
    color: #155724 !important;
}

.alert-success::before {
    content: "\f00c"; /* Check icon */
}

.alert-warning {
    background-color: rgba(133, 100, 4, 0.3);
    color: #ffeeba;
    border-color: #856404;
}

body.light-mode .alert-warning {
    background-color: #fff3cd !important;
    color: #856404 !important;
    border-color: #ffeeba !important;
    font-weight: 600 !important;
}

body.light-mode .alert-warning::before {
    color: #856404 !important;
}

.alert-warning::before {
    content: "\f071"; /* Warning icon */
}

.alert-error {
    background-color: rgba(114, 28, 36, 0.3);
    color: #f5c6cb;
    border-color: #721c24;
}

body.light-mode .alert-error {
    background-color: #f8d7da !important;
    color: #721c24 !important;
    border-color: #f5c6cb !important;
    font-weight: 600 !important;
}

/* Ensure error alert icon is visible in light mode */
body.light-mode .alert-error::before {
    color: #721c24 !important;
}

.alert-error::before {
    content: "\f06a"; /* Error icon */
}

/* Form Container Extensions for employee onboarding (wider form) */
.form-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background: #333;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.light-mode .form-container {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-container h1 {
    color: #fff;
    margin-bottom: 2rem;
    text-align: center;
}

body.light-mode .form-container h1 {
    color: #333;
}

.form-section h2 {
    color: #444;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

body.light-mode .form-section h2 {
    color: #444;
}

body:not(.light-mode) .form-section h2 {
    color: #fff;
}

.form-section h3 {
    color: #ddd;
    margin: 1.5rem 0 1rem;
    font-size: 1.2rem;
}

body.light-mode .form-section h3 {
    color: #555;
}

.form-actions {
    margin-top: 2rem;
    text-align: center;
}

.submit-button {
    background-color: #4CAF50;
    color: white;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.submit-button:hover {
    background-color: #45a049;
}

.submit-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Responsive Media Queries */
/* For mobile phones */
@media (max-width: 480px) {
    .container {
        width: 100%;
        padding: 15px;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .fullscreen-container {
        padding: 0;
    }
    
    .app-header {
        flex-direction: column;
        padding: 10px;
    }
    
    .app-title {
        align-items: center;
    }
    
    .app-title h1 {
        font-size: 20px;
        text-align: center;
    }
    
    .app-subtitle {
        font-size: 14px;
        text-align: center;
    }
    
    input, 
    select, 
    textarea,
    .form-section input,
    .form-section select,
    .form-section textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 8px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .form-group.half {
        width: 100%;
    }
    
    .form-section {
        padding: 12px;
    }
    
    .form-container {
        margin: 1rem;
        padding: 1rem;
    }
}

/* For tablets */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        max-width: 500px;
    }
    
    .app-header {
        gap: 10px;
    }
    
    .form-section {
        padding: 12px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 600px;
    }
}

@media (min-width: 1025px) {
    .container {
        max-width: 650px;
    }
    
    input, select, textarea {
        padding: 12px;
    }
    
    .btn {
        padding: 14px;
    }
}

/* For landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .app-header {
        margin-bottom: 15px;
    }
    
    .form-group {
        margin-bottom: 8px;
    }
    
    .container {
        padding: 12px;
    }
    
    .fullscreen-container {
        align-items: flex-start;
        padding-top: 10px;
    }
}

/* Mobile device specific styles */
body.mobile-device .container {
    padding-bottom: 60px; /* Extra padding to prevent content from being hidden by virtual keyboard */
}

/* iOS specific fixes */
body.ios-device .container {
    margin-top: 0;
    padding-top: 20px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling for iOS */
}

/* Fix for top of form being cut off */
@media screen and (max-height: 800px) {
    .fullscreen-container {
        padding-top: 0;
        padding-bottom: 40px; /* Add extra space at bottom */
    }
    
    .container {
        margin-top: 10px;
    }
}

/* Fix for very small screens */
@media screen and (max-height: 600px) {
    .fullscreen-container {
        min-height: 100vh;
        height: auto;
    }
}

/* Dark mode support for different form pages */
@media (prefers-color-scheme: dark) {
    html, body {
        background-color: #222;
        color: #eee;
    }
    
    .container {
        background-color: #333;
        box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
    }
    
    .app-header {
        background-color: #444;
        border-color: #555;
    }
    
    .app-title h1 {
        color: #fff;
    }
    
    .app-subtitle {
        color: #ccc;
    }
    
    input, select, textarea {
        background-color: #444;
        border-color: #555;
        color: #eee;
    }
    
    label {
        color: #ccc;
    }
    
    .form-section {
        background-color: #3a3a3a;
        border-color: #555;
    }
    
    .section-title {
        color: #ddd;
        border-bottom-color: #555;
    }
    
    .alert {
        background-color: #444;
        border-color: #555;
        color: #eee;
    }
    
    .alert-success {
        background-color: rgba(21, 87, 36, 0.3);
        border-color: #155724;
    }
    
    .alert-warning {
        background-color: rgba(133, 100, 4, 0.3);
        border-color: #856404;
    }
    
    .alert-error {
        background-color: rgba(114, 28, 36, 0.3);
        border-color: #721c24;
    }
    
    .fas, label i {
        color: #7cc77f;
    }
    
    .error-field {
        background-color: rgba(220, 53, 69, 0.1);
    }
}

/* Print styles */
@media print {
    .container {
        box-shadow: none;
        max-height: none;
    }
    
    input, select, textarea {
        border: 1px solid #999;
    }
    
    .btn {
        display: none;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* High contrast mode support */
@media (forced-colors: active) {
    .app-header {
        border: 2px solid CanvasText;
    }
    
    input, select, textarea {
        border: 1px solid CanvasText;
    }
    
    .btn {
        border: 1px solid CanvasText;
    }
}

/* Enhanced Form Validation Styles - VISUAL CUES ONLY */

/* Invalid state - RED border */
input.is-invalid,
select.is-invalid,
textarea.is-invalid,
input.error-field,
select.error-field,
textarea.error-field {
    border: 2px solid #dc3545 !important;
    box-shadow: 0 0 0 0.1rem rgba(220, 53, 69, 0.25) !important;
    background-color: rgba(220, 53, 69, 0.05) !important;
    /* Ensure consistent sizing to prevent movement */
    box-sizing: border-box !important;
}

/* Valid state - GREEN border */
input.is-valid,
select.is-valid,
textarea.is-valid {
    border: 2px solid #28a745 !important;
    box-shadow: 0 0 0 0.1rem rgba(40, 167, 69, 0.25) !important;
    background-color: rgba(40, 167, 69, 0.05) !important;
    /* Ensure consistent sizing to prevent movement */
    box-sizing: border-box !important;
}

/* Loading state for AJAX validation - MAINTAIN NORMAL STYLING */
input.validating,
select.validating,
textarea.validating {
    /* Keep normal field styling during validation */
    border: 1px solid #555 !important;
    box-shadow: none !important;
    background-color: #444 !important;
    color: #eee !important;
    /* Ensure consistent sizing to prevent movement */
    box-sizing: border-box !important;
}

/* Default state - ensure consistent border for all fields */
input,
select,
textarea {
    border: 1px solid #555 !important;
    background-color: #444 !important;
    color: #eee !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

/* Light mode defaults */
body.light-mode input,
body.light-mode select,
body.light-mode textarea {
    border: 1px solid #ccc !important;
    background-color: #fff !important;
    color: #333 !important;
}

/* Neutral state - same as default */
input.neutral,
select.neutral,
textarea.neutral {
    border: 1px solid #555 !important;
    background-color: #444 !important;
    color: #eee !important;
    box-shadow: none !important;
}

body.light-mode input.neutral,
body.light-mode select.neutral,
body.light-mode textarea.neutral {
    border: 1px solid #ccc !important;
    background-color: #fff !important;
    color: #333 !important;
    box-shadow: none !important;
}

/* Light mode specific colors */
body.light-mode input.is-invalid,
body.light-mode select.is-invalid,
body.light-mode textarea.is-invalid,
body.light-mode input.error-field,
body.light-mode select.error-field,
body.light-mode textarea.error-field {
    border-color: #dc3545 !important;
    background-color: #fff5f5 !important;
    box-shadow: 0 0 0 0.1rem rgba(220, 53, 69, 0.15) !important;
}

body.light-mode input.is-valid,
body.light-mode select.is-valid,
body.light-mode textarea.is-valid {
    border-color: #28a745 !important;
    background-color: #f8fff9 !important;
    box-shadow: 0 0 0 0.1rem rgba(40, 167, 69, 0.15) !important;
}

body.light-mode input.validating,
body.light-mode select.validating,
body.light-mode textarea.validating {
    /* Keep normal field styling during validation in light mode */
    border: 1px solid #ccc !important;
    background-color: #fff !important;
    color: #333 !important;
    box-shadow: none !important;
}

/* REMOVED: All text feedback elements to prevent field movement */
/* NO .invalid-feedback, .valid-feedback, .error-message styling */
/* NO .validation-message, .server-error styling */

/* Hide any existing error/feedback text elements */
.invalid-feedback,
.valid-feedback,
.error-message,
.server-error,
.validation-message {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Focus states maintain visual validation */
input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

input.is-valid:focus,
select.is-valid:focus,
textarea.is-valid:focus {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
}

/* REMOVED: Validating focus state - no special styling during validation */

/* Ensure form groups maintain consistent spacing */
.form-group {
    margin-bottom: 1rem !important;
    /* Prevent any height changes from validation */
    min-height: auto !important;
}

/* REMOVED: All validation icon styling */
/* NO .validation-icon styling */

/* REMOVED: All bulk validation summary styling */
/* NO .bulk-validation-summary styling */

/* Make placeholder text visible in invalid fields */
body.light-mode input.is-invalid::placeholder,
body.light-mode select.is-invalid::placeholder,
body.light-mode textarea.is-invalid::placeholder,
body.light-mode input.error-field::placeholder,
body.light-mode select.error-field::placeholder,
body.light-mode textarea.error-field::placeholder {
    color: #999 !important;
    opacity: 1;
}

/* Responsive validation adjustments */
@media (max-width: 480px) {
    .invalid-feedback,
    .valid-feedback,
    .server-error {
        font-size: 0.8em;
    }
    
    .validation-icon {
        right: 8px;
        font-size: 14px;
    }
    
    input.validating,
    select.validating,
    textarea.validating {
        background-size: 14px 14px;
        background-position: right 8px center;
    }
}

/* Dark mode specific validation styles */
@media (prefers-color-scheme: dark) {
    input.is-invalid,
    select.is-invalid,
    textarea.is-invalid {
        background-color: rgba(220, 53, 69, 0.1);
    }
    
    input.is-valid,
    select.is-valid,
    textarea.is-valid {
        background-color: rgba(40, 167, 69, 0.1);
    }
    
    .invalid-feedback,
    .server-error {
        color: #ff6b6b;
    }
    
    .valid-feedback {
        color: #51cf66;
    }
}

/* Print styles - hide validation indicators */
@media print {
    input.is-invalid,
    input.is-valid,
    select.is-invalid,
    select.is-valid,
    textarea.is-invalid,
    textarea.is-valid {
        border-color: #999 !important;
        box-shadow: none !important;
        background-color: transparent !important;
    }
    
    .invalid-feedback,
    .valid-feedback,
    .server-error,
    .validation-icon {
        display: none !important;
    }
}

/* High contrast mode support for validation */
@media (forced-colors: active) {
    input.is-invalid,
    select.is-invalid,
    textarea.is-invalid {
        border: 2px solid CanvasText !important;
    }
    
    input.is-valid,
    select.is-valid,
    textarea.is-valid {
        border: 2px solid CanvasText !important;
    }
    
    .invalid-feedback,
    .valid-feedback {
        color: CanvasText !important;
    }
}

/* ===================================================================
 * LOADING SPINNER STYLES
 * Modern animated loading spinner for page navigation
 * ===================================================================*/

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(34, 34, 34, 0.9); /* Dark theme background */
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

body.light-mode .loading-overlay {
    background-color: rgba(245, 245, 245, 0.9); /* Light theme background */
}

.loading-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

/* Loading Spinner Container */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: #333;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
}

body.light-mode .loading-spinner {
    background: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

/* Modern Spinner Wheel */
.spinner-wheel {
    width: 50px;
    height: 50px;
    border: 4px solid #555;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

body.light-mode .spinner-wheel {
    border: 4px solid #ddd;
    border-top: 4px solid #4CAF50;
}

/* Loading Text */
.loading-text {
    color: #eee;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    margin: 0;
    font-family: 'Arial', sans-serif;
}

body.light-mode .loading-text {
    color: #333;
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive Design for Loading Spinner */
@media (max-width: 480px) {
    .loading-spinner {
        padding: 1.5rem;
        border-radius: 12px;
    }
    
    .spinner-wheel {
        width: 40px;
        height: 40px;
    }
    
    .loading-text {
        font-size: 0.9rem;
    }
}

/* Accessibility - Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .spinner-wheel {
        animation: none !important;
        border: 4px solid #4CAF50;
        border-radius: 50%;
    }
    
    .loading-overlay {
        transition: none;
    }
}

/* High contrast mode support for loading spinner */
@media (forced-colors: active) {
    .loading-spinner {
        border: 2px solid CanvasText;
        background: Canvas;
    }
    
    .spinner-wheel {
        border-color: CanvasText;
        border-top-color: Highlight;
    }
    
    .loading-text {
        color: CanvasText;
    }
}

/* Hide spinner when printing */
@media print {
    .loading-overlay {
        display: none !important;
    }
}

/* ===================================================================
 * AUTOFILL STYLES
 * Chrome autofill background and text color fixes for dark/light modes
 * ===================================================================*/

/* Dark mode autofill styling */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus,
select:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
textarea:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #444 inset !important;
    -webkit-text-fill-color: #eee !important;
    background-color: #444 !important;
    color: #eee !important;
    caret-color: #fff !important;
}

/* Light mode autofill styling */
body.light-mode input:-webkit-autofill,
body.light-mode input:-webkit-autofill:hover,
body.light-mode input:-webkit-autofill:focus,
body.light-mode input:-webkit-autofill:active,
body.light-mode select:-webkit-autofill,
body.light-mode select:-webkit-autofill:hover,
body.light-mode select:-webkit-autofill:focus,
body.light-mode select:-webkit-autofill:active,
body.light-mode textarea:-webkit-autofill,
body.light-mode textarea:-webkit-autofill:hover,
body.light-mode textarea:-webkit-autofill:focus,
body.light-mode textarea:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #fff inset !important;
    -webkit-text-fill-color: #333 !important;
    background-color: #fff !important;
    color: #333 !important;
    caret-color: #333 !important;
}

/* Form section specific autofill styles */
.form-section input:-webkit-autofill,
.form-section input:-webkit-autofill:hover,
.form-section input:-webkit-autofill:focus,
.form-section input:-webkit-autofill:active,
.form-section select:-webkit-autofill,
.form-section select:-webkit-autofill:hover,
.form-section select:-webkit-autofill:focus,
.form-section select:-webkit-autofill:active,
.form-section textarea:-webkit-autofill,
.form-section textarea:-webkit-autofill:hover,
.form-section textarea:-webkit-autofill:focus,
.form-section textarea:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #444 inset !important;
    -webkit-text-fill-color: #eee !important;
    background-color: #444 !important;
    color: #eee !important;
    caret-color: #fff !important;
}

/* Light mode form section autofill */
body.light-mode .form-section input:-webkit-autofill,
body.light-mode .form-section input:-webkit-autofill:hover,
body.light-mode .form-section input:-webkit-autofill:focus,
body.light-mode .form-section input:-webkit-autofill:active,
body.light-mode .form-section select:-webkit-autofill,
body.light-mode .form-section select:-webkit-autofill:hover,
body.light-mode .form-section select:-webkit-autofill:focus,
body.light-mode .form-section select:-webkit-autofill:active,
body.light-mode .form-section textarea:-webkit-autofill,
body.light-mode .form-section textarea:-webkit-autofill:hover,
body.light-mode .form-section textarea:-webkit-autofill:focus,
body.light-mode .form-section textarea:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #fff inset !important;
    -webkit-text-fill-color: #333 !important;
    background-color: #fff !important;
    color: #333 !important;
    caret-color: #333 !important;
}