/**
 * Device Keys Panel Styles
 * Reuses existing styles from certificates.css and app.css
 */

/* Generate Key Modal - must appear above Device Keys popup */
#generateKeyModal {
    z-index: 10003 !important;
    /* Above Device Keys popup (10001) */
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow: hidden;
}

#generateKeyModal .modal-content {
    background-image: url("../../images/bg_noise.webp"), linear-gradient(180deg, var(--color-bg-gradient-top, #f8f8f7), var(--color-bg-gradient-bottom, #f1f0ee));
    background-position: 0 0, 0 0;
    background-size: auto, auto;
    border: 1px solid var(--color-border, #dddfe0);
    border-radius: 1.25rem;
    box-shadow: var(--shadow-md, 0 2px 8px rgba(0, 0, 0, 0.08));
    max-width: 1200px;
    margin: 5% auto;
    padding: 2rem;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 90vh;
    /* Hide scrollbar but keep scrolling functionality */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

/* FilterDropdown styles for inline selects in generate-key-modal */
#generateKeyModal .filter-group {
    padding: 0;
    border: 1px solid var(--color-border, #dddfe0);
    border-radius: 4px;
    background: var(--bg-input, #f8f9fa);
    overflow: visible;
    display: inline-block;
    min-width: 150px;
}

#generateKeyModal .filter-group label {
    display: none;
}

/* Prevent label clicks from affecting dropdown containers */
#generateKeyModal label[for="generateFlashEncryption"] #flashEncryptionChipContainer,
#generateKeyModal label[for="generateFlashEncryption"] #flashEncryptionBitsContainer,
#generateKeyModal label[for="generateSecureBoot"] #secureBootVersionContainer {
    pointer-events: auto;
    position: relative;
    z-index: 1;
}

/* Ensure dropdown containers and their children stop event propagation */
#generateKeyModal #flashEncryptionChipContainer *,
#generateKeyModal #flashEncryptionBitsContainer *,
#generateKeyModal #secureBootVersionContainer * {
    pointer-events: auto;
}

#generateKeyModal .modal-content::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

#generateKeyModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border, #dddfe0);
}

#generateKeyModal .modal-header h2 {
    margin: 0;
    color: var(--color-text-primary, #2c3e50);
    font-size: 24px;
    font-weight: 600;
}

#generateKeyModal .modal-body {
    color: var(--color-text-primary, #2c3e50);
    line-height: 1.6;
    overflow: visible;
    max-height: none;
    height: auto;
}

#generateKeyModal .modal-body h3 {
    color: var(--color-text-primary, #2c3e50);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

#generateKeyModal .modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border, #dddfe0);
}

#generateKeyModal .certificate-filters {
    padding: 20px;
    background: #f9fafb;
    border: 1px solid #dddfe0;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Match Product Dashboard filter styling */
#generateKeyModal .filter-group {
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 180px;
    background: white;
    border: 1px solid #dddfe0;
    border-radius: 8px;
    overflow: hidden;
}

/* FilterItemSelector component labels should match */
#generateKeyModal .filter-group .filter-label-row label {
    font-size: 11px;
    font-weight: 600;
    color: #2c3e50;
    padding: 4px 10px 4px 10px;
    background: white;
    margin: 0;
}

#generateKeyModal .table-wrapper {
    background: white;
    border-radius: var(--radius-md, 8px);
    overflow: visible;
}

#generateKeyModal .data-table {
    background: white;
}

#generateKeyModal .data-table thead {
    background: white;
}

#generateKeyModal .data-table tbody {
    background: white;
}

#generateKeyModal .data-table tr {
    background: white;
}

#generateKeyModal .filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
}

#generateKeyModal .filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: #2c3e50;
    padding: 4px 10px 4px 10px;
    background: white;
    margin: 0;
}

#generateKeyModal .filter-input {
    width: 100%;
    padding: 8px 12px;
    border-top: 1px solid #dddfe0;
    border-left: 0px;
    border-right: 0px;
    border-bottom: 0px;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    font-size: 12px;
    background: white;
    color: #2c3e50;
}

