/**
 * Telemetry Panel Stylesheet
 */

/* Clickable table rows */
.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-row:hover {
    background-color: var(--bg-hover, #f0f7ff) !important;
}

.clickable-row:active {
    background-color: var(--border-light, #e8ecef) !important;
}

/* Prevent body scroll when popup is open */
body.popup-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
}

/* CSS Variables */
:root {
    --telemetry-color-primary: #2d8998;
    --telemetry-color-primary-dark: #246b78;
    --telemetry-color-primary-light: #e3f2fd;
    --telemetry-color-success: #4caf50;
    --telemetry-color-error: #e74c3c;
    --telemetry-color-warning: #f57f17;
    --telemetry-color-info: #2196f3;
    --telemetry-color-text-primary: #2c3e50;
    --telemetry-color-text-secondary: #34495e;
    --telemetry-color-text-muted: #7f8c8d;
    --telemetry-bg-card: #ffffff;
    --telemetry-bg-input: #f8f9fa;
    --telemetry-bg-hover: #f0f7ff;
    --telemetry-border-light: #e8ecef;
    --telemetry-border-medium: #b0bec5;
    --telemetry-border-focus: #36a4b5;
    --telemetry-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --telemetry-shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --telemetry-shadow-lg: 0 6px 20px rgba(30, 136, 229, 0.4);
    --telemetry-radius-sm: 6px;
    --telemetry-radius-md: 8px;
    --telemetry-radius-lg: 10px;
}

/* ==================== TELEMETRY MANAGEMENT MODAL ==================== */
/* Telemetry Management Modal - Full Screen from Right */
#telemetryManagementModal {
    display: none;
    position: fixed;
    z-index: 5000 !important;
    /* Below other modals (6000+) so they can overlay it, but above menu (100) */
    top: var(--top-bar-height, 70px);
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(100vh - var(--top-bar-height, 70px));
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    align-items: stretch;
    justify-content: flex-end;
    overflow: hidden;
    padding: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease, left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    isolation: isolate;
    /* Create new stacking context */
}

/* When menu panel is open, shift entire modal to start after menu */
body.menu-open #telemetryManagementModal {
    left: 200px;
    /* Width of menu panel */
}

#telemetryManagementModal[style*="flex"] {
    display: flex;
    pointer-events: auto;
    /* Enable clicks when modal is open */
    opacity: 1;
    z-index: 5000 !important;
    /* Ensure it stays below other modals (6000+) */
}

/* Ensure Telemetry Management stays below other modals when they're open */
body.popup-open #telemetryManagementModal,
.users-modal-overlay.active~#telemetryManagementModal,
#certificatesPopup.show~#telemetryManagementModal,
#deviceKeysPopup.show~#telemetryManagementModal,
#variationsPopup.show~#telemetryManagementModal,
#customersPopup.show~#telemetryManagementModal,
#deviceTypesPopup.show~#telemetryManagementModal {
    z-index: 5000 !important;
    /* Stay below other modals */
}

#telemetryManagementModal .modal-container {
    background-image: url("../../images/bg_noise.webp"), linear-gradient(180deg, #f8f8f7, #f1f0ee);
    background-position: 0 0, 0 0;
    background-size: auto, auto;
    border-radius: 0;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    width: 100%;
    /* Always 100% of parent modal width */
    max-width: 100%;
    height: 100%;
    margin: 0;
    /* No margin needed - parent modal shifts instead */
    border: none;
    border-left: 1px solid #dddfe0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1 !important;
    /* Ensure it doesn't create a higher stacking context */
    pointer-events: auto;
    /* Ensure container is clickable */
    /* Start off-screen to the right, animate in like info panel */
    right: -100%;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* Override generic modal-container opacity from other CSS files */
    opacity: 1 !important;
    transform: none !important;
}

#telemetryManagementModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #dddfe0;
    flex-shrink: 0;
    background: white;
    gap: 1rem;
    border-top-right-radius: 0 !important;
    border-top-left-radius: 0 !important ;    
}

#telemetryManagementModal .modal-header h2 {
    color: #2c3e50 !important;
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

#telemetryManagementModal .modal-header .modal-btn-cancel {
    width: auto;
    padding: 8px 16px;
    background: white;
    color: #2c3e50;
    border: 1px solid #dddfe0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

