.data-table-container {
    position: relative; /* Needed for overlay */
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.table-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1030; /* Above sticky header */
}

/* Table Layout & Structure */
.modern-table {
    table-layout: auto;
    font-size: 0.7rem !important; /* Set base font size for the entire table */
    margin-bottom: 0; /* Remove default margin */
}

.modern-table th {
    white-space: nowrap;
    padding: 0.4rem 0.5rem; /* Adjust header padding */
    vertical-align: middle;
    text-align: left;
    font-weight: 600;
    font-size: 0.65rem !important; /* Smaller font for headers */
}

.modern-table td {
    padding: 0.2rem 0.5rem; /* Adjust cell padding */
    vertical-align: middle;
    position: relative; /* For indicators */
    font-size: 0.7rem !important;
}

.modern-table tbody td {
    border-bottom: 1px solid var(--border-subtle, #d6dae0);
}

.modern-table th.numeric-heading,
.modern-table td.numeric-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.modern-table th.text-heading,
.modern-table td.text-cell {
    text-align: left;
}

/* Narrow columns for boolean fields */
.modern-table th[data-column="Blacklisted"],
.modern-table td[data-column="Blacklisted"],
.modern-table th[data-column="InLichidare"],
.modern-table td[data-column="InLichidare"],
.modern-table th[data-column="abc_class"],
.modern-table td[data-column="abc_class"] {
    max-width: 50px !important;
    width: 50px !important;
    padding-left: 0.2rem !important;
    padding-right: 0.2rem !important;
    text-align: center !important;
}

/* Fix for truncated text in spans */
.modern-table td span {
    font-size: 0.7rem !important;
    line-height: inherit;
    vertical-align: middle;
}

.modern-table td.text-truncate span {
    font-size: 0.7rem !important;
    max-width: 200px;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sticky Header */
thead.sticky-top {
  position: sticky;
  top: 0;
  z-index: 1020;
  background-color: #f8f9fa !important; /* Ensure background */
  box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
}

/* Vertical Dividers */
.vertical-divider {
    border-left: 1px solid #d3d9df !important;
}

th.vertical-divider {
    border-left: 1px solid #c1c9d1 !important;
}

/* Group Background Colors - High Specificity */
.modern-table td.group-source,
.modern-table th.group-source { 
    background-color: rgba(230, 240, 255, 0.4) !important;
}

.modern-table td.group-destination,
.modern-table th.group-destination { 
    background-color: rgba(230, 255, 235, 0.4) !important;
}

.modern-table td.group-necessity,
.modern-table th.group-necessity { 
    background-color: rgba(255, 245, 230, 0.4) !important;
}

.modern-table td.group-action,
.modern-table th.group-action { 
    background-color: rgba(245, 235, 255, 0.4) !important;
}

/* Alternating Row Colors */
.even-row { background-color: transparent; }

/* Hover effect */
tbody tr:hover {
    background-color: rgba(220, 235, 255, 0.5) !important; /* Light blue hover */
}

/* Compact Input Styling */
.compact-input {
    padding: 0.1rem 0.2rem !important;
    height: calc(1.5em + 0.2rem + 2px) !important;
    font-size: 0.8rem !important;
    text-align: right !important;
    border-radius: 2px !important;
    max-width: 70px !important;
    appearance: textfield !important;
    -moz-appearance: textfield !important;
}

.compact-input::-webkit-outer-spin-button,
.compact-input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

/* Header Filter Select */
.header-filter-select {
    font-size: 0.8rem !important;
    font-weight: normal !important; /* Override bold header */
    padding: 0.1rem 0.2rem !important; /* Override default padding */
    min-width: 100px !important;
    max-width: 150px !important;
    background-image: none !important; /* Remove default arrow if needed */
}
.header-filter-select:focus {
    box-shadow: none;
    border-color: transparent;
}

/* Narrow filter selects for boolean and ABC columns */
.modern-table th[data-column="Blacklisted"] .header-filter-select,
.modern-table th[data-column="InLichidare"] .header-filter-select,
.modern-table th[data-column="abc_class"] .header-filter-select {
    min-width: 45px !important;
    max-width: 45px !important;
    font-size: 0.7rem !important;
    padding: 0.05rem 0.1rem !important;
}

/* Text Color Classes (from utilityFunctions) */
.text-danger { color: #dc3545 !important; }
.text-success { color: #198754 !important; }
.text-warning { color: #ffc107 !important; }
.text-muted { color: #6c757d !important; }
.text-dark { color: #212529 !important; }
.fw-bold { font-weight: bold !important; }

/* Stock Status Indicator Styles (applied via classFn or directly in renderCell) */
.stock-indicator {
    position: absolute;
    top: 1px;
    right: 3px;
    font-size: 9px;
    line-height: 1;
    font-weight: bold;
    padding: 1px;
    border-radius: 2px;
}

.stock-indicator.critical { 
    color: #dc3545 !important; 
}

.stock-indicator.optimal { 
    color: #0f5132 !important; 
}

.stock-indicator.high { 
    color: #198754 !important; 
}

/* Apply base styles from getStockClass */
.modern-table td.stock-critical { color: inherit; }
.modern-table td.stock-optimal { font-weight: 500; }
.modern-table td.stock-high { color: inherit; }
.modern-table td.stock-undefined { color: inherit; }

/* Tooltip Styling */
.tooltip {
    font-family: inherit !important;
    font-size: 0.75rem !important;
    opacity: 0.95 !important;
}

.tooltip .tooltip-inner {
    max-width: 300px !important;
    padding: 0.4rem 0.8rem !important;
    background-color: var(--bs-primary) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
}

/* Custom arrow color to match primary background */
.tooltip .tooltip-arrow::before {
    border-top-color: var(--bs-primary) !important;
    border-bottom-color: var(--bs-primary) !important;
}

/* Ensure tooltips appear above other elements */
.tooltip {
    z-index: 1070 !important;
}

/* ABC Classification colored text styles */
.abc-text-a {
    color: #198754 !important;
    font-weight: bold !important;
}

.abc-text-b {
    color: #0d6efd !important;
    font-weight: bold !important;
}

.abc-text-c {
    color: #ffc107 !important;
    font-weight: bold !important;
}

.abc-text-default {
    color: #6c757d !important;
    font-weight: normal !important;
}
