/* Inbounds page styles - extracted from inbounds.html */

/* Match compact table styling from seasons.html */
#inboundsTable tbody tr {
    height: 20px;
}

/* File upload area styles */
.excel-upload-area:hover {
    border-color: #0d6efd !important;
    background-color: #f8f9fa;
}

.excel-upload-area.dragover {
    border-color: #0d6efd !important;
    background-color: #e7f3ff;
}

.excel-upload-area.file-selected {
    border-color: #198754 !important;
    background-color: #f0f9f4;
}

#inboundsTable tbody td {
    padding: 0.1rem 0.25rem;
    vertical-align: middle;
}

#inboundsTable thead th {
    padding: 0.1rem 0.25rem;
}

/* Make action buttons smaller */
#inboundsTable .btn-group-sm .btn {
    padding: 0.05rem 0.15rem;
    font-size: 0.65rem;
}

/* Make table font smaller */
#inboundsTable {
    font-size: 0.75rem;
}

/* Make table header font even smaller */
#inboundsTable thead th {
    font-size: 0.7rem;
    font-weight: 600;
}

/* Prevent text wrapping in table cells */
#inboundsTable tbody td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Fixed table layout to prevent column resizing */
#inboundsTable {
    table-layout: fixed;
}

/* Allow text wrapping in header */
#inboundsTable thead th {
    white-space: normal;
}

/* Validation styles */
.is-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

/* Rows being edited - slightly yellow background (target td to override Bootstrap table-striped) */
#inboundsTable .row-being-edited,
#inboundsTable .row-being-edited td {
    background-color: #fff3cd !important;
}

/* Expandable rows styles */
.expandable-row {
    background-color: #f8f9fa;
}

/* Zebra striping: apply only to main rows.
   We can't rely on :nth-of-type because expandable <tr> (even when hidden) still affects the count.
   Instead, JS marks main rows with .main-row-odd/.main-row-even, and we style those. */
#inboundsTable.table-striped > tbody > tr > * {
    /* Bootstrap striping uses box-shadow + --bs-table-accent-bg. Neutralize it for this table. */
    --bs-table-accent-bg: transparent;
    box-shadow: none !important;
}

#inboundsTable > tbody > tr.main-row.main-row-odd > * {
    box-shadow: inset 0 0 0 9999px var(--bs-table-striped-bg) !important;
}

.timber-items-container {
    border-left: 2px solid var(--primary-color);
    margin-left: 1px;
    padding: 0.2rem !important;
}

/* Expand cell click area */
.expand-cell {
    width: 20px;
    padding: 0;
    text-align: center;
    cursor: pointer;
    vertical-align: middle;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.expand-cell * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.expand-cell .expand-icon {
    font-size: 0.65rem;
}

.expand-cell:hover .expand-icon {
    transform: scale(1.05);
}

.expand-icon {
    transition: transform 0.2s ease;
}

/* Timber items table styling */
.timber-items-container .table {
    margin-bottom: 0;
    font-size: 0.7rem;
}

.timber-items-container .table th {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
    font-weight: 600;
}

.timber-items-container .table td {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
    vertical-align: middle;
}

.timber-items-container .table-responsive {
    margin-bottom: 0;
}

/* Remove top border from dark table headers inside expanded blocks */
.timber-items-container thead.table-dark,
.timber-items-container thead.table-dark th {
    border-top: 0 !important;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.timber-items-container thead.table-dark th {
    cursor: pointer;
}

/* Add bottom space only when table has data, so FAB doesn't overlap */
.table-responsive:has(#inboundsTableBody > tr:not(.loading):not(.empty))::after {
    content: '';
    display: block;
    height: 80px;
}

/* Editable field styles */
.editable-field {
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.2s ease;
    display: inline-block;
    width: 100%;
    outline: none;
}

.editable-field:focus {
    background-color: #e7f3ff;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}

.editable-field:hover {
    background-color: #f8f9fa;
}

.editable-field.editing {
    background-color: #e7f3ff;
}

.inline-edit-input {
    width: calc(100% - 40px); /* leave space for buttons */
    min-width: 60px;
    max-width: 120px;
    padding: 2px 4px;
    border: 1px solid #0d6efd;
    border-radius: 3px;
    font-size: 0.75rem;
    background-color: white;
    box-sizing: border-box;
}

.inline-edit-buttons {
    display: inline-flex;
    align-items: center; /* vertical align middle */
    gap: 2px;
    margin-left: 2px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Ensure table cells maintain consistent width during editing */
#inboundsTable tbody td[data-field="invoiceNumber"] {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
}

#inboundsTable tbody td[data-field="invoiceNumber"] .editable-field {
    display: inline-block;
    width: 100%;
}

.inline-edit-btn {
    width: 16px; /* square */
    height: 16px; /* square */
    padding: 0; /* square */
    font-size: 0.6rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    cursor: pointer;
}

.inline-edit-btn.save { /* colors come from btn-primary */
}

.inline-edit-btn.cancel { /* colors come from btn-secondary */
}

.inline-edit-btn:hover {
    opacity: 0.8;
}

.loading-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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