#telemetryManagementModal .modal-header .modal-btn-cancel:hover {
    background: #f8f9fa;
    border-color: #b0bec5;
}

#telemetryManagementModal .modal-body {
    padding: 0.75rem 1.5rem 1.5rem 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    background-image: url("../../images/bg_noise.webp"), linear-gradient(180deg, #f8f8f7, #f1f0ee);
    background-position: 0 0, 0 0;
    background-size: auto, auto;
}

.telemetry-popup .popup-content {
    padding: 0;
    max-width: 100%;
}

.telemetry-popup .upload-form {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0;
    box-shadow: none;
}

/* Popup Header - now handled by modal-header */

/* Sections */
.telemetry-section {
    background: #ffffff;
    border: 1px solid #dddfe0;
    border-radius: 1.25rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.telemetry-section {
    margin-top: 0;
    padding-left: 1rem;
    padding-right: 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    transition: border-bottom 0.3s ease;
}

.section-header.no-border {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
    cursor: pointer;
}

.section-header.no-border:hover {
    opacity: 0.8;
}

.section-title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.section-count {
    font-size: 0.875rem;
    font-weight: 400;
    color: #9ca3af;
    margin-left: auto;
    margin-right: 0.5rem;
    text-align: right;
    flex-shrink: 0;
}

.section-collapse-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.section-collapse-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.collapse-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
    transform: rotate(0deg);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-icon {
    width: 20px;
    height: 20px;
}

.section-content {
    position: relative;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease;
    overflow: hidden;
    max-height: 5000px;
    opacity: 1;
}

.section-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.section-footer {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: flex-start;
    gap: 0.75rem;
}

.section-actions {
    display: flex;
    gap: 0.75rem;
}

/* Action Buttons */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

.add-btn {
    background: var(--color-primary);
    color: white;
}

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

.simple-monitor-btn,
.graph-monitor-btn {
    background: #ecf0f1;
    color: #555;
    border: none;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    height: 32px;
    box-sizing: border-box;
    gap: 6px;
}

.simple-monitor-btn:hover,
.graph-monitor-btn:hover {
    background: #bdc3c7;
    color: #555;
}

/* Remove button - matches main page style */
.remove-btn {
    background: #ecf0f1;
    color: #555;
    border: none;
    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;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: var(--radius-sm);
}

.remove-btn:hover {
    background: #bdc3c7;
    color: #555;
}

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

.delete-btn {
    background: var(--color-error);
    color: white;
}

.delete-btn:hover {
    background: #c0392b;
}

/* Filter Area */
.filter-area {
    margin-top: 0.5rem;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem;
}

.filter-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.filter-select,
.filter-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: white;
    transition: border-color 0.2s;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--border-focus);
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

/* Table Header (matches Product Dashboard style) */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    padding: 0;
}

.table-header .filters {
    flex: 1;
    min-width: 0;
}

/* Filter Buttons Row */
.filter-buttons-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

/* Filter More Button (matches Product Dashboard style) */
.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;
    height: 32px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #2c3e50;
}

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

/* Active Filters Container */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    flex: 1;
}

/* Filter Badges (matches Product Dashboard style) */
.filter-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #e6f4fa;
    border: 1px solid #3d7b8f;
    border-radius: 4px;
    font-size: 11px;
    color: #3d7b8f;
    font-weight: 600;
    cursor: default;
}

.filter-badge .badge-remove {
    cursor: pointer;
    font-weight: bold;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    margin-left: 4px;
    font-size: 12px;
    line-height: 1;
    border: none;
}

.filter-badge .badge-remove:hover {
    opacity: 1;
}

/* Filters Row */
.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.filter-apply-btn,
.filter-clear-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-apply-btn {
    background: var(--color-primary);
    color: white;
}

.filter-apply-btn:hover {
    background: var(--color-primary-dark);
}

.filter-clear-btn {
    background: white;
    color: var(--color-text-secondary);
    border: 1px solid var(--border-medium);
}

.filter-clear-btn:hover {
    background: var(--bg-input);
}

/* Table - Scoped to Telemetry Management Modal only */
#telemetryManagementModal .table-wrapper {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #ffffff;
    max-height: 450px;
    overflow-y: auto;
}