#generateKeyModal .filter-input:focus {
    outline: none;
    box-shadow: var(--shadow-focus-glow);
    border-color: transparent;
}

#generateKeyModal label[for^="generate"] {
    padding: 8px 12px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

#generateKeyModal label[for^="generate"]:hover {
    background: var(--color-bg-hover, #f0f7ff);
}

/* Generate Key Modal checkbox styling matching theme */
#generateKeyModal 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;
}

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

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

#generateKeyModal input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

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

#generateKeyModal 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);
}

#generateKeyModal select {
    background: white;
    color: var(--color-text-primary, #2c3e50);
}

#generateKeyModal select:disabled {
    background: var(--color-bg-input-disabled, #ecf0f1);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Dark mode support for Generate Key Modal */
@media (prefers-color-scheme: dark) {
    #generateKeyModal .modal-content {
        background: #1a1d20;
        border-color: rgba(255, 255, 255, 0.12);
    }

    #generateKeyModal .modal-header {
        border-bottom-color: rgba(255, 255, 255, 0.12);
    }

    #generateKeyModal .modal-header h2 {
        color: #e5e7eb;
    }

    #generateKeyModal .modal-body {
        color: #e5e7eb;
    }

    #generateKeyModal .modal-body h3 {
        color: #e5e7eb;
    }

    #generateKeyModal .modal-footer {
        border-top-color: rgba(255, 255, 255, 0.12);
    }

    #generateKeyModal .certificate-filters {
        background: #0f1113;
        border-color: rgba(255, 255, 255, 0.12);
    }

    #generateKeyModal .filter-input {
        background: #1a1d20;
        border-color: rgba(255, 255, 255, 0.12);
        color: #e5e7eb;
    }

    #generateKeyModal .filter-input:focus {
        box-shadow: var(--shadow-focus-glow);
        border-color: transparent;
    }

    #generateKeyModal label[for^="generate"]:hover {
        background: rgba(45, 137, 152, 0.1);
    }

    #generateKeyModal select {
        background: #1a1d20;
        color: #e5e7eb;
        border-color: rgba(255, 255, 255, 0.12);
    }

    #generateKeyModal select:disabled {
        background: #0f1113;
    }
}

/* Device Keys Popup - reuse certificates popup styles */
#deviceKeysPopup {
    /* CSS Variables (scoped to popup) */
    --color-primary: #2d8998;
    --color-primary-dark: #246b78;
    --color-primary-light: #e3f2fd;
    --color-success: #4caf50;
    --color-error: #e74c3c;
    --color-warning: #f57f17;
    --color-info: #2196f3;
    --color-text-primary: #2c3e50;
    --color-text-secondary: #34495e;
    --color-text-muted: #7f8c8d;
    --bg-card: #ffffff;
    --bg-input: #f8f9fa;
    --bg-hover: #f0f7ff;
    --border-light: #e8ecef;
    --border-medium: #b0bec5;
    --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);
    --radius-md: 8px;
    --radius-lg: 10px;

    /* Popup backdrop styles */
    display: none;
    position: fixed;
    z-index: 10001 !important;
    /* Above dropdowns (10000) and menu panel (500) */
    isolation: isolate;
    /* Create new stacking context */
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow-y: auto;
    overflow-x: hidden;
    align-items: center;
    justify-content: center;
}

#deviceKeysPopup.show {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    /* Temporary: Add bright background to verify visibility */
    background: rgba(0, 0, 0, 0.35) !important;
}

#deviceKeysPopup .popup-content {
    width: min(100%, 1400px);
    margin: 2rem auto;
    padding: 0 1rem 2rem 1rem;
    max-height: calc(100vh - 4rem);
    position: relative;
    z-index: 1;
}

