/* Item Catalog specific styles */

/* ITEMS CATALOG HEADER - Dark Orange Bold to match theme */
.catalog-content-wrapper h4.text-primary {
    color: #cc5200 !important; /* Very dark orange - visible in light mode */
    font-weight: 700 !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.catalog-container {
    position: relative; /* Added for drag-icon positioning */
}

/* Fixed toolbar styling - consistent with BOQ page */
.catalog-toolbar-fixed {
    position: fixed;
    top: 60px; /* Below navbar */
    left: 0;
    right: 0;
    z-index: 1020;
    background-color: white;
    border-bottom: 2px solid #cc5200;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 0.5rem 1rem;
}

/* Dark mode support for fixed toolbar */
[data-theme="dark"] .catalog-toolbar-fixed {
    background-color: #212529;
    border-bottom-color: #cc5200;
    color: #e9ecef;
}

/* Ensure content doesn't hide behind fixed toolbar */
.catalog-content-wrapper {
    padding-top: 120px; /* Account for navbar (60px) + toolbar (60px) */
}

/* Professional button styling - consistent with BOQ */
.catalog-toolbar .btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.catalog-toolbar .btn-primary {
    background-color: #cc5200;
    border-color: #cc5200;
    color: white;
}

.catalog-toolbar .btn-primary:hover {
    background-color: #b84600;
    border-color: #b84600;
    color: white;
}

.catalog-toolbar .btn-outline-primary {
    color: #cc5200;
    border-color: #cc5200;
}

.catalog-toolbar .btn-outline-primary:hover {
    background-color: #cc5200;
    border-color: #cc5200;
    color: white;
}

/* Dark mode button adjustments */
[data-theme="dark"] .catalog-toolbar .btn-outline-secondary {
    color: #adb5bd;
    border-color: #6c757d;
}

[data-theme="dark"] .catalog-toolbar .btn-outline-secondary:hover {
    background-color: #6c757d;
    color: white;
}

/* Search section styling - fixed below toolbar */
.catalog-search-fixed {
    position: fixed;
    top: 120px; /* Below toolbar (60px navbar + 60px toolbar) */
    left: 0;
    right: 0;
    z-index: 1019;
    background-color: white;
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Dark mode search section */
[data-theme="dark"] .catalog-search-fixed {
    background-color: #343a40;
    border-bottom-color: #495057;
    color: #e9ecef;
}

/* Selection checkboxes styling - consistent with BOQ */
.catalog-table .row-select,
.catalog-table #selectAll {
    transform: scale(1.1);
    accent-color: #cc5200;
    cursor: pointer;
}

/* Highlight selected rows */
.catalog-table tr.selected {
    background-color: #fff3cd !important;
    border-left: 3px solid #cc5200;
}

.catalog-table tr.selected.phase-row {
    background-color: #ffdb70 !important;
    border-left: 4px solid #cc5200 !important;
    box-shadow: 0 0 10px rgba(204, 82, 0, 0.3) !important;
}

.catalog-table tr.selected.cc-row {
    background-color: #ddd6fe !important;
}

.catalog-table tr.selected.item-row {
    background-color: #fef3c7 !important;
}

/* Dark mode selected rows */
[data-theme="dark"] .catalog-table tr.selected {
    background-color: #495057 !important;
    color: #e9ecef;
}

/* Ensure modals appear above sticky table headers */
.modal {
    z-index: 1060 !important;
}

.modal-backdrop {
    z-index: 1055 !important;
}

/* Fix any sticky table headers that might interfere with modals */
#catalogTable thead th {
    z-index: 1040 !important;
}
}

/* =================================================================
   HIERARCHICAL TABLE STYLING - Professional Construction Management
   ================================================================= */

/* Base table styling override - prevent conflicts */
#catalogTable {
    width: 100% !important;
    border-collapse: collapse !important;
    border-spacing: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    table-layout: fixed !important;
}

#catalogTable td {
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
    transition: background-color 0.2s ease;
    padding: 8px !important;
}

/* Phase row styling - Reference Color #474747 */
.phase-row,
.catalog-phase-row {
    background-color: #474747 !important;
    border-left: 4px solid #cc5200 !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    cursor: pointer;
    border-top: 1px solid rgba(204, 82, 0, 0.4) !important;
    border-bottom: 1px solid rgba(204, 82, 0, 0.4) !important;
    color: #ffffff !important;
}

.phase-row:hover,
.catalog-phase-row:hover {
    background-color: #525252 !important;
}

/* Phase text should be uppercase and larger */
.catalog-phase-row td,
.catalog-phase-row th,
.phase-row td,
.phase-row th {
    font-weight: 700 !important;
    font-size: 1rem !important;
    text-transform: uppercase !important;
    background-color: #474747 !important;
    color: #ffffff !important;
}

