/* Open Iconic removed - using Bootstrap Icons instead */

/* Import Inter font - Apple-like modern UI font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a, .btn-link {
    color: #0366d6;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

/* Navigation header text color fix - override any conflicting styles */
.nav-header {
    color: #7B3F99 !important;
}

.nav-header span {
    color: #7B3F99 !important;
}

/* Professional Dropdown Styling */
.dropdown {
    position: relative;
}

.dropdown-menu {
    z-index: 1070;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    background-color: #ffffff;
    min-width: 200px;
    padding: 0.5rem 0;
    margin: 0.125rem 0 0;
    position: fixed !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
}

/* Enhanced dropdown within cards */
.card .dropdown-menu {
    z-index: 1080;
}

/* Modal context dropdown */
.modal .dropdown-menu {
    z-index: 1090;
}

/* Prevent modal dialogs from being hidden by boosted z-index elements */
.modal,
.modal.show {
    --bs-modal-zindex: 2000;
    z-index: 2000 !important;
}

.modal-backdrop,
.modal-backdrop.show {
    --bs-backdrop-zindex: 1990;
    z-index: 1990 !important;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: #212529;
    text-decoration: none;
    background-color: transparent;
    border: none;
    width: 100%;
    text-align: left;
    transition: all 0.15s ease-in-out;
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: #1e2125;
    background-color: #f8f9fa;
}

.dropdown-item:active {
    color: #fff;
    background-color: #0d6efd;
}

.dropdown-item.disabled,
.dropdown-item:disabled {
    color: #6c757d;
    pointer-events: none;
    background-color: transparent;
}

/* Icon spacing in dropdown items */
.dropdown-item i {
    width: 1.25rem;
    text-align: center;
    margin-right: 0.5rem;
}

