/* ===================================================================
 * styles-boq-main.css
 * Purpose: Main BOQ table layout, item rows, hover, comparison
 * Extracted from styles.css during the Apr 2026 split (task #23).
 * =================================================================== */
/* BOQ Styles */
.table-container {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* Phase row styling */
#boq-table tr[data-level="phase"],
.table tr.phase-row {
    background-color: #2a2a2a !important;
    font-size: 1.4em !important;
    font-weight: 700 !important;
    border-top: 3px solid var(--primary-color) !important;
    border-bottom: 1px solid var(--primary-color) !important;
    color: #ff8c00 !important;
    text-transform: uppercase;
}

#boq-table tr[data-level="phase"] td,
.table tr.phase-row td {
    color: #ff8c00 !important;
}

/* Phase row text colors */
#boq-table tr[data-level="phase"] td,
#boq-table tr[data-level="phase"] td *,
.table tr.phase-row td,
.table tr.phase-row td * {
    color: #ff8c00 !important;
}

/* Cost center row text colors */
#boq-table tr[data-level="cc"] td,
#boq-table tr[data-level="cc"] td *,
.table tr[data-type="cc"] td,
.table tr[data-type="cc"] td * {
    color: #ff8c00 !important;
}

/* Ensure phase and cc row editable spans maintain color */
#boq-table tr[data-level="phase"] td span.editable,
#boq-table tr[data-level="cc"] td span.editable,
.table tr.phase-row td span.editable,
.table tr[data-type="cc"] td span.editable {
    color: #ff8c00 !important;
}

/* Total columns color */
#boq-table tr[data-level="phase"] td.phase-total,
#boq-table tr[data-level="cc"] td.cc-total,
.table tr.phase-row td.text-end,
.table tr[data-type="cc"] td.text-end {
    color: #ff8c00 !important;
}

#boq-table thead th,
.table thead th {
    color: #ff6600 !important;
    font-weight: 600;
}

/* Cost center row styling */
#boq-table tr[data-level="cc"],
.table tr[data-type="cc"] {
    background-color: #222222 !important;
    font-size: 1.2em !important;
    font-weight: 600 !important;
    border-left: 4px solid #ff8c00 !important;
    color: #ff8c00 !important;
    padding-left: 15px !important;
}

#boq-table tr[data-level="cc"] td,
.table tr[data-type="cc"] td {
    color: #ff8c00 !important;
}

/* Item row styling */
#boq-table tr[data-level="item"],
.table tr[data-type="item"] {
    background-color: #1a1a1a !important;
    padding-left: 30px !important;
    border-left: 2px solid #444 !important;
    color: #d0d0d0 !important;
    font-size: 1em !important;
    font-weight: normal !important;
}

/* Hover effects */
tr[data-level]:hover {
    background-color: rgba(245, 179, 1, 0.1);
}

[contenteditable="true"] {
    border: 1px solid var(--primary-color);
    padding: 2px 4px;
    min-width: 50px;
    outline: none;
    background: rgba(255, 255, 255, 0.05);
    cursor: text;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

[contenteditable="true"]:focus {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 2px rgba(245, 179, 1, 0.3);
}

.editable {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    min-width: 30px;
    display: inline-block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.editable:hover {
    background: rgba(255, 255, 255, 0.05);
}

.editable[contenteditable="true"] {
    background: rgba(255, 255, 255, 0.1);
    outline: 1px solid var(--primary-color);
    padding: 2px 4px;
}

/* Fix for item catalog table display */
#catalogTable td {
    white-space: normal !important;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    min-width: 50px;
    padding: 8px !important;
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#catalogTable td:nth-child(3) {  /* Item Code column */
    min-width: 180px;
    max-width: 180px;
    white-space: nowrap;
}

#catalogTable td:nth-child(4) {  /* Description column */
    min-width: 200px;
    word-break: break-word;
}

.item-code {
    font-family: monospace;
    white-space: nowrap !important;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    margin-right: 5px;
}

/* Ensure items appear in their correct columns */
#catalogTable tr[data-type="item"] td {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Force column alignment */
#catalogTable th,
#catalogTable td {
    box-sizing: border-box;
    position: relative;
}

/* Fixed column widths */
#catalogTable th:nth-child(1),
#catalogTable td:nth-child(1) {
    width: 40px;
    max-width: 40px;
}

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

/* Hide preview icon cell for item rows */
#catalogTable tr[data-type="item"] td:nth-child(2) {
    padding: 0 !important;
    width: 0 !important;
    max-width: 0 !important;
    overflow: hidden;
    border: none !important;
}

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

