/**
 * Firmware Dashboard - Main Stylesheet
 * Organized by: Layout → Components → Utilities → Dark Mode
 */

/* ==================== GLOBAL BOX SIZING ==================== */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ==================== CSS VARIABLES ==================== */
:root {
    /* Primary Colors */
    --color-primary: #2d8998;
    --color-primary-dark: #246b78;
    --color-primary-light: #e3f2fd;
    --color-primary-darker: #105c74;
    --color-primary-darkest: #0d4a5e;
    
    /* Text Colors */
    --color-text-primary: #2c3e50;
    --color-text-secondary: #555;
    --color-text-muted: #7f8c8d;
    --color-text-disabled: #95a5a6;
    --color-text-light: #555;
    
    /* Background Colors */
    --color-bg: #ffffff;
    --color-bg-secondary: #f9fafb;
    --color-bg-input: #f8f9fa;
    --color-bg-input-disabled: #ecf0f1;
    --color-bg-hover: #f0f7ff;
    --color-bg-gradient-top: #f8f8f7;
    --color-bg-gradient-bottom: #f1f0ee;
    
    /* Border Colors */
    --color-border: #dddfe0;
    --color-border-light: #e8ecef;
    --color-border-medium: #b0bec5;
    --color-border-focus: #36a4b5;
    
    /* Status Colors */
    --color-success: #4caf50;
    --color-error: #e74c3c;
    --color-warning: #f57f17;
    --color-info: #2196f3;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 6px 20px rgba(30, 136, 229, 0.4);
    --shadow-xl: 0 10px 40px rgba(0,0,0,0.3);
    --shadow-focus-glow: 0 4px 20px rgba(45, 137, 152, 0.4), 0 0 0 2px rgba(45, 137, 152, 0.2);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-2xl: 1.25rem;
    
    /* Transitions */
    --transition-base: all 0.3s ease;
    --transition-fast: all 0.2s ease;
    
    /* Layout */
    --top-bar-height: 70px;
    --menu-panel-width: 200px;
    --menu-content-gap: 20px;
    
    /* Legacy support (deprecated - use standardized names above) */
    --text-color--text-primary: var(--color-text-primary);
    --border-color--border: var(--color-border);
    --base-color-neutral--white: var(--color-bg);
    --base-color-gradient-color--beige-top: var(--color-bg-gradient-top);
    --base-color-gradient-color--beige-bottom: var(--color-bg-gradient-bottom);
    --radius--1-25rem: var(--radius-2xl);
}

/* ==================== GLOBAL LAYOUT STYLES ==================== */

.top-container {
    max-width: 100vw;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    width: 100%;
    margin-top: calc(var(--top-bar-height, 70px) + 20px); /* Start below top-bar */
    margin-bottom: 0; /* No bottom margin - padding handles spacing */
    margin-left: auto; /* Center when menu is closed */
    margin-right: auto; /* Center when menu is closed */
    padding-top: 0; /* Removed padding-top since margin handles spacing */
    padding-bottom: 20px;
    padding-left: 20px; /* Space for shadow on left side */
    padding-right: 20px; /* Space for shadow on right side */
    box-sizing: border-box;
    /* Smooth transition for padding when menu opens/closes */
    transition: padding-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Prevent layout shift */
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
    /* Removed transform to prevent layout issues */
    position: relative; /* Establish positioning context */
}

/* Add padding when menu is open AND content would overlap - only push if needed */
body.menu-open .container.menu-push-content {
    /* Set left padding to menu width + gap (replaces original 20px padding) */
    /* This creates exactly 20px gap between menu right edge and content left edge */
    padding-left: calc(var(--menu-panel-width, 200px) + var(--menu-content-gap, 20px));
    /* Keep original right padding */
    padding-right: 20px;
}