/* Colored icons in dropdown */
.dropdown-item .text-primary { color: #0d6efd !important; }
.dropdown-item .text-info { color: #0dcaf0 !important; }
.dropdown-item .text-success { color: #198754 !important; }
.dropdown-item .text-danger { color: #dc3545 !important; }
.dropdown-item .text-warning { color: #fd7e14 !important; }
.dropdown-item .text-secondary { color: #6c757d !important; }

/* Divider styling */
.dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    overflow: hidden;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
}

/* Animation for dropdown */
.dropdown-menu.show {
    animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .dropdown-menu {
        min-width: 180px;
        font-size: 0.875rem;
    }

    .dropdown-item {
        padding: 0.375rem 0.75rem;
    }
}

#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;
    }

/* Matrix Editor - Clean UI Styles */
.matrix-container {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.matrix-view-toggle {
    display: inline-flex;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.matrix-view-toggle .btn {
    border: none;
    background: transparent;
    color: #6c757d;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.matrix-view-toggle .btn.active {
    background: white;
    color: #0078d4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Clean Table Styling */
.matrix-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    font-size: 0.875rem;
}

.matrix-table th {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    padding: 10px 8px;
    font-weight: 600;
    color: #495057;
    text-align: center;
    position: sticky;
    z-index: 10;
}

.matrix-table th.corner-header {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    left: 0;
    top: 0;
    z-index: 12;
}

.matrix-table th.width-header {
    top: 0;
    min-width: 80px;
}

.matrix-table th.height-header {
    left: 0;
    min-width: 100px;
}

/* Matrix Cells */
.matrix-cell {
    position: relative;
    border: 1px solid #e9ecef;
    padding: 0;
    background: white;
    transition: all 0.2s ease;
    min-width: 80px;
    height: 40px;
}

.matrix-cell:hover {
    background-color: #f0f8ff;
    border-color: #b3d9ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 120, 212, 0.1);
}

.matrix-cell.selected {
    background-color: #e3f2fd;
    border-color: #2196f3;
    box-shadow: inset 0 0 0 1px #2196f3;
}

.matrix-cell.modified {
    background-color: #fff8e1;
    border-color: #ffc107;
}

.matrix-cell.editing {
    z-index: 100;
}

/* Cell Value Display */
.cell-value {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #212529;
}

.cell-value.empty {
    color: #adb5bd;
    font-style: italic;
    font-size: 0.75rem;
}

/* Inline Cell Editor */
.cell-editor {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    background: white;
    border: 2px solid #0078d4;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    padding: 8px;
    min-width: 120px;
}

.cell-editor-input {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.875rem;
    margin-bottom: 6px;
}

.cell-editor-input:focus {
    outline: none;
    border-color: #0078d4;
    box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.1);
}

.cell-editor-buttons {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.cell-editor-buttons .btn {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 3px;
}

/* Grid View Styles */
.matrix-grid {
    display: grid;
    gap: 4px;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.grid-cell {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 8px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.grid-cell:hover {
    background: #e3f2fd;
    border-color: #2196f3;
    transform: scale(1.05);
}

.grid-cell-header {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 4px;
}

.grid-cell-value {
    font-size: 1rem;
    font-weight: 600;
    color: #212529;
}

/* Status Indicators */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
}

.status-badge.changes {
    background: #fff3cd;
    color: #856404;
}

.status-badge.saved {
    background: #d1f2eb;
    color: #0f5132;
}

/* Smooth Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cell-editor {
    animation: slideIn 0.2s ease;
}

/* Loading State */
.matrix-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #6c757d;
}

.matrix-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* Fix contrast issues on purple backgrounds */
.bg-purple,
.product-header,
.card-header.bg-gradient {
    background: linear-gradient(135deg, #8e44ad, #9b59b6) !important;
}

/* Ensure all text on purple backgrounds is white or light colored */
.bg-purple *,
.product-header *,
.card-header.bg-gradient * {
    color: #ffffff !important;
}

/* Product code text - force white on purple */
.product-code,
.text-muted.product-code {
    color: rgba(255, 255, 255, 0.9) !important;
    opacity: 1 !important;
}

/* Badge improvements for better contrast */
.badge {
    font-weight: 500;
    padding: 0.375rem 0.75rem;
}

.badge.bg-success {
    background-color: #28a745 !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge.bg-info {
    background-color: #17a2b8 !important;
    color: #ffffff !important;
}

/* Price table improvements */
.price-matrix-table,
.table-bordered {
    border-collapse: separate;
    border-spacing: 1px;
    background-color: #dee2e6;
}

.price-matrix-table td,
.price-matrix-table th {
    border: 1px solid #adb5bd;
    background-color: #ffffff;
}

.price-matrix-table tbody tr:hover {
    background-color: #e3f2fd;
}

.price-matrix-table tbody td:hover {
    background-color: #bbdefb;
    outline: 2px solid #2196f3;
    position: relative;
    z-index: 1;
}

/* Modern focus styles - elegant purple theme */
*:focus {
    outline: none;
}

button:focus,
.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(123, 63, 153, 0.25);
    outline: none;
}

/* Modern input focus - Material Design inspired */
.form-control,
.form-select {
    border: 1px solid #dee2e6;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    color: black !important;
}

.form-control:focus,
.form-select:focus {
    border-color: #7B3F99;
    box-shadow: none;
    outline: none;
}

/* Floating labels - Material Design style */
.form-floating > .form-control,
.form-floating > .form-select {
    border: none;
    border-bottom: 2px solid #dee2e6;
    border-radius: 0;
    background-color: transparent;
    padding-left: 0;
    padding-right: 0;
    box-shadow: none;
}

.form-floating > .form-control:focus,
.form-floating > .form-select:focus {
    border-bottom-color: #7B3F99;
    box-shadow: none;
    background-color: transparent;
}

/* Fix label positioning when input has value */
.form-floating > .form-control:not(:placeholder-shown),
.form-floating > .form-select:not(:placeholder-shown) {
    background-color: transparent;
    border-bottom-color: #dee2e6;
}

/* Remove green border validation styles */
.form-control.valid,
.form-control:valid,
.form-floating > .form-control:valid {
    border-color: #dee2e6;
    border-bottom-color: #dee2e6;
    background-image: none;
}

.form-control:valid:focus,
.form-floating > .form-control:valid:focus {
    border-bottom-color: #7B3F99;
    box-shadow: none;
}

.form-floating > label {
    color: #6c757d;
    padding-left: 0;
}

/* Improve text contrast on cards */
.card-body .text-muted {
    color: #495057;
}

/* Navigation active state improvements */
.nav-link.active {
    background-color: #8e44ad;
    color: #ffffff;
    border-left: 4px solid #ffffff;
}

.nav-link:hover {
    background-color: rgba(142, 68, 173, 0.1);
    color: #8e44ad;
}

/* Ensure form labels have good contrast */
label {
    color: #212529;
    font-weight: 500;
}

/* Table header improvements */
thead th {
    background-color: #f8f9fa;
    color: #212529;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
}

/* Specific fixes for matrix table headers */
.matrix-table thead th,
.matrix-table th.table-light,
.table-light th {
    background-color: #ffffff;
    color: #212529;
    font-weight: 600;
    border: 2px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Corner and axis headers with stronger contrast */
.matrix-table th.corner-header,
.matrix-table th.width-header,
.matrix-table th.height-header {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    color: #212529;
    font-weight: 700;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
    border: 2px solid #adb5bd;
}

/* Fix contrast for disabled elements */
.btn:disabled,
.form-control:disabled {
    opacity: 0.65;
    background-color: #e9ecef;
    color: #6c757d;
}

/* Improve visibility of statistics cards */
.stat-card .display-4 {
    color: #212529;
    font-weight: 600;
}

.stat-card .text-muted {
    color: #495057;
    font-size: 0.9rem;
}

/* Matrix editor specific contrast fixes */
.matrix-table th {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #adb5bd;
    color: #212529;
}

.cell-value {
    color: #212529;
}

.cell-value.empty {
    color: #6c757d;
}

/* Responsive improvements for mobile */
@media (max-width: 768px) {
    .price-matrix-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .price-matrix-table table {
        min-width: 800px;
    }
}

/* Accordion header text visibility fix */
.modal .accordion-button {
    color: #212529;
}

.modal .accordion-button:not(.collapsed) {
    color: #212529;
    background-color: #e7f1ff;
}

.modal .accordion-button:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.modal .accordion-button strong {
    color: #212529;
}

/* Ensure accordion content text is visible */
.modal .accordion-item {
    color: #212529;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bg-purple,
    .product-header,
    .card-header.bg-gradient {
        background: #000000 !important;
        border: 2px solid #ffffff;
    }

    .price-matrix-table td,
    .price-matrix-table th {
        border: 2px solid #000000 !important;
    }

    *:focus {
        outline: 3px solid #ffff00 !important;
    }
}

/* ===== DROPDOWN IMPROVEMENTS ===== */

/* Ensure dropdown container has proper positioning */
.dropdown {
    position: relative;
}

/* Robust dropdown menu styling */
.dropdown-menu {
    /* Enhanced z-index to ensure visibility above all content */
    z-index: 1070 !important;

    /* Proper positioning */
    position: absolute !important;

    /* Enhanced visual styling */
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

    /* Ensure consistent minimum width */
    min-width: 180px;

    /* Prevent content cutoff */
    overflow: visible;

    /* Animation for smooth appearance */
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

/* Show dropdown with animation */
.dropdown-menu.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Enhanced dropdown items */
.dropdown-item {
    padding: 8px 16px;
    color: #212529 !important;
    font-size: 0.9rem;
    line-height: 1.5;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* Dropdown item hover and focus states */
.dropdown-item:hover,
.dropdown-item:focus {
    background-color: #f8f9fa !important;
    color: #16181b !important;
    outline: none;
}

/* Active dropdown item */
.dropdown-item:active {
    background-color: #e9ecef !important;
    color: #16181b !important;
}

/* Disabled dropdown item */
.dropdown-item:disabled,
.dropdown-item.disabled {
    color: #6c757d !important;
    background-color: transparent !important;
    cursor: not-allowed;
    opacity: 0.65;
}

/* Colored dropdown items maintain their colors on hover */
.dropdown-item.text-success:hover,
.dropdown-item.text-success:focus {
    color: #198754 !important;
    background-color: rgba(25, 135, 84, 0.1) !important;
}

.dropdown-item.text-danger:hover,
.dropdown-item.text-danger:focus {
    color: #dc3545 !important;
    background-color: rgba(220, 53, 69, 0.1) !important;
}

.dropdown-item.text-warning:hover,
.dropdown-item.text-warning:focus {
    color: #fd7e14 !important;
    background-color: rgba(253, 126, 20, 0.1) !important;
}

/* Dropdown dividers */
.dropdown-divider {
    height: 1px;
    margin: 4px 0;
    overflow: hidden;
    background-color: #e9ecef;
    border: none;
}

/* Icon spacing in dropdown items */
.dropdown-item i {
    width: 16px;
    text-align: center;
    margin-right: 8px;
}

/* Ensure dropdown shows above cards and modals */
.card .dropdown-menu {
    z-index: 1080 !important;
}

.modal .dropdown-menu {
    z-index: 1090 !important;
}

/* Fix for dropdowns in navbar */
.navbar .dropdown-menu {
    z-index: 1100 !important;
}

/* Prevent dropdown from being cut off by parent containers */
.dropdown-menu-end {
    right: 0 !important;
    left: auto !important;
}

/* Ensure dropdown button maintains proper styling */
.dropdown-toggle:after {
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
}

.dropdown-toggle:empty:after {
    margin-left: 0;
}

/* Mobile responsive dropdown adjustments */
@media (max-width: 767.98px) {
    .dropdown-menu {
        min-width: 160px;
        max-width: calc(100vw - 32px);
    }

    .dropdown-item {
        padding: 10px 16px;
        font-size: 0.95rem;
    }
}

/* Dark mode support for dropdowns */
@media (prefers-color-scheme: dark) {
    .dropdown-menu {
        background-color: #343a40;
        border-color: #495057;
    }

    .dropdown-item {
        color: #f8f9fa !important;
    }

    .dropdown-item:hover,
    .dropdown-item:focus {
        background-color: #495057 !important;
        color: #f8f9fa !important;
    }

    .dropdown-divider {
        background-color: #495057;
    }
}

/* High contrast mode dropdown support */
@media (prefers-contrast: high) {
    .dropdown-menu {
        border: 2px solid #000000 !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
    }

    .dropdown-item {
        border-bottom: 1px solid #e9ecef;
    }

    .dropdown-item:hover,
    .dropdown-item:focus {
        background-color: #ffff00 !important;
        color: #000000 !important;
        outline: 2px solid #000000 !important;
    }
}

/* Accessibility improvements */
.dropdown-item:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

/* Fix for Bootstrap 5.3.0 specific issues */
.dropdown-menu[data-bs-popper] {
    margin-top: 2px;
}

/* Ensure dropdown works with flex layouts */
.d-flex .dropdown,
.flex-row .dropdown,
.justify-content-end .dropdown {
    position: relative;
}

.d-flex .dropdown-menu,
.flex-row .dropdown-menu,
.justify-content-end .dropdown-menu {
    position: absolute !important;
}

/* Modal z-index fixes */
.modal {
    z-index: 1055 !important;
}

.modal-backdrop {
    z-index: 1050 !important;
}

.modal.show {
    display: block !important;
}

/* Ensure modals appear above all other content */
.modal-dialog {
    z-index: 1056 !important;
    position: relative;
}

/* Fix for modal focus issues */
.modal-content {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
    border: none !important;
    border-radius: 0.5rem !important;
}

/* Modals in fullscreen are handled dynamically via JavaScript */