#deviceKeysPopup .upload-form {
    border: 1px solid var(--color-border, #dddfe0);
    border-radius: 1.25rem;
    background-image: url("../../images/bg_noise.webp"), linear-gradient(180deg, var(--color-bg-gradient-top, #f8f8f7), var(--color-bg-gradient-bottom, #f1f0ee));
    background-position: 0 0, 0 0;
    background-size: auto, auto;
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

#deviceKeysPopup .certificates-container {
    width: 100%;
}

#deviceKeysPopup .table-wrapper {
    overflow: auto;
    border: 1px solid var(--color-border, #dddfe0);
    border-radius: var(--radius-xl, 12px);
    max-width: 100%;
    background: white;
}

#deviceKeysPopup .data-table {
    background: white;
    width: 100%;
    border-collapse: collapse;
}

#deviceKeysPopup .data-table thead {
    background: var(--bg-input, #f8f9fa);
    border-bottom: 2px solid var(--border-light, #e8ecef);
}

#deviceKeysPopup .data-table tbody {
    background: white;
}

#deviceKeysPopup .data-table tbody tr {
    background: white;
}

#deviceKeysPopup .data-table tbody tr:hover {
    background: var(--bg-hover, #f0f7ff);
}

#deviceKeysPopup .data-table tbody tr.device-key-row:hover {
    background: var(--bg-hover, #f0f7ff);
    cursor: pointer;
}

#deviceKeysPopup .data-table td {
    background: inherit;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light, #e8ecef);
    color: var(--color-text-primary, #2c3e50);
    font-size: 13px;
    line-height: 1.4;
}

#deviceKeysPopup .data-table th {
    background: var(--bg-input, #f8f9fa);
    padding: 8px 16px;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    color: var(--color-text-primary, #2c3e50);
    white-space: nowrap;
    border-bottom: 2px solid var(--border-light, #e8ecef);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Checkbox styling matching theme */
#deviceKeysPopup .data-table input[type="checkbox"],
#deviceKeysPopup .device-key-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 2px solid var(--border-light, #e8ecef);
    border-radius: 4px;
    background-color: white;
    position: relative;
    transition: all 0.2s ease;
}

#deviceKeysPopup .data-table input[type="checkbox"]:hover,
#deviceKeysPopup .device-key-checkbox:hover {
    border-color: var(--color-primary, #2d8998);
    background-color: var(--bg-hover, #f0f7ff);
}

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

#deviceKeysPopup .data-table input[type="checkbox"]:checked::after,
#deviceKeysPopup .device-key-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

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

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

/* Certificate Filters Section - Match Certificates Dashboard */
#deviceKeysPopup .certificate-filters {
    padding: 20px;
    background: #f9fafb;
    border-bottom: 1px solid #dddfe0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        border-bottom-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom-color: transparent;
    margin-bottom: 0;
}

#deviceKeysPopup .certificate-filters.visible {
    max-height: 2000px;
    opacity: 1;
    padding-top: 20px;
    padding-bottom: 20px;
    border-bottom-color: #dddfe0;
}

#deviceKeysPopup .filters-row {
    display: flex;
    gap: 5px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: stretch;
}

#deviceKeysPopup .filters-row:last-child {
    margin-bottom: 0;
}

/* Column group for stacking filters vertically */
#deviceKeysPopup .filter-column-group {
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: stretch;
    min-width: 220px;
    width: 220px;
    height: 100%;
    justify-content: space-between;
}

#deviceKeysPopup .filter-column-group>.filter-group,
#deviceKeysPopup .filter-column-group>div>.filter-group {
    flex-shrink: 0;
    width: 100%;
    min-width: 0;
}

/* Fine-tune filter group heights in column 2 */
#deviceKeysPopup .filter-column-group>.filter-group {
    min-height: 60px;
}

#deviceKeysPopup .filter-column-group #filterDeviceKeyGeneratedDateContainer {
    flex: 0 0 auto;
    width: 100% !important;
    min-width: 0;
}

#deviceKeysPopup .filter-column-group #filterDeviceKeyGeneratedDateContainer .filter-group {
    min-height: 60px;
    width: 100% !important;
    min-width: 0;
}

/* Make Device Type filter container match height of filter-column-group */
#deviceKeysPopup #filterDeviceKeyProductTypeContainer {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 180px;
    width: auto;
    max-width: 200px;
}

#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-group {
    height: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Make FilterItemSelector multiselect area expand to fill available height */
#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-multiselect {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 2px;
}

