/* Subcontract Portal Styling */
.add-lines-section {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
}

.add-lines-section h6 {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.js-add-line-form label {
    font-weight: 500;
    font-size: 0.9rem;
}

.form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.form-check-label {
    cursor: pointer;
}

.form-check-input:checked + .form-check-label {
    font-weight: 600;
}

/* SR column indentation styles */
.indent-level-0 {
    padding-left: 5px !important;
}
.indent-level-1 {
    padding-left: 20px !important;
}
.indent-level-2 {
    padding-left: 35px !important;
}
.indent-level-3 {
    padding-left: 50px !important;
}
.indent-level-4 {
    padding-left: 65px !important;
}
.indent-level-5 {
    padding-left: 80px !important;
}

/* Bold SR column values */
td .serial {
    font-weight: 600;
}

/* SR input styling - compact for fixed column */
input[name^="line_ids"][name$="[serial]"] {
    width: 45px !important;
    max-width: 45px !important;
    padding: 0.15rem 0.25rem !important;
    font-weight: 600;
    font-size: 0.75rem !important;
    border-radius: 2px;
    border-color: #ced4da;
    text-align: center;
}

input[name^="line_ids"][name$="[serial]"]:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: 0;
}

/* Delete button styling */
.js-delete-line {
    padding: 0.15rem 0.5rem !important;
    transition: all 0.2s ease;
}

.js-delete-line:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

/* UOM Selector Styling */
.uom-selector-container {
    position: relative;
}

.uom-dropdown {
    width: 300px;
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
}

.uom-dropdown.show {
    display: block;
}

.uom-dropdown .dropdown-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.uom-dropdown .dropdown-item:hover,
.uom-dropdown .dropdown-item:focus {
    background-color: #f8f9fa;
}

.uom-dropdown .dropdown-item.active {
    color: #fff;
    background-color: #0d6efd;
}

.uom-dropdown .dropdown-header {
    font-weight: bold;
    background-color: #f0f0f0;
    margin-top: 0;
    padding: 0.5rem 1rem;
}

.uom-dropdown .uom-search {
    margin: 0.5rem 0;
}

/* UOM Modal Styles */
#uom-categories .card {
    border: 1px solid #dee2e6;
    margin-bottom: 1rem;
}

#uom-categories .card-header {
    background-color: #f8f9fa;
    padding: 0.75rem 1rem;
}

#uom-categories .card-header h6 {
    margin: 0;
    font-weight: 600;
    color: #495057;
}

.uom-item {
    padding: 0.5rem 1rem;
    margin-bottom: 0.5rem;
    text-align: left;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
}

.uom-item:hover {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.uom-item.selected,
.uom-item:active {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

/* Search box styling */
#uom-search {
    border-radius: 0.25rem;
    border: 1px solid #ced4da;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
}

/* Modal sizing */
#modalUomSelect .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

.line-note {
    line-height: 0;
    margin-bottom: 0;
    font-style: normal;
}

/* Attachment Drag and Drop Styling */
.attachment-dropzone {
    border: 2px dashed #ccc;
    border-radius: 5px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s ease;
    background-color: #f8f9fa;
    margin-bottom: 20px;
}

.attachment-dropzone.drag-active {
    border-color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.05);
}

.attachment-dropzone .dropzone-message {
    font-size: 1.1rem;
    color: #6c757d;
    margin-bottom: 0;
}

.attachment-dropzone i.fa-upload {
    font-size: 2rem;
    color: #6c757d;
    margin-bottom: 10px;
}

.attachment-card {
    transition: all 0.2s ease;
}