.logo-bar {
    text-align: left;
    padding: 8px 0 8px 0;
    max-width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.logo-bar img {
    height: 50px;
    padding: 0 80px 0 0; /* Reduced right padding, no left padding (menu button takes space) */
    max-width: 100%;
}

.top-bar {
    background-image:none;
    background-color: #ffffff;
    background-position: 0 0, 0 0, 0 0, 0 0;
    background-size: auto, auto, auto, auto;
    padding: 0;
    width: 100%;
    max-width: 100vw;
    height: var(--top-bar-height, 70px);
    box-sizing: border-box;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1500; /* Above regular content, below forms/modals (2000+) */
}

/* ==================== HEADER SECTION ==================== */
.header {
    padding: 0px;
    text-align: center;
    font-weight: 500;
    margin-top: 60px;
}

.header:first-child {
    margin-top: 0;
}

.heading-style-h1 {
    color: var(--color-text-primary);
    font-variation-settings: "wght" 450;
    letter-spacing: -2px;
    font-family: Sora Variablefont Wght, Arial, sans-serif;
    font-size: 2rem;
    line-height: 1.1;
    font-weight: normal;
    padding: 0;
    margin: 0;
}

.header p {
    font-size: 1.25rem;
}

/* ==================== BODY & BACKGROUND ==================== */

/* Hide scrollbar utility - applied via class or directly */
.hide-scrollbar,
html,
body,
* {
    scrollbar-width: none !important; /* Firefox */
    -ms-overflow-style: none !important; /* IE and Edge */
}

.hide-scrollbar::-webkit-scrollbar,
html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
    display: none !important;
}

.hide-scrollbar::-webkit-scrollbar-track,
.hide-scrollbar::-webkit-scrollbar-thumb,
html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-thumb {
    display: none !important;
}

html {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: auto; /* Disable smooth scrolling which can cause glitches */
}

body {
    width: 100%;
    height: auto; /* Let height be determined by content */
    min-height: 0; /* No minimum height */
    max-height: none; /* No maximum height */
    font-family: Sora Variablefont Wght, Arial, sans-serif;
    background-image: url("../../images/bg_noise.webp");
    background-repeat: repeat;
    background-size: auto;
    overflow-x: hidden;
    overflow-y: visible; /* Don't create second scroll context */
    margin: 0;
    padding: 0;
    position: relative; /* Establish positioning context */
}

/* ==================== DASHBOARD COMPONENTS ==================== */
.dashboard-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 100%;
}

.dashboard-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2xl);
    background: var(--color-bg);
    background-image: none;
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    max-width: 100%;
    transition: box-shadow 0.5s ease;
}

/* Dashboard highlight animation - only animate shadow, no position/size changes */
.dashboard-card.dashboard-highlight {
    animation: dashboardHighlight 1s ease;
}

@keyframes dashboardHighlight {
    0% {
        box-shadow: var(--shadow-md);
    }
    50% {
        box-shadow: 0 4px 20px rgba(45, 137, 152, 0.4), 0 0 0 2px rgba(45, 137, 152, 0.2);
    }
    100% {
        box-shadow: var(--shadow-md);
    }
}

/* Also apply to error-logs-card for Activity Logs */
.error-logs-card {
    transition: box-shadow 0.5s ease;
}

.error-logs-card.dashboard-highlight {
    animation: dashboardHighlight 1s ease;
}

/* ==================== GLOBAL FOCUS STYLES ==================== */
/* Apply consistent focus glow to all interactive elements */
button:focus-visible,
.modal-btn:focus-visible,
.submit-btn:focus-visible,
.pagination-btn:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus-glow);
}

/* ==================== TABLE COMPONENTS ==================== */
.table-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 12px;
    margin-top: 12px;
    gap: 8px;
    transition: margin-top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.table-header.filters-visible {
    margin-top: 12px;
}

