/* Global Overrides */
.table-hover tbody tr:hover {
    background-color: #f5f5f5;
}

/* Compare Bar */
.compare-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #333;
    color: white;
    padding: 1rem;
    display: none;
    z-index: 1000;
}

/* 1. Global Layout & Stickiness (Compare View) */

/* Sticky Toolbar: Always at the very top of the window */
.sticky-toolbar {
    position: sticky;
    top: 0;
    z-index: 1090;
    /* Higher than headers */
    background-color: white;
    border-bottom: 2px solid #dee2e6;
    padding: 0.75rem 0;
    margin-bottom: 0;
}

/* Table Container: To make sticky headers work reliably with horizontal scroll */
/* Global Layout */
html,
body {
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll, let table scroll */
}

/* Table Container: To make sticky headers work reliably with horizontal scroll */
.table-container {
    position: relative;
    flex-grow: 1;
    overflow: auto;
    border: 1px solid #dee2e6;
    /* Remove rounding bottom corners to flush with screen edge if desired, 
       but keeping rounding is nicer if there is padding. 
       Let's keep rounded but ensure it fills space. */
    border-radius: 0.375rem;
}

/* Sticky Headers: Inside the scrollable container */
.sticky-header th {
    position: sticky;
    top: 0;
    z-index: 1045;
    background-color: #343a40 !important;
    color: white !important;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}

/* Sticky Filter Row */
.sticky-header .filter-row td {
    position: sticky;
    top: 45px;
    /* Height of the main header row */
    z-index: 1040;
    background-color: #6c757d;
    /* Matches bg-secondary */
    color: white;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}

/* Category Headers */
.category-header,
.sub-category-header {
    position: sticky;
    top: 147px;
    /* 48px toolbar + approx 99px sticky-header */
    z-index: 1010;
}

/* 2. Highlight Toggle Logic */
table.no-highlight .table-warning,
table.no-highlight tr.table-warning,
table.no-highlight td.table-warning {
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: inset 0 0 0 9999px transparent !important;
    --bs-table-bg-state: transparent !important;
    --bs-table-bg-type: transparent !important;
    --bs-table-accent-bg: transparent !important;
    --bs-table-striped-bg: transparent !important;
    --bs-table-bg: transparent !important;
    color: inherit !important;
}

/* Ensure text visibility on highlighted rows if they were dark */
.table-warning {
    color: #000 !important;
}

/* 3. Helper Classes */
.hide-identical .identical-row {
    display: none !important;
}

.icon-container {
    display: inline-block;
    width: 1.5rem;
    text-align: center;
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    opacity: 0.9;
}

/* 4. Comparison View Toggles */


/* Add subtle animation when highlighting is toggled */
.highlight-diffs td[data-best="true"],
.highlight-diffs td[data-differs="true"] {
    transition: background-color 0.2s ease, border-left 0.2s ease;
}

/* Ensure toggle switches are properly spaced */
.d-flex.gap-3 {
    gap: 1.5rem !important;
}

/* Make form switches slightly larger for better visibility */
.form-check-input {
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* 5. Subsection Collapse Animations */

/* Smooth transitions for row visibility */
tbody tr {
    transition: opacity 0.3s ease, max-height 0.3s ease, transform 0.3s ease;
    max-height: 1000px;
    opacity: 1;
}

/* Hiding animation */
tbody tr.collapsing {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transform: scaleY(0);
    transform-origin: top;
}

/* Badge appearance animation */
.subsection-badge {
    animation: badgeAppear 0.4s ease-out;
    display: inline-block;
}

@keyframes badgeAppear {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.8);
    }

    60% {
        transform: translateY(0px) scale(1.1);
    }

    100% {
        opacity: 1;
        transform: translateY(0px) scale(1);
    }
}

/* Badge hover effect */
.subsection-badge:hover {
    transform: scale(1.05);
    background-color: #5a6268 !important;
    transition: all 0.2s ease;
}

/* Subsection header hover effect */
.subsection-header:hover {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

/* Icon rotation animation */
.subsection-header i,
.section-header i {
    transition: transform 0.3s ease;
    display: inline-block;
}

/* Collapsed state icon */
tr[data-collapsed="true"] i {
    transform: rotate(-90deg);
}

/* Badge container transition */
.collapsed-subsections-badge {
    display: inline-block;
    transition: all 0.3s ease;
}

/* Animation Classes */

/* Row folding animation */
.row-fold-transition {
    transition: all 0.3s ease-in-out;
    transform-origin: top;
    overflow: hidden;
}

.row-folded {
    opacity: 0;
    line-height: 0;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-bottom-width: 0 !important;
    transform: scaleY(0);
}

/* Flying Badge */
.flying-badge {
    position: fixed;
    z-index: 9999;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Bouncy transition */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

/* Subsection header transition */
.subsection-header i {
    transition: transform 0.3s ease;
}

.subsection-badge {
    transition: all 0.3s ease;
}

.subsection-badge.badge-pop-in {
    animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgePop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* USB Colors */
.usb-icon {
    font-weight: bold;
    margin-right: 0.5rem;
    font-style: normal;
    display: inline-block;
}

.usb-20 {
    color: #212529 !important;
}

/* Dark/Black */
.usb-30,
.usb-5g {
    color: #0d6efd !important;
}

/* Bootstrap Primary Blue */
.usb-10g {
    color: #20c997 !important;
}

/* Teal */
.usb-20g {
    color: #fd7e14 !important;
}

/* Orange */
.usb-40g,
.usb-tb {
    color: #dc3545 !important;
}

/* Red */