/* Match Product Dashboard scrollbar styling */
#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-multiselect::-webkit-scrollbar {
    width: 8px;
}

#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-multiselect::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-multiselect::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-multiselect::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Match Product Dashboard filter search box styling */
#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-search-box {
    padding: 3px 12px;
    border: none;
    border-top: 1px solid #dddfe0;
    border-bottom: 1px solid #dddfe0;
    border-radius: 0;
    font-size: 11px;
    background: white;
    width: 100%;
}

#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-search-box:focus {
    outline: none;
    box-shadow: var(--shadow-focus-glow);
    border-color: transparent;
    position: relative;
    z-index: 1;
}

/* Match Product Dashboard filter option styling */
#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-option {
    display: flex;
    align-items: center;
    padding: 1px 5px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s, color 0.15s;
    font-size: 11px;
    line-height: 1.4;
    color: #4a5568;
    user-select: none;
    position: relative;
}

#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-option:hover {
    background: #f3f4f6;
}

#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-option.selected {
    background: #f0f7ff;
    color: black;
    font-weight: 500;
    border: 1px solid #dddfe0;
}

#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-option.selected:hover {
    background: #cbd5df;
}

#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-option.drag-hover {
    background: #d6ebf5;
    border: 1px solid #2d8998;
    color: black;
    font-weight: 500;
}

#deviceKeysPopup #filterDeviceKeyProductTypeContainer .filter-option label {
    cursor: pointer;
    margin: 0;
    padding: 0;
    font-size: 11px;
    font-weight: inherit;
    color: inherit;
    background: transparent;
    flex: 1;
    pointer-events: none;
}

#deviceKeysPopup .filter-group {
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 180px;
    background: white;
    border: 1px solid #dddfe0;
    border-radius: 8px;
    overflow: hidden;
}

/* Ensure filter groups in column 2 match width */
#deviceKeysPopup .filter-column-group .filter-group {
    width: 100% !important;
    min-width: 0;
}

/* Override FilterDatePicker inline styles to match column width */
#deviceKeysPopup .filter-column-group #filterDeviceKeyGeneratedDateContainer[style*="width"] {
    width: 100% !important;
    max-width: 100% !important;
}

/* Override inline width style on filter-group created by FilterDatePicker */
#deviceKeysPopup .filter-column-group #filterDeviceKeyGeneratedDateContainer .filter-group[style*="width"] {
    width: 100% !important;
    max-width: 100% !important;
}

#deviceKeysPopup .filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: #2c3e50;
    padding: 4px 10px 4px 10px;
    background: white;
    margin: 0;
}

#deviceKeysPopup .filter-group .filter-label-row label {
    font-size: 11px;
    font-weight: 600;
    color: #2c3e50;
    padding: 4px 10px 4px 10px;
    background: white;
    margin: 0;
}

#deviceKeysPopup .filter-input {
    padding: 6px 12px;
    border-top: 1px solid #dddfe0;
    border-left: 0px;
    border-right: 0px;
    border-bottom: 0px;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    font-size: 12px;
    background: white;
    width: 100%;
    color: #2c3e50;
    min-height: 36px;
    box-sizing: border-box;
}

#deviceKeysPopup .filter-input:focus {
    outline: none;
    box-shadow: var(--shadow-focus-glow);
    border-color: transparent;
}

/* Table Header - Match Certificates Dashboard */
#deviceKeysPopup .table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

#deviceKeysPopup .table-header .filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

/* Filter Buttons - Match Certificates Dashboard */
#deviceKeysPopup .filter-more-btn {
    padding: 8px 16px;
    border: 1px solid #dddfe0;
    border-radius: 6px;
    background: white;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #2c3e50;
}

#deviceKeysPopup .filter-more-btn:hover {
    background: #f3f4f6;
}

#deviceKeysPopup .filter-clear-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: #e5e7eb;
    color: #4a4a4a;
}

#deviceKeysPopup .filter-clear-btn:hover {
    background: #d1d5db;
}

#deviceKeysPopup .active-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#deviceKeysPopup .active-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--color-primary-light);
    color: var(--color-primary-darker);
    border-radius: 12px;
    font-size: 12px;
    margin-right: 8px;
    margin-bottom: 4px;
}