/* Cost Center row styling - Reference Color #707070 */
.cc-row,
.catalog-cc-row {
    background-color: #707070 !important;
    font-weight: 500 !important;
    border-left: 2px solid #606060 !important;
    border-top: 1px solid rgba(112, 112, 112, 0.4) !important;
    border-bottom: 1px solid rgba(112, 112, 112, 0.4) !important;
    color: #ffffff !important;
}

.cc-row:hover,
.catalog-cc-row:hover {
    background-color: #808080 !important;
}

.cc-row td,
.cc-row th,
.catalog-cc-row td,
.catalog-cc-row th {
    background-color: #707070 !important;
    color: #ffffff !important;
    font-weight: 500 !important;
}

.phase-row td {
    padding: 12px 8px;
    border-bottom: 2px solid #dee2e6;
}

/* Cost Center row styling - Level 2 */
.cc-row {
    background-color: #ffffff;
    border-left: 3px solid #28a745;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
}

.cc-row:hover {
    background-color: #f8f9fa;
}

.cc-row td {
    padding: 10px 8px;
    padding-left: 20px; /* Indent for hierarchy */
}

.cc-row td:first-child {
    padding-left: 8px; /* Reset first column */
}

/* Item row styling - Level 3 */
.item-row {
    background-color: #ffffff;
    font-size: 0.9rem;
    border-left: 2px solid #17a2b8;
}

.item-row:hover {
    background-color: #f1f3f5;
}

.item-row td {
    padding: 8px;
    padding-left: 40px; /* Greater indent for items */
}

.item-row td:first-child,
.item-row td:nth-child(2) {
    padding-left: 8px; /* Reset first two columns */
}

/* Toggle button styling */
.toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid #dee2e6;
    background-color: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    font-family: monospace;
    font-weight: bold;
    font-size: 14px;
    color: #495057;
    transition: all 0.2s ease;
    user-select: none;
}

.toggle-btn:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
    color: #212529;
}

.phase-row .toggle-btn {
    background-color: #cc5200;
    color: white;
    border-color: #cc5200;
}

.phase-row .toggle-btn:hover {
    background-color: #e55a00;
}

.cc-row .toggle-btn {
    background-color: #28a745;
    color: white;
    border-color: #28a745;
}

.cc-row .toggle-btn:hover {
    background-color: #218838;
}

/* Row visibility states */
.phase-row.collapsed + .cc-row,
.phase-row.collapsed ~ .cc-row,
.phase-row.collapsed ~ .item-row {
    display: none;
}

.cc-row.collapsed + .item-row,
.cc-row.collapsed ~ .item-row[data-parent] {
    display: none;
}

/* Visual hierarchy indicators removed for cleaner interface */

/* Professional status indicators */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active { background-color: #d4edda; color: #155724; }
.status-inactive { background-color: #f8d7da; color: #721c24; }
.status-pending { background-color: #fff3cd; color: #856404; }

/* Dark mode support */
[data-theme="dark"] .phase-row {
    background-color: #343a40;
    color: #e9ecef;
}

[data-theme="dark"] .cc-row {
    background-color: #495057;
    color: #e9ecef;
}

[data-theme="dark"] .item-row {
    background-color: #212529;
    color: #e9ecef;
}

[data-theme="dark"] .phase-row:hover {
    background-color: #495057;
}

[data-theme="dark"] .cc-row:hover {
    background-color: #6c757d;
}

[data-theme="dark"] .item-row:hover {
    background-color: #343a40;
}

[data-theme="dark"] .toggle-btn {
    background-color: #495057;
    border-color: #6c757d;
    color: #adb5bd;
}

[data-theme="dark"] .toggle-btn:hover {
    background-color: #6c757d;
    color: #ffffff;
}

/* Responsive design */
@media (max-width: 768px) {
    .phase-row td,
    .cc-row td,
    .item-row td {
        padding-left: 10px;
        font-size: 0.85rem;
    }

    .cc-row td {
        padding-left: 15px;
    }

    .item-row td {
        padding-left: 25px;
    }
}

/* Animation for smooth expand/collapse */
.catalog-table tbody tr {
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

.catalog-table tbody tr.collapsing {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
}

/* Professional edit button styling */
.edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    color: #6c757d;
    text-decoration: none;
    transition: all 0.2s ease;
}

.edit-btn:hover {
    background-color: #e9ecef;
    color: #495057;
}

[data-theme="dark"] .edit-btn {
    color: #adb5bd;
}

[data-theme="dark"] .edit-btn:hover {
    background-color: #495057;
    color: #e9ecef;
}
}

[data-theme="dark"] .catalog-table tr.selected.phase-row {
    background-color: #6c520f !important;
}

[data-theme="dark"] .catalog-table tr.selected.cc-row {
    background-color: #4c4f69 !important;
}

/* Improve button group spacing and consistency */
.catalog-toolbar .btn-group + .btn-group {
    margin-left: 0.5rem;
}

/* Dropdown improvements for dark mode */
[data-theme="dark"] .dropdown-menu {
    background-color: #495057;
    border-color: #6c757d;
}

[data-theme="dark"] .dropdown-item {
    color: #e9ecef;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: #6c757d;
    color: #ffffff;
}

/* Input group improvements for dark mode */
[data-theme="dark"] .form-control {
    background-color: #495057;
    border-color: #6c757d;
    color: #e9ecef;
}

[data-theme="dark"] .form-control:focus {
    background-color: #495057;
    border-color: #cc5200;
    color: #e9ecef;
    box-shadow: 0 0 0 0.2rem rgba(204, 82, 0, 0.25);
}

/* Professional table row styling */
#catalogTable tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
}

#catalogTable tbody tr:hover {
    background-color: rgba(204, 82, 0, 0.05) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(204, 82, 0, 0.15);
}