.filters {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

/* Firmware Dashboard - badges inline with filter */
.filters .active-filters {
    flex-basis: auto;
    order: 0;
}

/* Firmware Dashboard - alignment based on filter state */
.filters > div.filter-collapsed {
    align-self: center;
}

.filters > div.filter-expanded {
    align-self: flex-end;
}

.filters .active-filters {
    align-self: center;
}

.filters > div.filter-expanded ~ .active-filters {
    align-self: flex-end;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.firmware-refresh-btn {
    background: transparent;
    border: none;
    color: #8b95a0;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    height: 32px;
    box-sizing: border-box;
}

.firmware-refresh-btn svg {
    transition: transform 0.3s ease;
}

.firmware-refresh-btn:hover {
    background: #e6f4fa;
    color: #3d7b8f;
}

.firmware-refresh-btn:hover svg {
    transform: rotate(90deg);
}

.firmware-refresh-btn:active svg {
    transform: rotate(180deg);
}

.filter-label {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.filter-select {
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
}

/* Dropdown option styling - Light mode */
.filter-select option {
    background: var(--color-bg);
    color: var(--color-text-primary);
    padding: 8px 12px;
}

.filter-select option:hover,
.filter-select option:focus,
.filter-select option:active,
.filter-select option:checked {
    background: var(--color-primary) !important;
    background-color: var(--color-primary) !important;
    color: white !important;
}

/* Firefox specific */
.filter-select option:hover {
    background: var(--color-primary) !important;
    color: white !important;
}

/* WebKit browsers specific */
.filter-select option:hover:not(:disabled) {
    background: linear-gradient(var(--color-primary), var(--color-primary)) !important;
    color: white !important;
}

/* ==================== KPI CARDS ==================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.kpi-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 16px;
}

.kpi-title {
    font-weight: 600;
    color: #667085;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 600;
}

/* ==================== TABLE SECTION ==================== */
.table-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.responsive-table {
    overflow: auto;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
}

.table-wrapper {
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    max-width: 100%;
}

/* Remove horizontal scrollbar for PCB table */
#pcbDashboardCard .table-wrapper {
    overflow-x: hidden;
    overflow-y: auto;
}

/* Ensure PCB table doesn't overflow */
#pcbTable {
    table-layout: auto;
    width: 100%;
    max-width: 100%;
}

/* PCB table row hover effect for clickable rows */
#pcbTable .pcb-table-row {
    transition: background-color 0.2s ease;
}

#pcbTable .pcb-table-row:hover {
    background-color: #f8f9fa;
}

/* Auto-size columns based on content */
#pcbTable th:nth-child(2),
#pcbTable th:nth-child(3),
#pcbTable th:nth-child(4),
#pcbTable th:nth-child(5),
#pcbTable th:nth-child(6) {
    width: auto;
    white-space: nowrap;
}

#pcbTable td:nth-child(2),
#pcbTable td:nth-child(3),
#pcbTable td:nth-child(4),
#pcbTable td:nth-child(5),
#pcbTable td:nth-child(6) {
    max-width: none;
    width: auto;
    min-width: fit-content;
}

/* ==================== PCB TABLE GROUPED VIEW STYLES ==================== */

/* Device Type Group Header - Primary group */
#pcbTable .pcb-device-type-header {
    background-color: #f8f9fa;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid #e5e7eb;
}

#pcbTable .pcb-device-type-header:hover {
    background-color: #e9ecef;
}

#pcbTable .pcb-device-type-header td {
    padding: 5px 8px;
    border-bottom: none;
}

/* Project Number Sub-Group Header - Secondary group, visually distinct */
#pcbTable .pcb-project-group-header {
    background-color: #fff;
    cursor: pointer;
    border-left: 3px solid #3498db;
}

#pcbTable .pcb-project-group-header:hover {
    background-color: #f0f7ff;
}

#pcbTable .pcb-project-group-header td {
    padding: 4px 8px;
    border-bottom: 1px solid #e5e7eb;
}

/* Group toggle icon */
#pcbTable .pcb-group-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    color: #2d8998;
    transition: transform 0.2s ease;
    font-size: 9px;
}

#pcbTable .pcb-group-toggle:hover {
    color: #246b78;
}

#pcbTable .pcb-device-type-header .pcb-group-toggle {
    font-size: 10px;
}

#pcbTable .pcb-project-group-header .pcb-group-toggle {
    color: #3498db;
}

/* Grouped PCB rows - Child row styling */
#pcbTable .pcb-grouped-row {
    background-color: #ffffff;
    cursor: pointer;
}

#pcbTable .pcb-grouped-row:hover {
    background-color: #f0f7ff;
}


/* Nested rows (inside sub-groups) - more indented appearance */
#pcbTable .pcb-nested-row {
    background-color: #fafcff;
    border-left: 3px solid #e8f4fc;
}

#pcbTable .pcb-nested-row:hover {
    background-color: #f0f7ff;
    border-left-color: #3498db;
}

/* Group count text */
#pcbTable .pcb-group-count {
    color: #7f8c8d;
    font-weight: normal;
    margin-left: 6px;
    font-size: 11px;
}

#pcbTable .pcb-subgroup-count {
    color: #3498db;
    font-weight: 500;
    margin-left: 6px;
    font-size: 10px;
}

/* Group name styling */
#pcbTable .pcb-group-name {
    color: #2c3e50;
    font-size: 12px;
    font-weight: 600;
}

#pcbTable .pcb-subgroup-name {
    color: #3498db;
    font-size: 11px;
    font-weight: 600;
    font-family: monospace;
}