#telemetryManagementModal .data-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

#telemetryManagementModal .data-table thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

#telemetryManagementModal .data-table th {
    padding: 4px 8px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: #34495e;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

#telemetryManagementModal .data-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s;
}

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

#telemetryManagementModal .data-table td {
    padding: 4px 8px;
    font-size: 0.7rem;
    color: #2c3e50;
    line-height: 1.2;
    vertical-align: middle;
}

#telemetryManagementModal .checkbox-cell {
    width: 40px;
    text-align: center;
}

#telemetryManagementModal .checkbox-cell input[type="checkbox"] {
    cursor: pointer;
    width: 12px;
    height: 12px;
}

#telemetryManagementModal .data-table td.actions-cell {
    padding: 4px 8px;
    vertical-align: middle;
    line-height: 1.2;
    text-align: right;
    white-space: nowrap;
    box-sizing: border-box;
    display: table-cell;
}


#telemetryManagementModal .data-table td.actions-cell .icon-btn {
    margin-left: 0.25rem;
    box-sizing: border-box;
}

#telemetryManagementModal .data-table td.actions-cell .icon-btn:first-child {
    margin-left: 0;
}

#telemetryManagementModal .icon-btn {
    background: transparent;
    border: 1px solid var(--border-medium);
    border-radius: 4px;
    padding: 0.15rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    vertical-align: baseline;
    line-height: 1;
    box-sizing: border-box;
    margin: 0;
}

#telemetryManagementModal .icon-btn svg {
    width: 12px;
    height: 12px;
    stroke: var(--color-text-secondary);
}

#telemetryManagementModal .icon-btn:hover {
    background: var(--bg-input);
    border-color: var(--color-primary);
}

#telemetryManagementModal .icon-btn:hover svg {
    stroke: var(--color-primary);
}

#telemetryManagementModal .edit-btn:hover {
    border-color: var(--color-info);
}

#telemetryManagementModal .edit-btn:hover svg {
    stroke: var(--color-info);
}

#telemetryManagementModal .copy-btn:hover {
    border-color: var(--color-warning);
}

#telemetryManagementModal .copy-btn:hover svg {
    stroke: var(--color-warning);
}

/* Status Badges - Scoped to Telemetry Management Modal */
#telemetryManagementModal .status-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1.1;
}

.status-enabled {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-disabled {
    background: #ffebee;
    color: #c62828;
}

/* Empty/Loading/Error States */
.loading-cell,
.empty-cell,
.error-cell {
    text-align: center;
    padding: 40px;
    color: var(--color-text-muted);
}

.error-cell {
    color: var(--color-error);
}

/* Parameter/Assignment Modal Styles */
.parameter-modal-overlay,
.assignment-modal-overlay {
    display: none;
    position: fixed;
    z-index: 7000;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
}

.parameter-modal-overlay.show,
.assignment-modal-overlay.show {
    display: flex;
}

.parameter-modal,
.assignment-modal {
    background-image: url("../../images/bg_noise.webp"), linear-gradient(180deg, #f8f8f7, #f1f0ee);
    background-position: 0 0, 0 0;
    background-size: auto, auto;
    border-radius: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    max-width: 90%;
    width: 700px;
    margin: 2rem auto;
    animation: modalSlideIn 0.3s ease-out;
    border: 1px solid #dddfe0;
    max-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Hide overflow but dropdown will use position:fixed to escape */
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.parameter-modal-header,
.assignment-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem 1rem 2rem;
    border-bottom: none;
    background: white;
    border-bottom: 1px solid #dddfe0;
}

.parameter-modal-header h3,
.assignment-modal-header h3 {
    color: #2c3e50;
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

.parameter-modal-close,
.assignment-modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s;
}

.parameter-modal-close:hover,
.assignment-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.parameter-modal-close svg,
.assignment-modal-close svg {
    width: 20px;
    height: 20px;
    stroke: var(--color-text-secondary);
}

.parameter-modal-body,
.assignment-modal-body {
    padding: 1rem 2rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    max-height: calc(100vh - 300px);
    min-height: 0;
    z-index: 1;
}

.parameter-modal-footer,
.assignment-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 2rem 1.5rem 2rem;
    border-top: none;
    background: white;
    border-top: 1px solid #dddfe0;
}

/* Form - matching variations form style */
.variation-edit-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-row {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Ensure FilterDropdown is visible in form-row */
.form-row #modalDeviceTypeContainer,
.form-row #modalFirmwareContainer {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    min-height: 50px;
}

.form-row #modalDeviceTypeContainer .filter-group,
.form-row #modalFirmwareContainer .filter-group {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
}