#catalogTable tbody tr:nth-child(even) {
    background-color: rgba(248, 249, 250, 0.5);
}

/* Dark mode table improvements */
[data-theme="dark"] #catalogTable {
    background-color: #212529;
}

[data-theme="dark"] #catalogTable tbody tr {
    border-bottom-color: #495057;
}

[data-theme="dark"] #catalogTable tbody tr:hover {
    background-color: rgba(204, 82, 0, 0.15) !important;
}

[data-theme="dark"] #catalogTable tbody tr:nth-child(even) {
    background-color: rgba(52, 58, 64, 0.5);
}

/* Professional column styling for estimators */
#catalogTable td {
    padding: 12px 8px;
    vertical-align: middle;
    border-right: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

#catalogTable td:last-child {
    border-right: none;
}

/* Item code column styling */
.item-code {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    font-size: 0.85rem;
    color: #0066cc;
    background-color: rgba(0, 102, 204, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* Description column styling */
.item-description {
    line-height: 1.4;
    color: #333;
    font-weight: 500;
}

/* Unit badge styling */
.badge.bg-secondary {
    background-color: #6c757d !important;
    font-weight: 600;
    padding: 6px 10px;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

/* Price styling for estimators */
.text-success {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: #28a745 !important;
}

/* Action button improvements */
.edit-btn {
    color: #6c757d;
    text-decoration: none;
    transition: all 0.2s ease;
    padding: 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.edit-btn:hover {
    color: #cc5200;
    background-color: rgba(204, 82, 0, 0.1);
    text-decoration: none;
    transform: scale(1.1);
}

/* Dark mode column adjustments */
[data-theme="dark"] #catalogTable td {
    border-right-color: #495057;
    color: #e9ecef;
}

[data-theme="dark"] .item-code {
    color: #66b3ff;
    background-color: rgba(102, 179, 255, 0.15);
}

[data-theme="dark"] .item-description {
    color: #e9ecef;
}

[data-theme="dark"] .edit-btn {
    color: #adb5bd;
}

[data-theme="dark"] .edit-btn:hover {
    color: #cc5200;
    background-color: rgba(204, 82, 0, 0.2);
}

/* Responsive design for professional estimator tables */
@media (max-width: 768px) {
    /* Adjust fixed positioning for mobile */
    .catalog-toolbar-fixed {
        top: 50px; /* Reduced navbar height on mobile */
        padding: 0.4rem 0.8rem;
    }

    .catalog-search-fixed {
        top: 100px; /* Adjusted for mobile toolbar */
        padding: 0.5rem 0.8rem;
    }

    .catalog-content-wrapper {
        padding-top: 160px; /* Reduced for mobile */
    }

    #catalogTable th {
        top: 160px; /* Adjusted for mobile layout */
        padding: 10px 6px;
        font-size: 0.8rem;
    }

    #catalogTable td {
        padding: 8px 4px;
        font-size: 0.85rem;
    }

    /* Mobile-friendly column widths */
    #catalogTable th:nth-child(1),
    #catalogTable td:nth-child(1) { width: 30px; }

    #catalogTable th:nth-child(2),
    #catalogTable td:nth-child(2) { width: 30px; }

    #catalogTable th:nth-child(3),
    #catalogTable td:nth-child(3) { width: 120px; }

    #catalogTable th:nth-child(5),
    #catalogTable td:nth-child(5) { width: 70px; }

    #catalogTable th:nth-child(6),
    #catalogTable td:nth-child(6) { width: 100px; }

    #catalogTable th:nth-child(7),
    #catalogTable td:nth-child(7) { width: 40px; }

    /* Hide less critical columns on very small screens */
    @media (max-width: 480px) {
        #catalogTable th:nth-child(1),
        #catalogTable td:nth-child(1) { display: none; }

        #catalogTable th:nth-child(2),
        #catalogTable td:nth-child(2) { display: none; }
    }
}

/* Enhanced table container for better scrolling */
.table-responsive {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Professional loading state */
.catalog-loading {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
    font-style: italic;
}

/* Enhanced selection styles for estimators */
.form-check-input:checked {
    background-color: #cc5200;
    border-color: #cc5200;
}

.form-check-input:focus {
    border-color: #cc5200;
    box-shadow: 0 0 0 0.25rem rgba(204, 82, 0, 0.25);
}

/* Professional notes icon styling */
.notes-icon {
    transition: all 0.2s ease;
    border-radius: 50%;
    padding: 2px;
}

.notes-icon:hover {
    background-color: rgba(204, 82, 0, 0.1);
    transform: scale(1.2);
}

/* Table styles - Professional estimator design */
#catalogTable {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin-bottom: 0;
    table-layout: fixed;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    background-color: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

#catalogTable th {
    position: sticky;
    top: 185px; /* Adjusted for navbar (60px) + toolbar (60px) + search section (65px) */
    background-color: #f8f9fa;
    z-index: 100;
    padding: 15px 12px;
    text-align: left;
    border-bottom: 3px solid #cc5200;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1.3;
    vertical-align: middle;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #2c3e50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Dark mode table header */
[data-theme="dark"] #catalogTable th {
    background-color: #343a40;
    color: #e9ecef;
    border-bottom-color: #cc5200;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Professional row hierarchy styling for estimators */
.phase-row {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.15) 0%, rgba(255, 143, 0, 0.1) 100%) !important;
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    border-left: 5px solid #ebb012 !important;
    border-top: 2px solid rgba(255, 143, 0, 0.4) !important;
    border-bottom: 2px solid rgba(255, 143, 0, 0.4) !important;
    padding: 1rem 0.8rem !important;
    position: relative;
    box-shadow: 0 3px 12px rgba(255, 143, 0, 0.2) !important;
    margin: 2px 0 !important;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.phase-row strong {
    font-weight: 800;
    color: #e65100;
}

.cc-row {
    background: linear-gradient(90deg, rgba(108, 117, 125, 0.1) 0%, rgba(248, 249, 250, 0.8) 100%) !important;
    border-left: 3px solid #6c757d !important;
    padding: 0.6rem 0.8rem 0.6rem 1.2rem !important;
    font-weight: 600 !important;
    font-size: 0.95rem;
    color: #495057;
    border-bottom: 1px solid rgba(108, 117, 125, 0.2) !important;
}

.item-row {
    padding: 0.5rem 0.3rem !important;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f8f9fa !important;
}

.item-row:hover {
    background-color: rgba(204, 82, 0, 0.05) !important;
    border-left: 3px solid #cc5200 !important;
}

/* Drag and drop styles */
.draggable-item {
    cursor: grab;
}

.draggable-item:hover {
    background-color: rgba(245, 179, 1, 0.1);
}

.draggable-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* Project Total Row in Table */
.project-total-row {
    position: sticky;
    bottom: 0;
    z-index: 50;
    background: linear-gradient(135deg, #a16207 0%, #7c2d12 100%);
    box-shadow: 0 -2px 10px rgba(161, 98, 7, 0.3);
    border-top: 3px solid #7c2d12 !important;
}

.project-total-row td {
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    background-color: transparent !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    padding: 8px !important;
    vertical-align: middle !important;
}

/* Light mode - ensure white text in project total row */
[data-theme="light"] .project-total-row td {
    color: #ffffff !important;
}

.project-total-row td:nth-last-child(2) {
    font-size: 0.9rem !important;
    font-weight: 600 !important;
}

.project-total-row td:last-child {
    font-size: 1.2rem !important;
    font-weight: 800 !important;
}

/* Enhanced Sticky Project Total Footer */
.project-total-sticky {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    background: linear-gradient(135deg, #a16207 0%, #7c2d12 100%);
    color: white;
    padding: 12px 20px;
    border-top: 3px solid #7c2d12;
    box-shadow: 0 -4px 20px rgba(161, 98, 7, 0.35);
    font-size: 1.1rem;
    font-weight: 700;
    text-align: right;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(100%);
    opacity: 0;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    visibility: hidden;
}

.project-total-sticky.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.project-total-sticky .total-label {
    font-size: 1rem;
    opacity: 0.9;
    margin-right: 20px;
}

.project-total-sticky .total-amount {
    font-size: 1.3rem;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    color: #fff;
}

/* Ensure body has space for sticky total when active */
body.boq-page {
    padding-bottom: 0;
    transition: padding-bottom 0.3s ease;
}

body.boq-page.sticky-total-active {
    padding-bottom: 70px;
}

/* ENFORCED: Project Total Row Text WHITE - Maximum Specificity */
.project-total-row td,
.boq-table .project-total-row td,
#boqTable .project-total-row td,
table.boq-table .project-total-row td {
    color: #ffffff !important;
}

.project-total-row td.text-end,
.boq-table .project-total-row td.text-end,
#boqTable .project-total-row td.text-end {
    color: #ffffff !important;
}

/* Dark theme support */
[data-theme="dark"] .project-total-row {
    background: linear-gradient(135deg, #b85c1f 0%, #92400e 100%);
    box-shadow: 0 -2px 10px rgba(184, 92, 31, 0.4);
}

[data-theme="dark"] .project-total-row td {
    color: #ffffff !important;
    border-top-color: #92400e !important;
}

[data-theme="dark"] .project-total-sticky {
    background: linear-gradient(135deg, #b85c1f 0%, #92400e 100%);
    border-top-color: #92400e;
    box-shadow: 0 -4px 20px rgba(184, 92, 31, 0.4);
    color: #fef3c7;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .boq-page .project-total-sticky {
        padding: 12px 15px;
        font-size: 1rem;
        text-align: center;
    }
    
    .boq-page .project-total-sticky .total-label {
        display: block;
        margin-right: 0;
        margin-bottom: 5px;
        font-size: 0.9rem;
    }
    
    .boq-page .project-total-sticky .total-amount {
        font-size: 1.2rem;
    }
    
    .boq-page .boq-container {
        padding-bottom: 90px; /* More space on mobile */
    }
}

/* Print styles for Project Total */
@media print {
    .boq-page .project-total-sticky {
        position: static !important;
        page-break-inside: avoid;
        break-inside: avoid;
        margin-top: 30px;
        border-radius: 0;
        box-shadow: none;
        border: 2px solid #333;
        background: #f8f9fa !important;
        color: #333 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .boq-page .boq-container {
        padding-bottom: 0;
    }
    
    /* Ensure total appears on last page */
    .boq-page .project-total-sticky {
        page-break-before: auto;
    }
}

.drop-target {
    background-color: rgba(245, 179, 1, 0.2) !important;
    border: 2px dashed #F5B301 !important;
}

.drag-icon {
    display: inline-block;
    background-color: #007bff;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Toggle button - consistent with BOQ styling */
.toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    cursor: pointer;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    color: #666;
    font-size: 16px;
    font-weight: bold;
    user-select: none;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.toggle-btn:hover {
    background-color: #cc5200;
    color: white;
    border-color: #cc5200;
    transform: scale(1.1);
    box-shadow: 0 2px 5px rgba(255,102,0,0.3);
}

/* Dark mode toggle button */
[data-theme="dark"] .toggle-btn {
    background-color: #495057;
    border-color: #6c757d;
    color: #adb5bd;
}

[data-theme="dark"] .toggle-btn:hover {
    background-color: #cc5200;
    color: white;
    border-color: #cc5200;
}

/* Arrow elements in items catalog */
.catalog-arrow,
.item-arrow,
.phase-arrow-text,
.cc-arrow-text {
    color: #F5B301 !important;
}

.toggle-btn:hover {
    background-color: #e9ecef;
}

/* Make + and - smaller only in the CC expand/collapse buttons */
.global-expand-cc .bi-plus-lg,
.global-collapse-cc .bi-dash-lg {
    font-size: 0.7rem !important;
}

/* Make the main expand/collapse buttons bigger */
.global-expand .bi-plus-lg,
.global-collapse .bi-dash-lg {
    font-size: 1.8rem !important; /* Increased size */
}

.toggle-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
    text-decoration: none !important;
}

/* Item selection */
.item-select {
    cursor: pointer;
}

/* =================================================================
   COLUMN RESIZER SYSTEM - Professional Table Column Resizing
   ================================================================= */

/* Column resize handle - positioned at right edge of header */
.column-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    border-right: 2px solid transparent;
    transition: all 0.2s ease;
    z-index: 1050;
}

/* Hover effect for resize handle */
.column-resize-handle:hover {
    background-color: rgba(204, 82, 0, 0.1);
    border-right-color: #cc5200;
}

/* Active resizing state */
.column-resize-handle:active,
#catalogTable.column-resizing .column-resize-handle {
    background-color: rgba(204, 82, 0, 0.2);
    border-right-color: #cc5200;
}

/* Visual feedback during column resizing */
#catalogTable.column-resizing {
    user-select: none;
    cursor: col-resize;
}

