/* Modern Table Styles */

/* Base Table Container */
.table-modern-container {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    background: white;
}

/* Modern Table */
.table-modern {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

/* Sticky Header Table */
.table-sticky-header {
    position: relative;
}

.table-sticky-header thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Table Header */
.table-modern thead th {
    background: #f8fafc;
    color: var(--bit-body-color, #374151);
    font-weight: 600;
    font-size: calc(var(--bit-table-font-size, 11px) * 1.05) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 20px;
    border: none;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.table-modern thead th:first-child {
    border-top-left-radius: 12px;
}

.table-modern thead th:last-child {
    border-top-right-radius: 12px;
}

/* Sortable Headers */
.table-modern thead th a {
    color: var(--bit-body-color, #374151);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s ease;
    position: relative;
    padding-right: 16px;
}

.table-modern thead th a:hover {
    color: #667eea;
}

/* Sortable but not currently sorted */
.table-modern thead th a.sortable::after {
    content: '↕';
    position: absolute;
    right: 0;
    font-size: 1.1em;
    opacity: 0.25;
    transition: opacity 0.2s ease;
    font-weight: 400;
}

.table-modern thead th a.sortable:hover::after {
    opacity: 0.5;
}

/* Currently sorted descending */
.table-modern thead th a.desc::after {
    content: '↓';
    position: absolute;
    right: 0;
    font-size: 1em;
    opacity: 0.9;
    color: #667eea;
    font-weight: 600;
}

/* Currently sorted ascending */
.table-modern thead th a.asc::after {
    content: '↑';
    position: absolute;
    right: 0;
    font-size: 1em;
    opacity: 0.9;
    color: #667eea;
    font-weight: 600;
}

/* Highlight the currently sorted column */
.table-modern thead th a.asc,
.table-modern thead th a.desc {
    color: #667eea;
    font-weight: 700;
}

/* Table Body */
.table-modern tbody td {
    padding: 10px 20px;
    border-color: #f1f5f9;
    vertical-align: middle;
    color: var(--bit-body-color, #374151);
    font-size: var(--bit-table-font-size, 11px) !important;
    border-bottom: 1px solid #f1f5f9;
}

.table-modern tbody tr {
    transition: background-color 0.15s ease;
}

.table-modern tbody tr:hover {
    background: var(--bit-primary-light, color-mix(in srgb, var(--bit-primary, #0d6efd) 10%, white));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--bit-primary, #0d6efd) 20%, transparent);
}

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

.table-modern tbody tr.clickable-row:hover {
    background: var(--bit-primary-light, color-mix(in srgb, var(--bit-primary, #0d6efd) 15%, white));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--bit-primary, #0d6efd) 30%, transparent);
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

/* Striped Variant */
.table-modern.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(248, 250, 252, 0.5);
}

/* Ensure hover works on striped rows */
.table-modern.table-striped tbody tr:hover {
    background: var(--bit-primary-light, color-mix(in srgb, var(--bit-primary, #0d6efd) 10%, white)) !important;
}

/* Status Badges in Tables */
.table-modern .badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: calc(var(--bit-font-size-base, 14px) * 0.8);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Badge styles now inherit from theme colors via theme_buttons.css */
/* Table badges use the same theme colors as other badges */
.table-modern .badge {
    /* Ensure badges in tables use theme colors */
    font-size: var(--bit-badge-font-size, 12px) !important;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
}

/* Primary badge */
.table-modern .badge.bg-primary {
    background-color: var(--bit-badge-primary, var(--bit-primary)) !important;
    color: var(--bit-badge-primary-fg, var(--bit-primary-fg, white)) !important;
}

/* Secondary badge */
.table-modern .badge.bg-secondary {
    background-color: var(--bit-badge-secondary, var(--bit-secondary)) !important;
    color: var(--bit-badge-secondary-fg, var(--bit-secondary-fg, white)) !important;
}

/* Success badge */
.table-modern .badge.bg-success {
    background-color: var(--bit-badge-success, var(--bit-success)) !important;
    color: var(--bit-badge-success-fg, var(--bit-success-fg, white)) !important;
}

/* Danger badge */
.table-modern .badge.bg-danger {
    background-color: var(--bit-badge-danger, var(--bit-danger)) !important;
    color: var(--bit-badge-danger-fg, var(--bit-danger-fg, white)) !important;
}

/* Warning badge */
.table-modern .badge.bg-warning {
    background-color: var(--bit-badge-warning, var(--bit-warning)) !important;
    color: var(--bit-badge-warning-fg, var(--bit-warning-fg, #212529)) !important;
}

/* Info badge */
.table-modern .badge.bg-info {
    background-color: var(--bit-badge-info, var(--bit-info)) !important;
    color: var(--bit-badge-info-fg, var(--bit-info-fg, #212529)) !important;
}

/* Light badge */
.table-modern .badge.bg-light {
    background-color: var(--bit-badge-light, var(--bit-light)) !important;
    color: var(--bit-badge-light-fg, var(--bit-light-fg, #212529)) !important;
}

/* Dark badge */
.table-modern .badge.bg-dark {
    background-color: var(--bit-badge-dark, var(--bit-dark)) !important;
    color: var(--bit-badge-dark-fg, var(--bit-dark-fg, white)) !important;
}

/* Custom Badge Types for Tables */
.table-modern .badge.bg-status {
    background-color: var(--bit-badge-status, #6b7280) !important;
    color: var(--bit-badge-status-fg, white) !important;
}

.table-modern .badge.bg-student-info {
    background-color: var(--bit-badge-student-info, #8b5cf6) !important;
    color: var(--bit-badge-student-info-fg, white) !important;
}

.table-modern .badge.bg-general {
    background-color: var(--bit-badge-general, #64748b) !important;
    color: var(--bit-badge-general-fg, white) !important;
}

.table-modern .badge.bg-time {
    background-color: var(--bit-badge-time, #06b6d4) !important;
    color: var(--bit-badge-time-fg, white) !important;
}

.table-modern .badge.bg-date {
    background-color: var(--bit-badge-date, #0891b2) !important;
    color: var(--bit-badge-date-fg, white) !important;
}

.table-modern .badge.bg-price {
    background-color: var(--bit-badge-price, #10b981) !important;
    color: var(--bit-badge-price-fg, white) !important;
}

.table-modern .badge.bg-qty {
    background-color: var(--bit-badge-qty, #f59e0b) !important;
    color: var(--bit-badge-qty-fg, white) !important;
}

.table-modern .badge.bg-code {
    background-color: var(--bit-badge-code, #1f2937) !important;
    color: var(--bit-badge-code-fg, white) !important;
}

.table-modern .badge.bg-pending {
    background-color: var(--bit-badge-pending, #eab308) !important;
    color: var(--bit-badge-pending-fg, white) !important;
}

.table-modern .badge.bg-category {
    background-color: var(--bit-badge-category, #6366f1) !important;
    color: var(--bit-badge-category-fg, white) !important;
}

/* Type Badges */
.type-badge {
    background: #fef3c7;
    color: #92400e;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: calc(var(--bit-font-size-base, 14px) * 0.85);
    font-weight: 600;
    display: inline-block;
}

.type-badge.ipcs {
    background: #dbeafe;
    color: #1e40af;
}

.type-badge.ocs {
    background: #dcfce7;
    color: #166534;
}


/* Action Buttons in Tables - Unified styling for all action buttons */
.table-modern .table-action-btn,
.table-modern .btn-sm {
    padding: 3px 6px !important;  /* Smaller padding */
    border-radius: 4px !important;
    font-size: calc(var(--bit-font-size-base, 14px) * 0.525) !important;  /* Smaller font */
    line-height: 1.4 !important;
    min-height: unset !important;
    margin: 0 2px;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

/* Global table-action-btn styling - applies anywhere */
.table-action-btn {
    padding: 3px 6px !important;  /* Smaller padding */
    border-radius: 4px !important;
    font-size: calc(var(--bit-font-size-base, 14px) * 0.525) !important;  /* Smaller font */
    line-height: 1.4 !important;
    min-height: unset !important;
    margin: 0 2px;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

/* Hover state for action buttons - inherits from app.css */

/* Button variant styles are handled in app.css for consistency */

/* Icon styling in action buttons */
.table-modern .table-action-btn i,
.table-modern .btn-sm i,
.table-modern td .btn i,
.table-action-btn i,
.listing-page .btn i {
    font-size: 0.84rem !important;  /* Even larger icons */
    vertical-align: middle;
    font-weight: 600 !important;  /* Medium weight for subtle emphasis */
    color: inherit !important;  /* Icons inherit button text color */
}

/* Old btn-action specific styles for backward compatibility */
.table-modern .btn-action {
    padding: 5px 10px !important;
    border-radius: 5px !important;
    font-size: calc(var(--bit-font-size-base, 14px) * 0.75) !important;
    line-height: 1.2 !important;
    min-height: unset !important;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #374151;
}

.table-modern .btn-action:hover {
    background: white;
    border-color: #e5e7eb;
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* Empty State */
.table-modern-empty {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.table-modern-empty i {
    font-size: 3rem;
    color: #d1d5db;
    margin-bottom: 16px;
}

.table-modern-empty h5 {
    color: #374151;
    font-weight: 600;
    margin-bottom: 8px;
}

.table-modern-empty p {
    margin-bottom: 0;
    font-size: calc(var(--bit-font-size-base, 14px) * 0.925);
}

/* CSS-based no results display logic */
/* Hide no-results row by default */
.listing-tbody .no-results-row {
    display: none;
}

/* Show no-results row when it's the only row (no data rows present) */
.listing-tbody:not(:has(.data-row)) .no-results-row,
.listing-tbody .no-results-row:only-child {
    display: table-row;
}

/* Alternative for browsers that don't support :has() */
.listing-tbody .no-results-row:first-child:last-child {
    display: table-row;
}

/* Table Info Row */
.table-info-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.table-info-row strong {
    color: var(--bit-body-color, #1e293b);
    font-weight: 600;
}

.table-info-row small {
    color: color-mix(in srgb, var(--bit-body-color, #6b7280) 70%, transparent);
    font-size: calc(var(--bit-font-size-base, 14px) * 0.85);
}

/* Config Text in Tables */
.config-text {
    font-size: calc(var(--bit-font-size-base, 14px) * 0.9);
    color: color-mix(in srgb, var(--bit-body-color, #6b7280) 70%, transparent);
    line-height: 1.4;
}

.config-text strong {
    color: var(--bit-body-color, #374151);
    font-weight: 600;
}

/* Responsive Table */
.table-responsive-modern {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table-modern thead th {
        padding: 12px 16px;
        font-size: calc(var(--bit-table-font-size, 11px) * 0.95);
    }
    
    .table-modern tbody td {
        padding: 12px 16px;
        font-size: var(--bit-table-font-size, 11px);
    }
    
    .table-modern .badge {
        padding: 4px 8px;
        font-size: calc(var(--bit-font-size-base, 14px) * 0.75);
    }
    
    /* Hide less important columns on mobile */
    .table-modern .hide-mobile {
        display: none;
    }
}

/* Pagination with Modern Table */
.table-pagination-modern {
    padding: 16px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: fit-content;
    flex-wrap: wrap;
    gap: 12px;
}

.table-pagination-modern .pagination {
    margin-bottom: 0;
}

.table-pagination-modern .pagination .page-link {
    border: 1px solid #e5e7eb;
    color: #374151;
    padding: 8px 12px;
    margin: 0 2px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.table-pagination-modern .pagination .page-link:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.table-pagination-modern .pagination .page-item.active .page-link {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.table-pagination-modern .page-info {
    color: #6b7280;
    font-size: calc(var(--bit-font-size-base, 14px) * 0.875);
    white-space: nowrap;
    min-width: fit-content;
}

/* Loading State */
.table-modern.loading {
    position: relative;
    pointer-events: none;
}

.table-modern.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Print Styles */
@media print {
    .table-modern-container {
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }
    
    .table-modern thead th {
        background: #f8fafc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .table-modern tbody tr:hover {
        background: transparent !important;
    }
}