.form-row #modalDeviceTypeContainer .filter-dropdown-wrapper,
.form-row #modalFirmwareContainer .filter-dropdown-wrapper {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.form-row #modalDeviceTypeContainer .filter-dropdown-trigger,
.form-row #modalFirmwareContainer .filter-dropdown-trigger {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.form-row #modalDeviceTypeContainer .filter-dropdown-input,
.form-row #modalFirmwareContainer .filter-dropdown-input {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.form-row label {
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
}

.form-row .form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #b0bec5;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.2s;
}

.form-row .form-input:focus {
    outline: none;
    border-color: #36a4b5;
}

.form-row .form-input::placeholder {
    color: #95a5a6;
}

/* Units input with datalist - constrain dropdown height */
.form-row .input-container {
    position: relative;
    max-height: none;
}

/* Ensure datalist dropdown doesn't exceed modal bounds */
.form-row input[list] {
    position: relative;
    z-index: 1;
}

/* Constrain datalist dropdown positioning */
.form-row .input-container {
    position: relative;
    z-index: 1;
}

/* Ensure dropdowns can escape modal bounds */
.parameter-modal-overlay,
.assignment-modal-overlay {
    overflow: visible !important;
}

.parameter-modal-body,
.assignment-modal-body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: calc(100vh - 200px) !important;
}

/* Constrain datalist dropdown to modal bounds */
.parameter-modal-body input[list],
.assignment-modal-body input[list] {
    max-width: 100%;
}

/* Constrain the form to modal height */
.variation-edit-form {
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Ensure input container for units doesn't cause overflow */
#parameterModal .form-row .input-container:has(input[list="paramUnitsList"]) {
    max-height: calc(100vh - 500px);
    overflow-y: visible;
    overflow-x: hidden;
}

/* Parameter Info View (read-only, shown after successful save) */
.parameter-info-view {
    padding: 1rem 0;
}

.info-success-badge {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #e8f5e9;
    border: 1px solid #4caf50;
    border-radius: 8px;
    color: #2e7d32;
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 1.5rem;
}

.info-success-badge svg {
    stroke: #2e7d32;
}

.info-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.25rem;
}

.info-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.info-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-label {
    font-weight: 600;
    color: #34495e;
    font-size: 14px;
    min-width: 160px;
    flex-shrink: 0;
}

.info-value {
    color: #2c3e50;
    font-size: 14px;
    flex: 1;
    word-break: break-word;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    color: #2c3e50;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-error {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #ffebee;
    border: 1px solid #ef5350;
    border-radius: 6px;
    color: #c62828;
    font-size: 13px;
}

/* Modal Buttons - matching variations style */
.btn-cancel,
.btn-save {
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-cancel {
    background: white;
    color: #34495e;
    border: 1px solid #b0bec5;
}

.btn-cancel:hover {
    background: #f8f9fa;
    border-color: #2d8998;
}

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

.btn-save:hover {
    background: #246b78;
}

.btn-save-monitor {
    background: #2d8998;
    color: white;
}

.btn-save-monitor:hover {
    background: #246b78;
}

/* Tag system styles - matching variations exactly */
/* Remove border from input-container when it contains tag-input-wrapper */
#parameterModal .form-row .input-container:has(.tag-input-wrapper) {
    border: 1px solid #dddfe0;
    background: white;
    background-color: white;
    padding: 5px;
    border-radius: 8px;
}

#parameterModal .tag-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0;
}

.tag-suggestion {
    display: inline-block;
    padding: 6px 12px;
    background: #e0f2f7;
    border: 1px solid #2d8998;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: #1e5661;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.tag-suggestion:hover {
    background: #c8e6f0;
    border-color: #246b78;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(45, 137, 152, 0.2);
}