#catalogTable.column-resizing th {
    border-right: 1px solid #dee2e6;
}

#catalogTable.column-resizing tbody tr {
    pointer-events: none;
}

/* Ensure table layout supports resizing */
#catalogTable {
    table-layout: fixed !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

/* Column width constraints for resizing */
#catalogTable th {
    min-width: 40px; /* Minimum width to prevent disappearing columns */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

#catalogTable td {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

/* Special handling for description column - allow text wrapping */
#catalogTable th:nth-child(4),
#catalogTable td:nth-child(4) {
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Dark mode support for resize handles */
[data-theme="dark"] .column-resize-handle:hover {
    background-color: rgba(204, 82, 0, 0.15);
    border-right-color: #cc5200;
}

[data-theme="dark"] .column-resize-handle:active,
[data-theme="dark"] #catalogTable.column-resizing .column-resize-handle {
    background-color: rgba(204, 82, 0, 0.25);
    border-right-color: #cc5200;
}

/* Responsive behavior for column resizing */
@media (max-width: 768px) {
    .column-resize-handle {
        width: 12px; /* Larger touch target on mobile */
    }

    #catalogTable th {
        min-width: 60px; /* Slightly larger minimum on mobile */
    }
}

/* Column resizer tooltip (optional enhancement) */
.column-resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 1px;
    width: 1px;
    height: 20px;
    background-color: #ccc;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.column-resize-handle:hover::after {
    opacity: 1;
}