#deviceKeysPopup .active-filter-pill .remove-filter {
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

#deviceKeysPopup .active-filter-pill .remove-filter:hover {
    opacity: 1;
}

/* Table Footer - Match Certificates Dashboard */
#deviceKeysPopup .table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

#deviceKeysPopup .table-footer .table-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#deviceKeysPopup .table-footer-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#deviceKeysPopup .certificates-count-display {
    font-size: 12px;
    color: #7f8c8d;
    font-weight: 500;
}

#deviceKeysPopup .submit-btn.add-btn {
    padding: 10px 20px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#deviceKeysPopup .submit-btn.add-btn:hover {
    background: var(--color-primary-dark);
}

/* Key badges */
.key-badge {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 4px 2px 0;
    background: var(--color-primary-light);
    color: var(--color-primary-darker);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

/* Table row selection */
.data-table tr.selected {
    background: var(--color-bg-hover);
}

.data-table tr.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.data-table tr.disabled td {
    pointer-events: none;
}

/* Pagination styles */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    margin-top: 12px;
}

.pagination-btn {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--color-bg-hover);
    border-color: var(--color-primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.pagination-ellipsis {
    padding: 0 8px;
    color: var(--color-text-muted);
}

/* Active filter pills */
.active-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--color-primary-light);
    color: var(--color-primary-darker);
    border-radius: 12px;
    font-size: 12px;
    margin-right: 8px;
    margin-bottom: 4px;
}