/* Cursor for clickable elements */
#pcbTable .pcb-device-type-header,
#pcbTable .pcb-project-group-header,
#pcbTable .pcb-grouped-row {
    cursor: pointer;
}

/* Expand/Collapse All button - simple style */
.pcb-expand-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pcb-expand-toggle-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.pcb-expand-toggle-btn svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

/* PCB Table Compact Rows */
#pcbTable td {
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.3;
}

#pcbTable th {
    padding: 6px 8px;
    font-size: 12px;
}

/* PCB Project ID column - prioritize width */
#pcbTable .pcb-project-id-cell {
    white-space: nowrap;
    min-width: 200px;
}

/* Other columns - compact */
#pcbTable .status-cell {
    width: 90px;
    min-width: 90px;
}

#pcbTable .pcb-variation-tags-cell {
    max-width: 120px;
}

#pcbTable .pcb-date-cell {
    width: 80px;
    min-width: 80px;
    font-size: 11px;
}

/* PCB Project ID cell with copy button */
#pcbTable .pcb-project-id-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

#pcbTable .pcb-project-id-text {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 11px;
    color: #2c3e50;
    letter-spacing: -0.3px;
}

#pcbTable .pcb-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    background: #f8f9fa;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    opacity: 0.6;
}

#pcbTable tr:hover .pcb-copy-btn {
    opacity: 1;
}

#pcbTable .pcb-copy-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #495057;
}

#pcbTable .pcb-copy-btn:active {
    background: #dee2e6;
}

#pcbTable .pcb-copy-btn.copied {
    background: #d4edda;
    border-color: #28a745;
    color: #28a745;
    opacity: 1;
}

/* ==================== END PCB TABLE GROUPED VIEW STYLES ==================== */

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}

.table-actions {
    display: flex;
    gap: 8px;
}