.tag-suggestion:active {
    transform: translateY(0);
}

/* Tag input wrapper - now inside input-container */
/* Style to match filter-dropdown-trigger but without dropdown arrow */
#parameterModal .input-container .tag-input-wrapper {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid #dddfe0;
    border-radius: 8px;
    background: white;
    background-color: white;
    min-height: 32px;
    transition: border-color 0.2s ease;
    cursor: text;
}

#parameterModal .input-container .tag-input-wrapper:hover {
    border-color: #2d8998;
}

#parameterModal .input-container .tag-input-wrapper:focus-within {
    border-color: transparent;
    box-shadow: var(--shadow-focus-glow);
    outline: none;
    background: white;
    background-color: white;
}

/* Tag suggestions inside input-container */
#parameterModal .input-container .tag-suggestions {
    padding: 12px;
    background: white;
    background-color: white;
}

.tag-bubbles-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.tag-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #e0f2f7;
    border: 1px solid #2d8998;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: #1e5661;
    white-space: nowrap;
}

.tag-bubble-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 2px;
    border-radius: var(--radius-sm, 6px);
    background: transparent;
    color: #2d8998;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.tag-bubble-remove:hover {
    background: rgba(45, 137, 152, 0.2);
    color: #1e5661;
}

#parameterModal .input-container .tag-input-wrapper #paramTagsInput {
    flex: 1;
    min-width: 150px;
    margin: 5px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    background: transparent;
    background-color: transparent;
    outline: none;
    font-size: 11px;
    border-radius: 0;
    color: #4a5568;
    line-height: 1.4;
}

#parameterModal .input-container .tag-input-wrapper #paramTagsInput:focus {
    box-shadow: none;
    background: transparent;
    background-color: transparent;
}

#parameterModal .input-container .tag-input-wrapper #paramTagsInput::placeholder {
    color: #9ca3af;
}

.hint {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .telemetry-popup .popup-content {
        padding: 1rem;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .section-actions {
        width: 100%;
    }

    .action-btn {
        flex: 1;
        justify-content: center;
    }
}

/* ==================== GROUP ROWS ==================== */
/* Group row styling for Device Assignments table */
#telemetryManagementModal .data-table tbody tr.group-row {
    background-color: #f8f9fa;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid #e5e7eb;
}

#telemetryManagementModal .data-table tbody tr.group-row:hover {
    background-color: #e9ecef;
}

#telemetryManagementModal .data-table tbody tr.group-row.collapsed {
    background-color: #f8f9fa;
}

/* Child row styling */
#telemetryManagementModal .data-table tbody tr.child-row {
    background-color: #ffffff;
}

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

/* Expand button styling */
#telemetryManagementModal .group-expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 8px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

#telemetryManagementModal .group-expand-btn:hover {
    opacity: 0.7;
}

#telemetryManagementModal .group-expand-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
    color: #2d8998;
}

#telemetryManagementModal .group-expand-icon:hover {
    color: #246b78;
}

/* Group checkbox styling */
#telemetryManagementModal .group-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* Indeterminate state styling for group checkbox */
#telemetryManagementModal .group-checkbox:indeterminate {
    background-color: #2d8998;
    border-color: #2d8998;
}

#telemetryManagementModal .group-checkbox:indeterminate::after {
    content: '';
    display: block;
    width: 10px;
    height: 2px;
    background-color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 1px;
}