/* Remove fixed width constraints to allow dynamic resizing */
#catalogTable th:nth-child(1),
#catalogTable td:nth-child(1) {
    width: auto;
    min-width: 40px;
    max-width: none;
}

#catalogTable th:nth-child(2),
#catalogTable td:nth-child(2) {
    width: auto;
    min-width: 40px;
    max-width: none;
}

#catalogTable th:nth-child(3),
#catalogTable td:nth-child(3) {
    width: auto;
    min-width: 120px;
    max-width: none;
}

#catalogTable th:nth-child(4),
#catalogTable td:nth-child(4) {
    width: auto;
    min-width: 200px;
    max-width: none;
}

#catalogTable th:nth-child(5),
#catalogTable td:nth-child(5) {
    width: auto;
    min-width: 60px;
    max-width: none;
}

#catalogTable th:nth-child(6),
#catalogTable td:nth-child(6) {
    width: auto;
    min-width: 80px;
    max-width: none;
}

#catalogTable th:nth-child(7),
#catalogTable td:nth-child(7) {
    width: auto;
    min-width: 80px;
    max-width: none;
}

/* Keep actions column fixed (last column) */
#catalogTable th:last-child,
#catalogTable td:last-child {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
}

/* Notes icon */
.notes-icon {
    cursor: pointer;
    color: var(--primary-color);
    font-size: 0.8rem;
    color: #495057;
}