.attachment-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.attachment-icon {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-name {
    height: 40px;
}

/* Delete attachment button styling */
.js-delete-attachment {
    transition: all 0.2s ease;
}

.js-delete-attachment:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

/* Work Items Table Optimization */
.work-items-table {
    table-layout: auto; /* Auto layout as requested */
    width: 100%;
    font-size: 0.85rem; /* Smaller font */
    border-collapse: collapse;
    border-spacing: 0;
}

.work-items-table th,
.work-items-table td {
    padding: 0.2rem 0.25rem !important; /* Very tight padding */
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    min-height: 28px !important; /* Prevent stacking */
    height: auto !important;
    display: table-cell !important; /* Force table cell display */
}

/* Ensure proper column sizing when some columns are hidden */
.work-items-table colgroup {
    display: table-column-group;
}

/* Dynamic column sizing with auto layout */
.work-items-table {
    table-layout: auto !important;
}

/* Column-specific optimizations using classes - VERY TIGHT */
.work-items-table .col-sr {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
}

.work-items-table .col-work-category,
.work-items-table .col-work-detail {
    width: 100px !important;
}

.work-items-table .col-description {
    width: 35% !important; /* Maximum space for description */
    min-width: 300px !important;
}

/* Description cell special handling */
.work-items-table .col-description ~ td,
.work-items-table td:nth-child(2) {
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

.work-items-table .col-description textarea,
.work-items-table td:nth-child(2) textarea {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow: hidden !important;
    resize: none !important;
    line-height: 1.2 !important;
}

.work-items-table .col-allocation {
    width: 120px !important;
}

.work-items-table .col-cost-code {
    width: 110px !important;
}

.work-items-table .col-qty {
    width: 55px !important;
    min-width: 55px !important;
}

.work-items-table .col-uom {
    width: 45px !important;
}

.work-items-table .col-unit-price {
    width: 85px !important; /* Slightly wider for currency display */
    min-width: 85px !important;
    position: relative !important;
    display: table-cell !important;
}

/* Taxes column removed - no longer needed */

.work-items-table .col-budget-qty,
.work-items-table .col-budget-amt {
    width: 70px !important;
    min-width: 70px !important;
}

.work-items-table .col-separator {
    width: 10px !important;
    min-width: 10px !important;
    max-width: 10px !important;
    padding: 0 !important;
    background: transparent !important;
}

.work-items-table .col-subtotal {
    width: 90px !important; /* Wider to ensure visibility */
    min-width: 90px !important;
    position: relative !important;
    display: table-cell !important;
}

.work-items-table .col-actions {
    width: 65px !important;
}

/* Apply same sizing to td elements based on their position */
.work-items-table tbody td {
    width: inherit;
    min-width: inherit;
    max-width: inherit;
}

/* Totals Section Styling */
.totals-section table {
    width: auto;
    margin-left: auto;
}

.totals-section td {
    padding: 0.25rem 0.75rem !important;
}

.totals-section .border-top {
    border-top: 2px solid #dee2e6 !important;
}

/* Note Editor Styling */
.note-content-container .note-content,
.note-content {
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    min-height: 50px;
}

.note-content:empty:before {
    content: "No note";
    color: #6c757d;
    font-style: italic;
}

/* Compact buttons in Note cell */
.note-editor-container .btn {
    padding: 0.15rem 0.3rem;
    font-size: 0.7rem;
    line-height: 1;
}

.note-editor-container .btn i {
    font-size: 0.7rem;
}

.note-display-buttons,
.note-editor-buttons {
    margin-top: 0.25rem;
}

/* Input fields in table - ULTRA compact */
.work-items-table input.form-control,
.work-items-table select.form-control {
    padding: 0.15rem 0.2rem !important;
    font-size: 0.8rem !important;
    height: 26px !important;
}

.work-items-table textarea.form-control {
    padding: 0.2rem 0.25rem !important;
    font-size: 0.8rem !important;
    min-height: 32px !important;
    line-height: 1.2 !important;
    resize: vertical;
}

/* Monetary values - remove currency symbol spacing */
.work-items-table .oe_currency_value {
    font-size: 0.8rem !important;
}

.work-items-table td.text-end {
    padding-right: 0.2rem !important;
    font-size: 0.8rem !important;
}

/* Monetary columns - FORCE visibility */
.work-items-table td.text-end,
.work-items-table td.text-end span,
.work-items-table td.text-end .oe_currency_value {
    font-size: 0.8rem !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: inherit !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Ensure monetary widgets render properly */
.work-items-table td.text-end span[data-oe-type="monetary"] {
    display: inline-block !important;
    white-space: nowrap !important;
}

/* Fix for location_display_name whitespace */
.work-items-table span[data-oe-field="location_display_name"] {
    display: inline-block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    padding-right: 0 !important;
    margin-right: 0 !important;
}

/* Select2 in table - FORCE compact width */
.work-items-table .select2-container,
.work-items-table .select2-container-multi {
    font-size: 0.75rem !important;
    width: 70px !important;
    max-width: 70px !important;
    min-width: 70px !important;
}

.work-items-table td .select2-container {
    width: 70px !important;
    max-width: 70px !important;
}

.work-items-table .select2-choices {
    min-height: 26px !important;
    max-height: 26px !important;
    padding: 1px !important;
    width: 70px !important;
    max-width: 70px !important;
    overflow: hidden !important;
}

/* Hide overflow text in Select2 */
.work-items-table .select2-search-choice div {
    max-width: 50px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 0.7rem !important;
}

.work-items-table .select2-search-choice {
    padding: 2px 5px !important;
    margin: 2px !important;
    font-size: 0.85rem !important;
}

/* Task and Cost Code cells with buttons */
.work-items-table .task-selection,
.work-items-table td:has(.js-edit-cost-code-subcontract) {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.work-items-table .task-selection span,
.work-items-table .cost-code-display {
    font-size: 0.85rem !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* Action buttons column */
.work-items-table .action-col,
.work-items-table td:last-child {
    width: 80px;
    text-align: center;
}

/* Compact buttons in table */
.work-items-table .btn-sm,
.work-items-table .js-edit-task-subcontract,
.work-items-table .js-edit-cost-code-subcontract {
    padding: 0.15rem 0.3rem !important;
    font-size: 0.75rem !important;
    line-height: 1 !important;
}

.work-items-table .btn-sm i,
.work-items-table button i {
    font-size: 0.7rem !important;
}

/* Compact table header */
.work-items-table thead th {
    font-size: 0.875rem;
    font-weight: 600;
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

/* Make better use of space on smaller screens */
@media (max-width: 1400px) {
    .work-items-table {
        font-size: 0.875rem;
    }

    .work-items-table th,
    .work-items-table td {
        padding: 0.3rem 0.4rem !important;
    }
}

/* Hover effect for better readability */
.work-items-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Selectable row styling when in select mode */
.work-items-table tr.selectable-row {
    cursor: pointer;
}

.work-items-table tr.table-active {
    background-color: rgba(13, 110, 253, 0.1) !important;
}

/* Table wrapper for horizontal scroll on smaller screens */
.table-responsive-work-items {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ULTRA aggressive space optimization for compact mode */
.work-items-table.compact-mode th,
.work-items-table.compact-mode td {
    padding: 0.15rem 0.2rem !important;
    font-size: 0.78rem !important;
    height: auto !important;
    line-height: 1.1 !important;
}

/* Adjusted columns in compact mode for visibility */
.work-items-table.compact-mode .col-subtotal {
    width: 85px !important;
    min-width: 85px !important;
}

.work-items-table.compact-mode .col-unit-price {
    width: 80px !important;
    min-width: 80px !important;
}

.work-items-table.compact-mode .col-budget-qty,
.work-items-table.compact-mode .col-budget-amt {
    width: 65px !important;
    min-width: 65px !important;
}

.work-items-table.compact-mode .col-qty {
    width: 45px !important;
}

.work-items-table.compact-mode .col-uom {
    width: 40px !important;
}

/* Taxes column removed from compact mode */

/* Description gets ALL remaining space */
.work-items-table.compact-mode .col-description {
    width: auto !important;
    min-width: 35% !important;
}

/* Remove unnecessary borders for cleaner look */
.work-items-table td {
    border-left: none !important;
    border-right: none !important;
}

/* Only keep horizontal borders */
.work-items-table {
    border-left: none !important;
    border-right: none !important;
}

/* Abbreviate long headers on smaller screens */
@media (max-width: 1200px) {
    .work-items-table thead th {
        font-size: 0.8rem !important;
    }

    /* Use abbreviations for headers */
    .work-items-table th:contains("Work Category")::after {
        content: "Category";
    }
    .work-items-table th:contains("Work Category") {
        font-size: 0 !important;
    }
    .work-items-table th:contains("Work Category")::after {
        font-size: 0.8rem !important;
    }
}