/* ==================== DARK MODE ==================== */
@media (prefers-color-scheme: dark) {
    :root {
        --telemetry-color-text-primary: #e5e7eb;
        --telemetry-color-text-secondary: #cbd5e1;
        --telemetry-color-text-muted: #94a3b8;
        --telemetry-bg-card: #0f1113;
        --telemetry-bg-input: #111315;
        --telemetry-bg-hover: #1a1d21;
        --telemetry-border-light: rgba(255, 255, 255, 0.08);
        --telemetry-border-medium: rgba(255, 255, 255, 0.14);
    }

    .clickable-row:hover {
        background-color: #1a1d21 !important;
    }

    .clickable-row:active {
        background-color: rgba(255, 255, 255, 0.08) !important;
    }

    /* Telemetry Management Modal */
    #telemetryManagementModal {
        background: rgba(0, 0, 0, 0.6);
    }

    #telemetryManagementModal .modal-container {
        background-image: none;
        background-color: #0f1113;
        border-color: rgba(255, 255, 255, 0.12);
    }

    #telemetryManagementModal .modal-header {
        background: #111827;
        border-bottom-color: #374151;
    }

    #telemetryManagementModal .modal-header h2 {
        color: #f3f4f6 !important;
    }

    #telemetryManagementModal .modal-header .modal-btn-cancel {
        background: #374151;
        color: #e5e7eb;
        border-color: #4b5563;
    }

    #telemetryManagementModal .modal-header .modal-btn-cancel:hover {
        background: #4b5563;
        border-color: #6b7280;
    }

    #telemetryManagementModal .modal-body {
        background-image: none;
        background-color: #0f1113;
    }

    /* Sections */
    .telemetry-section {
        background: #111315;
        border-color: rgba(255, 255, 255, 0.12);
    }

    .section-header {
        border-bottom-color: #374151;
    }

    .section-count {
        color: #94a3b8;
    }

    .section-collapse-btn {
        color: #9ca3af;
    }

    .section-collapse-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .section-title {
        color: #f3f4f6;
    }

    /* Action Buttons */
    .simple-monitor-btn,
    .graph-monitor-btn {
        background: #374151;
        color: #e5e7eb;
    }

    .simple-monitor-btn:hover,
    .graph-monitor-btn:hover {
        background: #4b5563;
        color: #f3f4f6;
    }

    .remove-btn {
        background: #374151;
        color: #e5e7eb;
    }

    .remove-btn:hover {
        background: #4b5563;
        color: #f3f4f6;
    }

    /* Filter Area */
    .filter-area {
        background: #1f2937;
        border-color: #374151;
    }

    .filter-group label {
        color: #cbd5e1;
    }

    .filter-select,
    .filter-input {
        background: #111315;
        border-color: rgba(255, 255, 255, 0.14);
        color: #e5e7eb;
    }

    .filter-select:focus,
    .filter-input:focus {
        border-color: #2d8998;
    }

    /* Filter Buttons */
    .filter-more-btn {
        background: #374151;
        border-color: #4b5563;
        color: #e5e7eb;
    }

    .filter-more-btn:hover {
        background: #4b5563;
    }

    /* Filter Badges */
    .filter-badge {
        background: rgba(45, 137, 152, 0.2);
        border-color: #2d8998;
        color: #6dd3e3;
    }

    .filter-clear-btn {
        background: #374151;
        color: #e5e7eb;
        border-color: rgba(255, 255, 255, 0.14);
    }

    .filter-clear-btn:hover {
        background: #4b5563;
    }

    /* Table Styles */
    #telemetryManagementModal .table-wrapper {
        border-color: #374151;
        background: #0f1113;
    }

    #telemetryManagementModal .data-table {
        background: #0f1113;
    }

    #telemetryManagementModal .data-table thead {
        background: #111214;
    }

    #telemetryManagementModal .data-table th {
        color: #e5e7eb;
        border-bottom-color: #374151;
    }

    #telemetryManagementModal .data-table tbody tr {
        border-bottom-color: #374151;
    }

    #telemetryManagementModal .data-table tbody tr:hover {
        background: #1a1d21;
    }

    #telemetryManagementModal .data-table td {
        color: #e5e7eb;
    }

    #telemetryManagementModal .icon-btn {
        border-color: rgba(255, 255, 255, 0.14);
    }

    #telemetryManagementModal .icon-btn svg {
        stroke: #9ca3af;
    }

    #telemetryManagementModal .icon-btn:hover {
        background: #374151;
        border-color: #2d8998;
    }

    #telemetryManagementModal .icon-btn:hover svg {
        stroke: #2d8998;
    }

    /* Status Badges */
    .status-enabled {
        background: #065f46;
        color: #6ee7b7;
    }

    .status-disabled {
        background: #7f1d1d;
        color: #fca5a5;
    }

    /* Loading/Error States */
    .loading-cell,
    .empty-cell {
        color: #94a3b8;
    }

    .error-cell {
        color: #f87171;
    }

    /* Parameter/Assignment Modal */
    .parameter-modal-overlay,
    .assignment-modal-overlay {
        background: rgba(0, 0, 0, 0.6);
    }

    .parameter-modal,
    .assignment-modal {
        background-image: none;
        background-color: #1f2937;
        border-color: rgba(255, 255, 255, 0.12);
    }

    .parameter-modal-header,
    .assignment-modal-header {
        background: #111827;
        border-bottom-color: #374151;
    }

    .parameter-modal-header h3,
    .assignment-modal-header h3 {
        color: #f3f4f6;
    }

    .parameter-modal-close svg,
    .assignment-modal-close svg {
        stroke: #9ca3af;
    }

    .parameter-modal-close:hover,
    .assignment-modal-close:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .parameter-modal-body,
    .assignment-modal-body {
        background: #1f2937;
    }

    .parameter-modal-footer,
    .assignment-modal-footer {
        background: #111827;
        border-top-color: #374151;
    }

    /* Form Styles */
    .form-row label {
        color: #e5e7eb;
    }

    .form-row .form-input {
        background: #111315;
        border-color: rgba(255, 255, 255, 0.14);
        color: #e5e7eb;
    }

    .form-row .form-input:focus {
        border-color: #36a4b5;
        background: #1f2937;
    }

    .form-row .form-input::placeholder {
        color: #6b7280;
    }

    /* Info View */
    .info-success-badge {
        background: #065f46;
        border-color: #10b981;
        color: #6ee7b7;
    }

    .info-section {
        background: #111315;
        border-color: #374151;
    }

    .info-row {
        border-bottom-color: #374151;
    }

    .info-label {
        color: #cbd5e1;
    }

    .info-value {
        color: #e5e7eb;
    }

    .checkbox-label {
        color: #e5e7eb;
    }

    .form-error {
        background: #450a0a;
        border-color: #dc2626;
        color: #fca5a5;
    }

    /* Modal Buttons */
    .btn-cancel {
        background: #374151;
        color: #e5e7eb;
        border-color: #4b5563;
    }

    .btn-cancel:hover {
        background: #4b5563;
        border-color: #2d8998;
    }

    /* Tag System Dark Mode */
    #parameterModal .form-row .input-container:has(.tag-input-wrapper) {
        border-color: #374151;
        background: #1f2937;
        background-color: #1f2937;
    }

    #parameterModal .tag-suggestions {
        background: #1f2937;
        background-color: #1f2937;
    }

    #parameterModal .input-container .tag-input-wrapper {
        border-color: #4b5563;
        background: #111315;
        background-color: #111315;
    }

    #parameterModal .input-container .tag-input-wrapper:hover {
        border-color: #2d8998;
    }

    #parameterModal .input-container .tag-input-wrapper:focus-within {
        background: #111315;
        background-color: #111315;
    }

    #parameterModal .input-container .tag-suggestions {
        background: #1f2937;
        background-color: #1f2937;
    }

    #parameterModal .input-container .tag-input-wrapper #paramTagsInput {
        border-color: rgba(255, 255, 255, 0.14);
        background: transparent;
        background-color: transparent;
        color: #e5e7eb;
    }

    #parameterModal .input-container .tag-input-wrapper #paramTagsInput:focus {
        background: transparent;
        background-color: transparent;
    }

    #parameterModal .input-container .tag-input-wrapper #paramTagsInput::placeholder {
        color: #6b7280;
    }

    .hint {
        color: #94a3b8;
    }

    /* Group Rows Dark Mode */
    #telemetryManagementModal .data-table tbody tr.group-row {
        background-color: #1f2937;
        border-bottom-color: #374151;
    }

    #telemetryManagementModal .data-table tbody tr.group-row:hover {
        background-color: #374151;
    }

    #telemetryManagementModal .data-table tbody tr.group-row.collapsed {
        background-color: #1f2937;
    }

    #telemetryManagementModal .data-table tbody tr.child-row {
        background-color: #0f1113;
    }

    #telemetryManagementModal .data-table tbody tr.child-row:hover {
        background-color: #1a1d21;
    }

    #telemetryManagementModal .group-expand-icon {
        color: #2d8998;
    }

    #telemetryManagementModal .group-expand-icon:hover {
        color: #36a4b5;
    }
}