/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    table-layout: fixed;
}

th {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #1976d2;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
    font-size: 0.9rem;
    white-space: nowrap;
    position: relative;
    -webkit-user-select: none;
    user-select: none;
    min-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

th:hover {
    background: #f1f5f9;
    cursor: pointer;
}

/* Column sorting indicators */
th.sortable {
    cursor: pointer;
    padding-right: 2rem;
}

th.sortable::after {
    content: '↕';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.8rem;
    opacity: 0.6;
}

th.sortable:hover::after {
    opacity: 1;
    color: #4f46e5;
}

th.sortable.sort-asc::after {
    content: '↑';
    color: #4f46e5;
    opacity: 1;
}

th.sortable.sort-desc::after {
    content: '↓';
    color: #4f46e5;
    opacity: 1;
}

/* Column resizer */
th .column-resizer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: col-resize;
    background: transparent;
    z-index: 11;
}

th .column-resizer:hover {
    background: #4f46e5;
}

th .column-resizer.resizing {
    background: #4f46e5;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
    color: #374151;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0;
}

/* Blue bold styling for quantity and date columns */
td:nth-child(1),
/* Date column */
td:nth-child(7)

/* Qty column */
    {
    color: #1976d2 !important;
    font-weight: bold !important;
}

/* Ensure truncated text shows ellipsis */
td.truncated {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Clickable row styles */
tbody tr.clickable-row {
    cursor: pointer;
}

tbody tr {
    background-color: white;
    transition: background-color 0.15s ease;
}

tbody tr:hover {
    background-color: #f0f9ff;
}

/* Overdue module hover behavior:
   - keep blue hover for non-overdue rows
   - use light red hover for overdue rows */
#overdue-table tbody tr:hover {
    background-color: #f0f9ff;
}

#overdue-table tbody tr.overdue-row:hover {
    background-color: #fef2f2;
}

/* Expanded row styles */
tbody tr.expanded td {
    overflow: visible;
    white-space: normal;
    word-wrap: break-word;
    position: relative;
    z-index: 5;
}

/* Table corner rounding */
tbody tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

tbody tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

/* Status Indicators in Tables */
.status-indicator-cell {
    position: relative;
    padding-left: 2rem !important;
}

.status-indicator-cell::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}

/* Row Status Colors */
.row-perfect-match .status-indicator-cell::before {
    background: #10b981;
}

.row-missing-quickbooks .status-indicator-cell::before {
    background: #ef4444;
}

.row-quantity-mismatch .status-indicator-cell::before {
    background: #f59e0b;
}

.row-extra-quickbooks .status-indicator-cell::before {
    background: #a855f7;
}

/* Clean table styling - no row highlighting */
.row-perfect-match,
.row-quantity-mismatch,
.row-nights-mismatch,
.row-service-mismatch,
.row-missing-quickbooks,
.row-extra-quickbooks {
    background-color: white !important;
    border-left: none !important;
    color: #374151 !important;
}

.row-perfect-match td,
.row-quantity-mismatch td,
.row-nights-mismatch td,
.row-service-mismatch td,
.row-missing-quickbooks td,
.row-extra-quickbooks td {
    color: #374151 !important;
}

/* Override row colors for specific blue columns */
.row-perfect-match td:nth-child(1),
.row-quantity-mismatch td:nth-child(1),
.row-nights-mismatch td:nth-child(1),
.row-service-mismatch td:nth-child(1),
.row-missing-quickbooks td:nth-child(1),
.row-extra-quickbooks td:nth-child(1),
.row-perfect-match td:nth-child(7),
.row-quantity-mismatch td:nth-child(7),
.row-nights-mismatch td:nth-child(7),
.row-service-mismatch td:nth-child(7),
.row-missing-quickbooks td:nth-child(7),
.row-extra-quickbooks td:nth-child(7) {
    color: #1976d2 !important;
    font-weight: bold !important;
}

.row-perfect-match:hover,
.row-quantity-mismatch:hover,
.row-nights-mismatch:hover,
.row-service-mismatch:hover,
.row-missing-quickbooks:hover,
.row-extra-quickbooks:hover {
    background-color: #f0f9ff !important;
    color: #374151 !important;
}

.row-perfect-match:hover td,
.row-quantity-mismatch:hover td,
.row-nights-mismatch:hover td,
.row-service-mismatch:hover td,
.row-missing-quickbooks:hover td,
.row-extra-quickbooks:hover td {
    color: #374151 !important;
}

/* Override hover row colors for specific blue columns */
.row-perfect-match:hover td:nth-child(1),
.row-quantity-mismatch:hover td:nth-child(1),
.row-nights-mismatch:hover td:nth-child(1),
.row-service-mismatch:hover td:nth-child(1),
.row-missing-quickbooks:hover td:nth-child(1),
.row-extra-quickbooks:hover td:nth-child(1),
.row-perfect-match:hover td:nth-child(7),
.row-quantity-mismatch:hover td:nth-child(7),
.row-nights-mismatch:hover td:nth-child(7),
.row-service-mismatch:hover td:nth-child(7),
.row-missing-quickbooks:hover td:nth-child(7),
.row-extra-quickbooks:hover td:nth-child(7) {
    color: #1976d2 !important;
    font-weight: bold !important;
}

/* Booking Group Styles */
.booking-group-header {
    background-color: #e3f2fd !important;
    border-top: 2px solid #4f46e5;
    border-bottom: 1px solid #bbdefb;
}

.booking-group-header:hover {
    background-color: #d1e7ff !important;
    color: #0d47a1 !important;
}

.booking-group-header:hover .group-header-cell {
    color: #0d47a1 !important;
}

.group-header-cell {
    padding: 0.75rem 0.5rem !important;
    font-weight: normal;
    color: #1565c0;
    background-color: transparent;
    border-left: 4px solid #4f46e5;
}

.booking-group-item {
    border-left: 2px solid #dee2e6;
}

.booking-group-item.group-first {
    border-top: 1px solid #dee2e6;
}

.booking-group-item.group-last {
    border-bottom: 2px solid #dee2e6;
}

.booking-group-spacer {
    height: 8px;
    background-color: transparent;
}

.group-spacer-cell {
    padding: 0 !important;
    border: none !important;
    background-color: transparent;
}

/* Ensure group headers don't get row highlighting */
.booking-group-header.row-perfect-match,
.booking-group-header.row-quantity-mismatch,
.booking-group-header.row-nights-mismatch,
.booking-group-header.row-service-mismatch,
.booking-group-header.row-missing-quickbooks,
.booking-group-header.row-extra-quickbooks {
    background-color: #e3f2fd !important;
    border-left: 4px solid #4f46e5 !important;
}

/* Table Container */
.table-container {
    flex: 1;
    overflow: auto;
    border-radius: 0 0 8px 8px;
}

/* Record Count */
.record-count {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    width: 100px;
    text-align: center;
    white-space: nowrap;
    display: inline-block;
}