/* Table styling */
.table {
    border-collapse: collapse !important; /* Change to collapse instead of separate */
    border-spacing: 0;
}

.table th {
    font-weight: 600;
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

#ordersTable td {
    border: none;
    border-top: 1px solid #dee2e6;
    vertical-align: middle;
}

/* Row border styling - refined to fix the line issues */
.order-main-row td,
.order-bottom-row td {
    padding-top: 10px;
    padding-bottom: 10px;
}

.order-main-row:not(.has-bottom-row) td {
    border-bottom: 1px solid #dee2e6;
}

/* When main row has a bottom row, adjust borders */
.order-main-row.has-bottom-row td {
    border-bottom: none !important;
}

/* Ensure cells with rowspan properly span two rows */
.order-main-row td[rowspan="2"] {
    border-bottom: 1px solid #dee2e6 !important;
}

/* Remove top border from bottom row */
.order-bottom-row td {
    border-top: none !important;
    border-bottom: 1px solid #dee2e6;
}
/* Ensure last row has bottom border */
#ordersTable tbody tr:last-child td {
    border-bottom: 1px solid #dee2e6;
}

/* Status indicators */
.status-sent {
    background-color: rgba(134, 239, 172, 0.15);
}

/* Consistent status heights and spacing */
.status-column {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Input backgrounds */
input.bg-yellow-200 { 
    background-color: #fef08a !important; 
}

input.bg-red-200 { 
    background-color: #fecaca !important; 
}

/* Color indicators for dates */
.bg-yellow-200 { 
    background-color: #fef08a !important; 
}

.bg-red-200 { 
    background-color: #fecaca !important; 
}

/* Badge styling */
.badge.bg-primary, 
.badge.bg-secondary {
    width: 60px; /* Fixed exact width instead of min-width */
    flex-shrink: 0;
    text-align: center;
    padding: 0.35em 0.65em;
    font-weight: 600;
    margin-right: 8px;
    margin-top: 2px;
}

/* Status layout */
.status-display {
    display: flex;
    align-items: flex-start; /* Changed from center to align at top */
    width: 100%;
    justify-content: space-between;
}

.status-left-group {
    display: flex;
    align-items: center;
    max-width: 65%; /* Increased width for left group */
}

/* Work type display with wrapping */
.work-type-display {
    flex-grow: 0;
    flex-shrink: 1;
    width: auto;
    max-width: calc(100% - 88px);
    white-space: normal; /* Allow text to wrap */
    overflow: visible; /* Don't clip the content */
    text-overflow: clip; /* Don't add ellipsis */
    margin-right: 8px;
    font-size: 0.85rem; /* Slightly smaller font */
    line-height: 1.2; /* Tighter line height */
    word-break: break-word; /* Break long words if needed */
}

/* Stage select container */
.stage-select-container {
    flex-grow: 0;
    flex-shrink: 0;
    width: 160px; /* Slightly reduced to balance the layout */
}

.stage-select {
    width: 100%;
}

/* Ensure date input is consistently sized */
input[type="date"].form-control-sm {
    width: 125px;
}

/* Input styling */
.form-control.bg-yellow-200,
.form-control.bg-red-200 {
    border-color: rgba(0, 0, 0, 0.1);
}

/* Form controls */
.form-select-sm {
    min-width: 130px;
}

.completion-date {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* Table column widths */
#ordersTable th:nth-child(1), /* Order # */
#ordersTable td:nth-child(1) {
    width: 7%;
}

#ordersTable th:nth-child(2), /* Doctor */
#ordersTable td:nth-child(2) {
    width: 9%;
}

#ordersTable th:nth-child(3), /* Patient */
#ordersTable td:nth-child(3) {
    width: 9%;
}

#ordersTable th:nth-child(4), /* Received */
#ordersTable td:nth-child(4) {
    width: 7%;
}

#ordersTable th:nth-child(5), /* Work Name */
#ordersTable td:nth-child(5) {
    width: 10%;
}

#ordersTable th:nth-child(6), /* Status */
#ordersTable td:nth-child(6) {
    width: 25%; /* Increased from 20% to give more space */
}

#ordersTable th:nth-child(7), /* Est. Next Stage */
#ordersTable td:nth-child(7) {
    width: 9%;
}

#ordersTable th:nth-child(8), /* Paid */
#ordersTable td:nth-child(8) {
    width: 4%;
    text-align: center;
}

#ordersTable th:nth-child(9), /* Price */
#ordersTable td:nth-child(9) {
    width: 6%;
    text-align: right;
}

#ordersTable th:nth-child(10), /* Notes */
#ordersTable td:nth-child(10) {
    width: 8%;
}

/* Ensure all cells have consistent height */
.order-main-row td,
.order-bottom-row td {
    height: auto; /* Override fixed height */
    min-height: 56px;
    padding-top: 10px;
    padding-bottom: 10px;
}

/* Mobile styling */
@media (max-width: 768px) {
    .order-card {
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        margin-bottom: 1rem;
    }
    
    .card-body.p-2 .row {
        margin-top: 10px;
    }
    
    .form-control-sm, .form-select-sm {
        height: 38px;
    }
    
    select.form-select-sm, input.form-control-sm {
        font-size: 0.875rem;
        padding: 0.25rem 0.5rem;
        border-radius: 0.25rem;
    }
    
    .text-muted {
        display: block;
        margin-bottom: 4px;
    }
    
    .order-card .card-header {
        background-color: #f8f9fa;
        padding: 0.75rem;
    }
    
    .order-card .card-body {
        padding: 1rem;
    }
    
    .order-card small.text-muted {
        font-size: 0.75rem;
        display: block;
        margin-bottom: 0.25rem;
    }
    
    .order-card .form-control-sm,
    .order-card .form-select-sm {
        height: calc(1.5em + 0.5rem + 2px);
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
    
    .card.status-sent {
        border-left: 3px solid #86efac !important;
    }
    
    .mobile-orders .badge {
        font-size: 0.75rem;
    }
    
    .mobile-orders .card {
        margin-bottom: 1rem;
    }
    
    .mobile-orders .card-inner {
        background-color: #f8f9fa;
        border-radius: 0.25rem;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .mobile-card-status {
        display: flex;
        align-items: flex-start; /* Changed from center for text wrapping */
        justify-content: space-between;
    }
    
    .mobile-left-group {
        display: flex;
        align-items: center;
        max-width: 70%;
    }
    
    .mobile-badge {
        margin-bottom: 4px;
    }
    
    .mobile-work-type {
        font-weight: normal;
        white-space: normal;
        word-wrap: break-word;
        display: block;
        width: 100%;
    }
    
    .mobile-orders input.bg-yellow-200,
    .mobile-orders input.bg-red-200 {
        width: 100%;
    }
    
    .mobile-stage-container {
        width: 50%;
    }
    
    .mobile-stage-select {
        width: 100%;
    }
}