#catalogTable th:nth-child(6),
#catalogTable td:nth-child(6) {
    width: 120px;
    max-width: 120px;
    text-align: right;
}

/* Actions column removed */

/* Hide the actions header and column completely */
#catalogTable th:last-child,
#catalogTable td:last-child {
    width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    border: none !important;
    display: none !important;
}

/* Hide all action buttons in items */
#catalogTable tr[data-type="item"] .action-buttons,
#catalogTable tr[data-type="item"] .btn-edit,
#catalogTable tr[data-type="item"] .btn-delete {
    display: none !important;
}

/* BOQ action buttons fixed at top */
.boq-action-buttons {
    position: sticky;
    top: 0;
    background-color: var(--dark-bg);
    z-index: 1050;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Project title in header */
.boq-action-buttons h3 {
    margin: 0;
    color: var(--primary-color);
    font-weight: 600;
}

/* Buttons in the fixed header */
.boq-action-buttons .btn-group {
    display: inline-flex;
}

/* Add some spacing between button groups */
.boq-action-buttons .btn-group:not(:last-child) {
    margin-right: 10px;
}

/* Priority colors */
.bg-priority-High {
    background-color: #FF8A80!important;
}

.bg-priority-Medium {
    background-color: #FFD54F!important;
}

.bg-priority-Low {
    background-color: #64B5F6!important;
}

.bg-priority-Finished {
    background-color: #81C784!important;
    color: #fff!important;
}

/* Tree connector styles for expand/collapse buttons */
.tree-button-group {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin-right: 10px;
}

.tree-connector {
    position: absolute;
    width: 2px;
    height: 100%;
    background-color: var(--color-accent-600); /* Orange color matching your theme */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -36%);
    z-index: 1;
}

.tree-connector:before {
    content: "";
    position: absolute;
    width: 8px;
    height: 2px;
    background-color: var(--color-accent-600);
    bottom: 0;
left: 0;
    transform: translateX(-3px);
}

.plus-connector {
    height: calc(100% - 10px);
}

.minus-connector {
    height: calc(100% - 10px);
}

.tree-button-group .btn {
    position: relative;
    z-index: 2;
    margin-bottom: 14px;
}

.tree-button-group .btn:last-child {
    margin-bottom: 0;
}

/* Ensure description cells properly wrap long text */
#boqTable td:nth-child(5) {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
    min-height: 1.2em;
}

/* Fix number field overflow */
#boqTable input[type="number"] {
    color: var(--text-light) !important;
}

[data-theme="light"] #boqTable input[type="number"] {
    color: #000000 !important;
}

#boqTable .unit-price {
    color: var(--text-light) !important;
}

[data-theme="light"] #boqTable .unit-price {
    color: #000000 !important;
}

#boqTable .unit-price-header,
#boqTable .takeoff {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    text-overflow: ellipsis;
    white-space: normal;
}

#boqTable td {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Apply word wrap to all table cells */
#boqTable td, #boqTable th {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* BOQ Comparison Styles */
.comparison-table {
    border-collapse: collapse;
    width: 100%;
}

.comparison-table th,
.comparison-table td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
}

.comparison-table th {
    background-color: var(--header-bg);
    font-weight: bold;
}

.phase-header {
    background-color: var(--phase-bg);
    font-weight: bold;
    text-transform: uppercase;
}

.cc-header {
    background-color: var(--cc-bg);
    font-weight: bold;
    padding-left: 20px;
}

.item-row {
    background-color: var(--item-bg);
}

.item-description {
    font-weight: 500;
    padding-left: 40px;
}

/* Item number styling */
    .item-number {
        display: block;
        font-weight: 500;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        max-width: 100%;
        font-family: monospace;
        font-size: 0.85rem;
        line-height: 1.2;
        padding: 2px 0;
        white-space: normal !important;
        color: var(--text-light) !important;
    }

    /* Ensure item numbers are visible in dark mode */
    [data-theme="dark"] .item-number {
        color: #ffffff !important;
    }

    [data-theme="light"] .item-number {
        color: #333333 !important;
    }

.item-data {
    text-align: center;
    vertical-align: top;
}

.item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.takeoff {
    font-weight: bold;
}

.unit-price {
    color: var(--text-light) !important;
    font-size: 0.9em;
}

[data-theme="light"] .unit-price {
    color: #000000 !important;
}

.total {
    color: var(--success-color);
    font-weight: bold;
}

.notes {
    font-size: 0.8em;
    color: var(--text-muted);
    font-style: italic;
}