/* ==================== BUTTON STYLES ==================== */
.submit-btn {
    background: var(--color-primary-darker);
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.submit-btn:disabled {
    background: var(--color-text-disabled);
    cursor: default;
    transform: none;
    box-shadow: none;
}

.add-btn {
    width: auto;
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    background: var(--color-primary);
    color: white;
    transition: var(--transition-fast);
    height: 32px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.add-btn:hover {
    background: var(--color-primary-dark);
    transform: none;
    box-shadow: none;
}

.remove-btn {
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    height: 32px;
    box-sizing: border-box;
}

.remove-btn .trash-icon {
    filter: grayscale(100%);
    opacity: 0.8;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

.batch-promote-btn {
    padding: 8px 14px !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    height: 32px !important;
    box-sizing: border-box;
}

.batch-promote-btn svg {
    width: 16px;
    height: 16px;
    filter: grayscale(100%);
    opacity: 0.8;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Batch Promote Modal Button Styles */
.batch-promote-status-btn {
    padding: 8px 16px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.batch-promote-status-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    transform: translateY(-1px);
}

.batch-promote-status-btn[data-selected="true"] {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

.batch-promote-status-btn[data-selected="true"]:hover {
    background: #2980b9;
    border-color: #2980b9;
}

.batch-promote-expand {
    cursor: pointer;
    color: #3498db;
    font-weight: 600;
    margin-left: 4px;
    user-select: none;
}

.batch-promote-expand:hover {
    color: #2980b9;
    text-decoration: underline;
}

.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 32px;
    max-height: 32px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-btn-cancel {
    background: #ecf0f1;
    color: #555;
}

.modal-btn-cancel:hover {
    background: #bdc3c7;
}

.modal-btn-confirm {
    background: #e74c3c;
    color: #fff;
}

.modal-btn-confirm:hover {
    background: #c0392b;
}

/* ==================== MODAL STYLES ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: #ffffff;
    margin: 15% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideIn 0.3s;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#confirmModal .modal-header h2,
#reusePrevModal .modal-header h2 {
    color: #e74c3c;
    font-size: 22px;
}

#confirmModal .modal-body,
#reusePrevModal .modal-body {
    margin-bottom: 25px;
    color: #555;
    line-height: 1.6;
}

#confirmModal .modal-body p,
#reusePrevModal .modal-body p {
    margin-bottom: 10px;
}

.firmware-id-display {
    font-family: monospace;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    margin: 15px 0;
}

.warning-text {
    margin-top: 15px;
    color: #e74c3c;
    font-weight: 600;
}

#confirmModal .modal-footer,
#reusePrevModal .modal-footer,
#deviceKeyDetailsModal .modal-footer,
#batchPromoteProductModal .modal-footer,
#batchPromoteModal .modal-footer {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.remove-btn {
    padding: 8px 14px;
    height: 32px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
}

/* Download button in table */
table td:last-child {
    text-align: center;
}

/* Firmware ID cell centering */
.data-table tbody td:nth-child(2) {
    text-align: center;
}

.download-btn {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    height: 24px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.download-btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(45, 137, 152, 0.3);
}

.download-btn:active {
    transform: translateY(0);
}

/* Tooltip styles */
.firmware-tooltip {
    position: absolute;
    z-index: 10000;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-size: 11px;
    line-height: 1.6;
    min-width: 400px;
    max-width: 500px;
    pointer-events: auto;
    animation: tooltipFadeIn 0.2s ease-in;
}

.firmware-tooltip .tooltip-content {
    color: #374151;
}

.firmware-tooltip .tooltip-layout {
    display: flex;
    gap: 16px;
}

.firmware-tooltip .tooltip-left {
    flex-shrink: 0;
}

.firmware-tooltip .tooltip-icon-wrapper {
    position: relative;
    display: inline-block;
}

.firmware-tooltip .tooltip-icon {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

/* Status cell in table */
.status-cell {
    text-align: center;
    padding: 0.5rem 0.75rem !important;
}

.status-cell .firmware-status-tag {
    height: 18px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
    max-width: 100%;
}

.firmware-tooltip .firmware-status-tag {
    position: absolute;
    bottom: 1px;
    right: 4px;
    width: 40px;
    height: 40px;
    background: transparent;
    padding: 0;
    box-shadow: none;
}

.firmware-tooltip .tooltip-icon-placeholder {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f3f4f6;
}

.firmware-tooltip .tooltip-right {
    flex: 1;
    min-width: 0;
}

.firmware-tooltip .tooltip-header {
    margin-bottom: 12px;
}

.firmware-tooltip .tooltip-header > div {
    margin-bottom: 4px;
}

.firmware-tooltip .tooltip-content strong {
    color: #1f2937;
    font-weight: 600;
}

.firmware-tooltip .tooltip-files {
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
    margin-top: 8px;
}

.firmware-tooltip .tooltip-file {
    margin-bottom: 10px;
    padding: 8px;
    background: #f9fafb;
    border-radius: 6px;
}

.firmware-tooltip .tooltip-file:last-child {
    margin-bottom: 0;
}

.firmware-tooltip .tooltip-file-label {
    font-weight: 600;
    color: #2d8998;
    margin-bottom: 4px;
}

.firmware-tooltip .tooltip-file-name {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: #4b5563;
    margin-bottom: 4px;
}

.firmware-tooltip .tooltip-file-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 9px;
    color: #6b7280;
}

.firmware-tooltip .tooltip-file-details span {
    font-family: 'Courier New', monospace;
}

.firmware-tooltip .tooltip-loading {
    text-align: center;
    padding: 20px;
    color: #6b7280;
}

.firmware-tooltip .tooltip-error {
    color: #dc2626;
    font-size: 10px;
    margin-top: 8px;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== DATA TABLE ==================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 5px 5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    vertical-align: middle;
    height: auto;
    min-height: 28px;
    line-height: 1.4;
}

/* Minimize padding for PCB table */
#pcbTable th,
#pcbTable td {
    padding: 4px 6px;
    min-height: auto;
}

.data-table thead th {
    background: #f9fafb;
    font-weight: 600;
}

.data-table thead th.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s ease;
}

.data-table thead th.sortable-header:hover {
    background: #e6f4fa;
}

.data-table thead th.sortable-header .sort-indicator {
    display: inline-block;
    margin-left: 6px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    vertical-align: middle;
    position: relative;
    top: -2px;
}

.data-table thead th.sortable-header[data-sort="desc"] .sort-indicator {
    border-top: 6px solid #2d8998;
    border-bottom: none;
}

.data-table thead th.sortable-header[data-sort="asc"] .sort-indicator {
    border-bottom: 6px solid #2d8998;
    border-top: none;
}

.data-table tbody tr {
    transition: background-color 0.2s, transform 0.1s;
    cursor: pointer;
    height: auto;
    min-height: 28px;
}

.data-table tbody td {
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background-color: #f0f7ff;
}

.data-table tr.selected {
    background: #e3f2fd;
}

/* ==================== TABLE CHECKBOXES ==================== */
/* Unified checkbox styling for all tables matching theme */

.data-table input[type="checkbox"],
.data-table th input[type="checkbox"],
.data-table td input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 2px solid var(--color-border, #dddfe0);
    border-radius: 4px;
    background-color: var(--color-bg, #ffffff);
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.data-table input[type="checkbox"]:hover {
    border-color: var(--color-primary, #2d8998);
    background-color: var(--color-primary-light, #e3f2fd);
}

.data-table input[type="checkbox"]:checked {
    background-color: var(--color-primary, #2d8998);
    border-color: var(--color-primary, #2d8998);
}

.data-table input[type="checkbox"]:focus {
    outline: none;
    box-shadow: var(--shadow-focus-glow);
    border-color: var(--color-primary, #2d8998);
}

.data-table input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    background-color: var(--color-bg-input-disabled, #ecf0f1);
    border-color: var(--color-border-light, #e8ecef);
}

.data-table input[type="checkbox"]:disabled:checked {
    background-color: var(--color-text-disabled, #95a5a6);
    border-color: var(--color-text-disabled, #95a5a6);
}

.data-table input[type="checkbox"]:disabled:checked::after {
    border-color: white;
}

/* Checkbox cell styling */
.data-table .checkbox-cell,
.data-table td:has(input[type="checkbox"]),
.data-table th:has(input[type="checkbox"]) {
    width: 40px;
    text-align: center;
    padding: 8px 5px;
    vertical-align: middle;
}

/* ==================== PAGINATION ==================== */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 0px;
}

.pagination button {
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    height: 32px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pagination button:hover:not([disabled]) {
    background: #f5f5f5;
}

.pagination button.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.pagination button[disabled] {
    opacity: 0.5;
    cursor: default;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 1024px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Add padding when menu is open on smaller screens AND content would overlap */
    body.menu-open .container.menu-push-content {
        /* Set left padding to menu width + gap (replaces original 1rem padding) */
        padding-left: calc(var(--menu-panel-width, 200px) + var(--menu-content-gap, 20px));
        padding-right: 1rem;
    }
    
    .logo-bar img {
        padding: 0 20px;
    }
}

@media (max-width: 768px) {
    .container {
        margin: calc(var(--top-bar-height, 70px) + 10px) auto 0 auto;
        padding-bottom: 20px;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Add padding when menu is open on mobile AND content would overlap - use smaller gap */
    body.menu-open .container.menu-push-content {
        /* Set left padding to menu width + gap (replaces original 1rem padding) */
        /* Note: Using 20px gap even on mobile for consistency */
        padding-left: calc(var(--menu-panel-width, 200px) + var(--menu-content-gap, 20px));
        padding-right: 1rem;
    }
    
    .logo-bar {
        margin: 0;
    }
    
    .logo-bar img {
        padding: 0 10px;
    }
}

/* ==================== DARK MODE ==================== */
@media (prefers-color-scheme: dark) {
    :root {
        /* Dark mode color overrides */
        --color-text-primary: #e5e7eb;
        --color-text-secondary: #cbd5e1;
        --color-text-muted: #94a3b8;
        --color-text-disabled: #64748b;
        --color-text-light: #a1a1aa;
        
        /* Dark mode backgrounds */
        --color-bg: #0f1113;
        --color-bg-secondary: #111827;
        --color-bg-input: #111315;
        --color-bg-input-disabled: #0a0b0c;
        --color-bg-hover: #1a1d21;
        --color-bg-gradient-top: #0f1113;
        --color-bg-gradient-bottom: #0a0b0c;
        
        /* Dark mode borders */
        --color-border: rgba(255, 255, 255, 0.12);
        --color-border-light: rgba(255, 255, 255, 0.08);
        --color-border-medium: rgba(255, 255, 255, 0.14);
        --color-border-focus: #2d8998;
        
        /* Keep same primary colors for dark mode */
        /* --color-primary, --color-success, etc. remain unchanged */
    }

    html, body {
        background-color: #0b0b0c;
    }

    body {
        background-image: none;
    }

    .top-bar {
        background-image: none;
        background-color: #0f1113;
        border-bottom: 1px solid #dddfe0;
        border-color: rgba(255,255,255,0.12);
    }

    .logo-bar {
        background-color: #0f1113;
  
    }

    .header .heading-style-h1 {
        color: #ffffff;
    }

    .header p {
        color: #ffffff;
    }

    .kpi-card,
    .responsive-table {
        background: var(--color-bg);
        border-color: var(--color-border-light);
    }
    .data-table thead th {
        background: #111214;
    }
    .data-table th,
    .data-table td {
        border-bottom: 1px solid var(--color-border-light);
        color: var(--color-text-primary);
    }
    
    /* Dark mode checkbox styling */
    .data-table input[type="checkbox"] {
        background-color: var(--color-bg-input, #111315);
        border-color: var(--color-border, rgba(255, 255, 255, 0.12));
    }
    
    .data-table input[type="checkbox"]:hover {
        border-color: var(--color-primary, #2d8998);
        background-color: rgba(45, 137, 152, 0.2);
    }
    
    .data-table input[type="checkbox"]:checked {
        background-color: var(--color-primary, #2d8998);
        border-color: var(--color-primary, #2d8998);
    }
    
    .data-table input[type="checkbox"]:disabled {
        background-color: var(--color-bg-input-disabled, #0a0b0c);
        border-color: var(--color-border-light, rgba(255, 255, 255, 0.08));
    }
    .table-wrapper {
        border-color: var(--color-border);
    }
    .dashboard-card {
        background: var(--color-bg);
        background-image: none;
        border-color: var(--color-border);
    }
    .filter-label {
        color: var(--color-text-secondary);
    }
    .filter-select {
        background: var(--color-bg-input);
        color: var(--color-text-primary);
        border-color: var(--color-border);
    }
    
    /* Dropdown option styling - Dark mode */
    .filter-select option {
        background: var(--color-bg-input);
        color: var(--color-text-primary);
        padding: 8px 12px;
    }
    
    .filter-select option:hover,
    .filter-select option:focus,
    .filter-select option:active,
    .filter-select option:checked {
        background: #3f4550 !important;
        background-color: #3f4550 !important;
        color: #ffffff !important;
    }
    
    /* Firefox specific - Dark mode */
    .filter-select option:hover {
        background: #3f4550 !important;
        color: #ffffff !important;
    }
    
    /* WebKit browsers specific - Dark mode */
    .filter-select option:hover:not(:disabled) {
        background: linear-gradient(#3f4550, #3f4550) !important;
        color: #ffffff !important;
    }
    .pagination button {
        background: var(--color-bg-input);
        color: var(--color-text-primary);
        border-color: var(--color-border);
    }
    .pagination button.active {
        background: var(--color-primary-darker);
        border-color: var(--color-primary-darker);
        color: #fff;
    }
    .data-table tr.selected {
        background: #0e2230;
    }
    
    .data-table tbody tr:hover {
        background-color: #1a1d21;
    }

    /* Button dark mode styles */
    .submit-btn {
        background: var(--color-primary);
        color: #fff;
    }
    
    .download-btn {
        background: var(--color-primary);
        color: #fff;
    }
    
    .download-btn:hover {
        background: var(--color-border-focus);
        box-shadow: 0 2px 8px rgba(45, 137, 152, 0.5);
    }

    /* Tooltip dark mode */
    .firmware-tooltip {
        background: #1f2937;
        border-color: #374151;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    }
    
    .firmware-tooltip .tooltip-content {
        color: #e5e7eb;
    }
    
    .firmware-tooltip .tooltip-content strong {
        color: #f3f4f6;
    }
    
    .firmware-tooltip .tooltip-icon {
        border-color: #4b5563;
    }
    
    .firmware-tooltip .tooltip-icon-placeholder {
        background: #374151;
    }
    
    .firmware-tooltip .tooltip-icon-placeholder rect {
        fill: #4b5563;
    }
    
    .firmware-tooltip .tooltip-icon-placeholder path {
        stroke: #6b7280;
    }
    
    .firmware-tooltip .tooltip-files {
        border-top-color: #4b5563;
    }
    
    .firmware-tooltip .tooltip-file {
        background: #111827;
    }
    
    .firmware-tooltip .tooltip-file-label {
        color: #36a4b5;
    }
    
    .firmware-tooltip .tooltip-file-name {
        color: #9ca3af;
    }
    
    .firmware-tooltip .tooltip-file-details {
        color: #6b7280;
    }
    
    .firmware-tooltip .tooltip-loading {
        color: #9ca3af;
    }
    
    .firmware-tooltip .tooltip-error {
        color: #f87171;
    }
    
    .modal-btn-cancel {
        background: var(--color-bg-input);
        color: var(--color-text-secondary);
        border: 1px solid var(--color-border);
    }
    .modal-btn-cancel:hover {
        background: var(--color-bg-hover);
    }
    .modal-btn-confirm {
        background: #e74c3c;
        color: #fff;
    }

    /* Modal dark mode styles */
    #confirmModal .modal-content,
    #reusePrevModal .modal-content {
        background-color: var(--color-bg);
        border: 1px solid var(--color-border);
    }
    #confirmModal .modal-header h2,
    #reusePrevModal .modal-header h2 {
        color: var(--color-error);
    }
    #confirmModal .modal-body,
    #reusePrevModal .modal-body {
        color: var(--color-text-secondary);
    }
    .firmware-id-display {
        background: var(--color-bg-input);
        color: var(--color-text-primary);
        border: 1px solid var(--color-border);
    }
}

/* Firmware table slide-in animation for new entries */
.firmware-slide-in {
    animation: firmwareSlideIn 0.5s ease-out;
}

@keyframes firmwareSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== PCB IMAGE TOOLTIP ==================== */
.pcb-image-tooltip {
    position: fixed;
    z-index: 10000;
    display: none;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.pcb-image-tooltip.visible {
    opacity: 1;
}

.pcb-image-tooltip .tooltip-image {
    width: 400px;
    height: 400px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px;
    box-sizing: border-box;
}

.pcb-table-image {
    transition: opacity 0.2s ease;
}

.pcb-table-image:hover {
    opacity: 0.8;
}

/* Consistent font styling for PCB table */
#pcbTable td,
#pcbTable th {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
}

#pcbTable td {
    font-size: 14px;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    max-width: 0; /* Force cells to respect table width */
    text-overflow: ellipsis;
}

/* Override max-width for auto-sizing columns (PCB Image, PCB Project ID, Device Type, Variation, Created on) */
#pcbTable td:nth-child(2),
#pcbTable td:nth-child(3),
#pcbTable td:nth-child(4),
#pcbTable td:nth-child(5),
#pcbTable td:nth-child(6) {
    max-width: none;
}

/* PCB table scrollable text cells */
#pcbTable .pcb-scrollable-cell {
    overflow: hidden;
    position: relative;
    white-space: nowrap;
}

/* PCB Project ID cell - left aligned content */
#pcbTable .pcb-project-id-cell {
    text-align: left;
}

/* Date cell - allow wrapping */
#pcbTable .pcb-date-cell {
    white-space: normal;
    overflow: visible;
    line-height: 1.4;
}

#pcbTable .pcb-scrollable-cell.scrolling-text {
    overflow: visible;
    z-index: 10;
}

/* Text wrapper for scrolling animation */
#pcbTable .pcb-text-wrapper {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    transition: transform 0.1s linear;
    will-change: transform;
    position: relative;
}

/* When scrolling, remove overflow hidden to show scrolled text */
#pcbTable .pcb-scrollable-cell.scrolling-text .pcb-text-wrapper {
    overflow: visible;
    text-overflow: clip;
}

/* Inner text span that will scroll */
#pcbTable .pcb-text-inner {
    display: inline-block;
    white-space: nowrap;
    position: relative;
}

/* File items scrolling */
#pcbTable .pcb-files-cell {
    text-align: right;
}

#pcbTable .pcb-file-item {
    overflow: hidden;
    position: relative;
    white-space: nowrap;
    text-align: right;
}

#pcbTable .pcb-file-item.scrolling-text {
    overflow: visible;
    z-index: 10;
}

/* Variation tags cell styling */
#pcbTable .pcb-variation-tags-cell {
    white-space: normal;
    overflow: visible;
    padding: 8px 12px;
}

#pcbTable .pcb-variation-tags-cell .tag-badge-inline {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 4px 2px 0;
    background: #e0f2f7;
    border: 1px solid #2d8998;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
    color: #1e5661;
    white-space: nowrap;
}

#pcbTable .pcb-file-item .pcb-text-wrapper {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    transition: transform 0.1s linear;
    will-change: transform;
    position: relative;
    vertical-align: top;
}

#pcbTable .pcb-file-item.scrolling-text .pcb-text-wrapper {
    overflow: visible;
    text-overflow: clip;
}

#pcbTable .pcb-file-item .pcb-text-inner {
    display: inline-block;
    white-space: nowrap;
    position: relative;
}