.active-filter-pill .remove-filter {
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.active-filter-pill .remove-filter:hover {
    opacity: 1;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .key-badge {
        background: rgba(45, 137, 152, 0.2);
        color: #4fb3c5;
    }

    .pagination-btn {
        background: #1a1d20;
        border-color: rgba(255, 255, 255, 0.12);
        color: #e5e7eb;
    }

    .pagination-btn:hover:not(:disabled) {
        background: #2a2d30;
        border-color: #2d8998;
    }

    .pagination-btn.active {
        background: #2d8998;
        color: white;
    }

    .active-filter-pill {
        background: rgba(45, 137, 152, 0.2);
        color: #4fb3c5;
    }
}

/* ============================================
   Key Generation Options Styles
   ============================================ */

.key-gen-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.key-gen-section {
    background: white;
    border: 1px solid var(--color-border, #dddfe0);
    border-radius: 8px;
    overflow: hidden;
}

.key-gen-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-input, #f8f9fa);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.key-gen-header:has(.key-gen-checkbox:checked) {
    border-bottom-color: var(--color-border, #dddfe0);
}

.key-gen-checkbox {
    flex-shrink: 0;
}

.key-gen-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-primary, #2c3e50);
    cursor: pointer;
    user-select: none;
}

.key-gen-title:hover {
    color: var(--color-primary, #2d8998);
}

.key-gen-body {
    padding: 16px;
    background: white;
}

.key-gen-mode-selector {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.key-gen-mode-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 16px;
    border: 1px solid var(--color-border, #dddfe0);
    border-radius: 6px;
    background: white;
    transition: all 0.2s ease;
    font-size: 13px;
    color: var(--color-text-primary, #2c3e50);
}

.key-gen-mode-option:hover {
    border-color: var(--color-primary, #2d8998);
    background: var(--color-bg-hover, #f0f7ff);
}

.key-gen-mode-option:has(input:checked) {
    border-color: var(--color-primary, #2d8998);
    background: var(--color-primary-light, #e3f2fd);
    color: var(--color-primary-darker, #1a5c67);
}

.key-gen-mode-option input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--color-primary, #2d8998);
}

.key-gen-manual-input {
    margin-top: 12px;
}

.key-gen-text-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border, #dddfe0);
    border-radius: 6px;
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: white;
    color: var(--color-text-primary, #2c3e50);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.key-gen-text-input:focus {
    outline: none;
    border-color: var(--color-primary, #2d8998);
    box-shadow: var(--shadow-focus-glow);
}

.key-gen-text-input.invalid {
    border-color: var(--color-error, #e74c3c);
}

.key-gen-text-input.valid {
    border-color: var(--color-success, #4caf50);
}

.key-gen-input-hint {
    margin-top: 6px;
    font-size: 11px;
    color: var(--color-text-muted, #7f8c8d);
}

.key-gen-input-hint.error {
    color: var(--color-error, #e74c3c);
}

.key-gen-input-hint.success {
    color: var(--color-success, #4caf50);
}

.key-gen-dropdowns {
    margin-top: 0;
}

.key-gen-dropdown-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.key-gen-dropdown-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

.key-gen-dropdown-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted, #7f8c8d);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.key-gen-upload {
    margin-top: 0;
}

.key-gen-file-input {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.key-gen-upload-btn {
    padding: 10px 20px;
    background: var(--color-primary, #2d8998);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.key-gen-upload-btn:hover {
    background: var(--color-primary-dark, #246b78);
}

.key-gen-file-name {
    font-size: 13px;
    color: var(--color-text-muted, #7f8c8d);
    font-style: italic;
}

.key-gen-file-name.has-file {
    color: var(--color-success, #4caf50);
    font-style: normal;
    font-weight: 500;
}

.key-gen-file-info {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-input, #f8f9fa);
    border-radius: 6px;
    font-size: 12px;
    color: var(--color-text-secondary, #34495e);
}

.key-gen-file-info .info-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.key-gen-file-info .info-row:last-child {
    margin-bottom: 0;
}

.key-gen-file-info .info-label {
    font-weight: 600;
    color: var(--color-text-muted, #7f8c8d);
    min-width: 80px;
}

.key-gen-file-info .info-value {
    color: var(--color-text-primary, #2c3e50);
    word-break: break-all;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 11px;
}

.key-gen-file-info.error {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--color-error, #e74c3c);
}

.key-gen-file-info.success {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid var(--color-success, #4caf50);
}

/* Dark mode for Key Generation Options */
@media (prefers-color-scheme: dark) {
    .key-gen-section {
        background: #1a1d20;
        border-color: rgba(255, 255, 255, 0.12);
    }

    .key-gen-header {
        background: #0f1113;
    }

    .key-gen-title {
        color: #e5e7eb;
    }

    .key-gen-body {
        background: #1a1d20;
    }

    .key-gen-mode-option {
        background: #1a1d20;
        border-color: rgba(255, 255, 255, 0.12);
        color: #e5e7eb;
    }

    .key-gen-mode-option:hover {
        border-color: #2d8998;
        background: rgba(45, 137, 152, 0.1);
    }

    .key-gen-mode-option:has(input:checked) {
        background: rgba(45, 137, 152, 0.2);
        border-color: #2d8998;
        color: #4fb3c5;
    }

    .key-gen-text-input {
        background: #0f1113;
        border-color: rgba(255, 255, 255, 0.12);
        color: #e5e7eb;
    }

    .key-gen-text-input:focus {
        border-color: #2d8998;
    }

    .key-gen-file-info {
        background: #0f1113;
        color: #b0b8c0;
    }

    .key-gen-file-info .info-value {
        color: #e5e7eb;
    }
}

/* ============================================
   Device Key Details Modal Styles
   ============================================ */

/* Modal container with flexbox layout */
.device-key-details-modal {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 4rem);
    max-width: 900px;
    width: 90%;
}

.device-key-details-modal .modal-header {
    flex-shrink: 0;
}

.device-key-details-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    max-height: none;
}

.device-key-details-modal .modal-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 2rem;
    background: var(--bg-input, #f8f9fa);
    border-top: 1px solid var(--color-border, #dddfe0);
    border-radius: 0 0 1.25rem 1.25rem;
}

.device-key-details-modal .modal-footer:empty {
    display: none;
}

.device-key-details-modal .modal-footer .modal-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.device-key-details-modal .modal-footer .modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.device-key-details-modal .modal-footer .modal-btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

/* Dark mode for Device Key Details Modal */
@media (prefers-color-scheme: dark) {
    .device-key-details-modal .modal-footer {
        background: #0f1113;
        border-top-color: rgba(255, 255, 255, 0.12);
    }
}