.notes-icon:hover {
    color: var(--primary-color);
}

/* Drag and Drop styles */
.item-row[draggable="true"] {
    cursor: move;
    transition: background-color 0.2s;
}

.item-row.dragging {
    opacity: 0.5;
    background-color: #f0f8ff;
}

.cc-row.drop-target {
    background-color: rgba(245, 179, 1, 0.1);
    border: 2px dashed var(--primary-color);
}

.drag-handle {
    cursor: move;
    margin-right: 5px;
}

.bi-sticky-fill {
    color: #ffc107;
    margin-left: 5px;
    vertical-align: text-top;
}

/* Collapsed state margin adjustments */
.item-row td:first-child {
    padding-left: 1rem;
}

.cc-row td:first-child {
    padding-left: 0.5rem;
}

/* Add some hover effects */
.item-row:hover {
    background-color: var(--hover-bg);
    background-color: rgba(245, 179, 1, 0.1);
}

/* Dark mode specific adjustments */
@media (prefers-color-scheme: dark) {
    .phase-row {
        background-color: var(--phase-bg-dark, #2d1b0d);
        border-left-color: #F5B301;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    .cc-row {
        background-color: var(--cc-bg-dark, #34495e);
        border-left-color: #6c757d;
    }

    .item-row:hover {
        background-color: var(--hover-bg-dark, #3d566e);
    }
}

/* Data-theme attribute selectors for consistency */
[data-theme="dark"] .phase-row {
    background-color: rgba(245, 179, 1, 0.12) !important;
    border-left-color: #F5B301 !important;
    border-top-color: rgba(245, 179, 1, 0.4) !important;
    border-bottom-color: rgba(245, 179, 1, 0.4) !important;
    box-shadow: 0 1px 4px rgba(245, 179, 1, 0.15) !important;
    color: #ffffff !important;
}

[data-theme="light"] .phase-row {
    background-color: #cc5200 !important;
    border-left-color: #cc5200 !important;
    border-top-color: #cc5200 !important;
    border-bottom-color: #cc5200 !important;
    box-shadow: 0 1px 3px rgba(204, 82, 0, 0.3) !important;
    color: #ffffff !important;
}

[data-theme="dark"] .cc-row {
    background-color: rgba(52, 73, 94, 0.3) !important;
    border-left-color: #6c757d !important;
}

[data-theme="light"] .cc-row {
    background-color: rgba(248, 249, 250, 0.8) !important;
    border-left-color: #dee2e6 !important;
}

/* Enhanced phase row effects */
.phase-row {
    transition: all 0.2s ease !important;
}

.phase-row:hover {
    background-color: rgba(255, 193, 7, 0.25) !important;
    box-shadow: 0 2px 6px rgba(255, 143, 0, 0.2) !important;
    transform: translateX(1px) !important;
}

/* Ensure proper text contrast */
.phase-row td, .phase-row th, .phase-row span, .phase-row strong {
    font-weight: 600 !important;
    color: #ffffff !important;
}

[data-theme="dark"] .phase-row td, 
[data-theme="dark"] .phase-row th, 
[data-theme="dark"] .phase-row span, 
[data-theme="dark"] .phase-row strong {
    color: #ffffff !important;
}

[data-theme="light"] .phase-row td, 
[data-theme="light"] .phase-row th, 
[data-theme="light"] .phase-row span, 
[data-theme="light"] .phase-row strong {
    color: #ffffff !important;
}

/* BOQ Phase Row Styling - Keep theme-specific overrides */
.phase-row {
    font-weight: 600 !important;
    padding: 0.5rem !important;
}

.phase-row td, .phase-row th {
    font-weight: 600 !important;
}

/* Dark mode phase row styling override */
[data-theme="dark"] .phase-row {
    background-color: #2a2d30 !important;
}

[data-theme="dark"] .phase-row td, 
[data-theme="dark"] .phase-row th {
    background-color: #2a2d30 !important;
    color: #ffffff !important;
}

/* Light mode phase row styling override - keep original background, change text to white */
[data-theme="light"] .phase-row,
[data-theme="light"] .catalog-phase-row {
    color: #ffffff !important;
}

[data-theme="light"] .phase-row td, 
[data-theme="light"] .phase-row th,
[data-theme="light"] .catalog-phase-row td,
[data-theme="light"] .catalog-phase-row th {
    color: #ffffff !important;
}

[data-theme="light"] .phase-row strong,
[data-theme="light"] .catalog-phase-row strong,
[data-theme="light"] .phase-row .phase-code,
[data-theme="light"] .catalog-phase-row .phase-code,
[data-theme="light"] .phase-row .phase-description,
[data-theme="light"] .catalog-phase-row .phase-description {
    color: #ffffff !important;
}

/* CC Row Styling - Keep default/white background */
.cc-row {
    background-color: transparent !important;
}

.cc-row td, .cc-row th {
    background-color: transparent !important;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .btn-group {
        flex-wrap: wrap;
        justify-content: center;
    }

    .btn-group .btn {
        margin-bottom: 5px;
    }

    #catalogTable th, #catalogTable td {
        padding: 5px;
    }
}

/* Added styles for drag and drop */
.draggable-item {
    cursor: move;
    position: relative;
}

.draggable-item:hover {
    background-color: rgba(245, 179, 1, 0.1);
}

.draggable-item:hover::before {
    content: "\F64D"; /* Bootstrap icon code for drag handle */
    font-family: "Bootstrap-icons";
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 12px;
}

.dragging {
    opacity: 0.6;
    background-color: rgba(245, 179, 1, 0.1);
    border: 1px dashed #F5B301;
}

.drop-target {
    background-color: rgba(245, 179, 1, 0.2) !important;
    border: 2px dashed #F5B301 !important;
    transition: all 0.2s ease;
}

.cc-row {
    transition: background-color 0.3s ease, border 0.3s ease;
}

.drag-icon {
    position: absolute;
    top: -1000px;
    background-color: rgba(245, 179, 1, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.copied-item {
    animation: highlight-copied 2s ease;
}

@keyframes highlight-copied {
    0% { background-color: rgba(40, 167, 69, 0.3); }
    100% { background-color: transparent; }
}

.action-button {
    margin-right: 3px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.items-controls-container .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.items-controls-container .btn-group {
    gap: 2px;
}

/* Global toast styles to ensure white text */
.toast-container {
    z-index: 1070 !important;
}

/* Target all elements inside toasts */
.toast,
.toast *,
.toast-header,
.toast-header *,
.toast-body,
.toast-body * {
    color: white !important;
}

/* Apply to specific classes */
.toast-header strong, 
.toast-header i,
.toast-body,
.toast.success,
.toast.error,
.toast.warning,
.toast.info,
.bg-success, 
.bg-danger, 
.bg-warning, 
.bg-primary,
.bg-info {
    color: white !important;
}

/* Target background colors specifically */
.toast.bg-success, 
.toast.bg-danger, 
.toast.bg-warning, 
.toast.bg-primary,
.toast.bg-info,
.toast-header.bg-success,
.toast-header.bg-danger,
.toast-header.bg-warning, 
.toast-header.bg-primary,
.toast-header.bg-info,
.toast-body.bg-success,
.toast-body.bg-danger,
.toast-body.bg-warning,
.toast-body.bg-primary,
.toast-body.bg-info {
    color: white !important;
}

/* Target by container */
.toast-container .toast,
.toast-container .toast-header,
.toast-container .toast-body,
.toast-container .toast strong,
.toast-container .toast span,
.toast-container .toast p,
.toast-container .toast div {
    color: white !important;
}

/* Ensure contrast */
.toast-header {
    background-color: rgba(0, 0, 0, 0.7) !important;
}

/* Dropdown filter styles */
.dropdown-menu {
    max-height: 300px;
    overflow-y: auto;
}

/* Limit form selects to show one row */
.form-select {
    size: 1;
}

.form-select option {
    height: 1.5em;
    line-height: 1.5em;
}

/* Form styles */
.modal-body .form-control {
    background-color: var(--dark-bg);
    border-color: var(--border-color);
    color: var(--text-light);
}

.modal-body .form-select {
    background-color: var(--dark-bg);
    border-color: var(--border-color);
    color: var(--text-light);
}

/* Dark theme overrides */
.modal-content {
    background-color: var(--darker-bg);
    color: var(--text-light);
}

.modal-header {
    border-bottom-color: var(--border-color);
}

.modal-footer {
    border-top-color: var(--border-color);
}

/* Expand/Collapse Controls - Enhanced Orange Styling */
.items-catalog .expand-collapse-btn {
    background: linear-gradient(135deg, #FFA500 0%, #FF8C00 100%);
    border: 2px solid #FF8C00;
    color: #000000;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 165, 0, 0.3);
    min-width: 40px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.items-catalog .expand-collapse-btn:hover {
    background: linear-gradient(135deg, #FF8C00 0%, #FF7F00 100%);
    color: #000000;
    box-shadow: 0 4px 12px rgba(255, 165, 0, 0.4);
    transform: translateY(-1px);
    border-color: #FF7F00;
}

.items-catalog .expand-collapse-btn:focus {
    outline: 3px solid rgba(255, 165, 0, 0.5);
    outline-offset: 2px;
    box-shadow: 0 4px 12px rgba(255, 165, 0, 0.4), 0 0 0 3px rgba(255, 165, 0, 0.3);
}

.items-catalog .expand-collapse-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(255, 165, 0, 0.3);
}

/* Icon rotation for state indication */
.items-catalog .expand-collapse-btn i,
.items-catalog .expand-collapse-btn .icon {
    transition: transform 0.3s ease;
    font-size: 14px;
    color: #000000;
}

.items-catalog .expand-collapse-btn[aria-expanded="true"] i,
.items-catalog .expand-collapse-btn[aria-expanded="true"] .icon {
    transform: rotate(90deg);
}

.items-catalog .expand-collapse-btn[aria-expanded="false"] i,
.items-catalog .expand-collapse-btn[aria-expanded="false"] .icon {
    transform: rotate(0deg);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .catalog-container {
        padding: 10px;
    }

    .catalog-table th,
    .catalog-table td {
        padding: 8px 4px;
        font-size: 13px;
    }

    /* Enhanced mobile expand/collapse buttons */
    .items-catalog .expand-collapse-btn {
        min-width: 36px;
        min-height: 32px;
        padding: 6px 10px;
        font-size: 14px;
    }

    .items-catalog .expand-collapse-btn:focus {
        outline: 2px solid rgba(255, 165, 0, 0.5);
        outline-offset: 1px;
    }
}

/* Dark theme overrides */
[data-bs-theme="dark"] .items-catalog .catalog-table {
    background-color: #2d3748;
    border-color: #4a5568;
}

[data-bs-theme="dark"] .items-catalog .catalog-table th {
    background-color: #4a5568;
    color: #e2e8f0;
    border-color: #718096;
}

[data-bs-theme="dark"] .items-catalog .catalog-table td {
    background-color: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}

/* Dark theme expand/collapse button adjustments */
[data-bs-theme="dark"] .items-catalog .expand-collapse-btn {
    background: linear-gradient(135deg, #FFA500 0%, #FF8C00 100%);
    border-color: #FF8C00;
    color: #000000;
    box-shadow: 0 2px 8px rgba(255, 165, 0, 0.4);
}

[data-bs-theme="dark"] .items-catalog .expand-collapse-btn:hover {
    background: linear-gradient(135deg, #FF8C00 0%, #FF7F00 100%);
    color: #000000;
    box-shadow: 0 4px 12px rgba(255, 165, 0, 0.5);
}

[data-bs-theme="dark"] .items-catalog .expand-collapse-btn:focus {
    outline: 3px solid rgba(255, 165, 0, 0.6);
    box-shadow: 0 4px 12px rgba(255, 165, 0, 0.5), 0 0 0 3px rgba(255, 165, 0, 0.4);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .items-catalog .expand-collapse-btn {
        background: #FFA500;
        border: 3px solid #000000;
        color: #000000;
        font-weight: 900;
    }

    .items-catalog .expand-collapse-btn:hover,
    .items-catalog .expand-collapse-btn:focus {
        background: #FF8C00;
        border-color: #000000;
        outline: 4px solid #000000;
    }
}