/* 
============================================================================
BENCHMARKING MODULE STYLES
============================================================================

CSS for the benchmarking/nano component system.
All component class names use -nano suffix to prevent conflicts.

Sections:
1. CSS Variables & Base Styles
2. Layout & Containers
3. Card Components
4. Form Inputs & Controls
5. Select & Dropdown Styling
6. Modal Components
7. Context Menu
8. Tables & Data Display
9. Alerts & Notifications
10. Utility Classes

============================================================================
*/

@import url("https://fonts.googleapis.com/css?family=Poppins:wght@400,;500;600;700&display=swap");

/* ============================================================================
   SECTION 1: CSS VARIABLES & BASE STYLES
   ============================================================================ */

body {
    font-family: 'Poppins', sans-serif;
}

:root {
    --fontsize-input: 0.8rem;
    --bs-border-color: #404040;
    --dp-font-size: 0.8rem;
}

/* ============================================================================
   SECTION 2: LAYOUT & CONTAINERS
   ============================================================================ */

.container-normalization {
    padding: 0 !important;
}

/* Charts Header & Tabs */
.charts-tabs-nano {
    position: sticky;
    top: 0px;
    height: 30px;
    z-index: 2;
    padding-top: 5px;
}

.charts-tab-nano {
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
    font-size: small;
    color: inherit !important;
}

.charts-tab-nano.active {
    color: var(--color-endata-orange) !important;
    /* font-weight: 600 !important; */
}

.charts-header-nano {
    position: sticky;
    top: 0px;
    z-index: 2;
    display: flex;
    padding-top: 0px;
    padding-left: 15px;
    padding-bottom: 0px;
    justify-content: flex-start;
    align-items: center !important;
    margin: 0;
}

.btn-add-chart-nano {
    border: none;
    padding: 0px 4px 0px 4px !important;
    font-size: large;
    border-radius: 3px;
}

#chart-container-nano {
    margin: 0 !important;
    padding-top: 5px;
}

/* ============================================================================
   SECTION 3: CARD COMPONENTS
   ============================================================================ */

/* Card Header (global) */
.card-header {
    height: 30px;
    padding-top: 2px;
    padding-bottom: 2px;
}

/* Card Layout Variants */
.card-top {
    height: 100% !important;
    margin: 0 !important;
}

.card-bottom {
    margin-top: 10px !important;
    height: 40vh !important;
}
.charts-page-wrapper-nano {
    margin-bottom:25px;
}

/* Chart Card Listener (Nano) */
.chart-card-listener-nano {
    width: 100% !important;
    padding: 0 !important;
}

.chart-card-listener-nano .card {
    margin: 0 0 0.5rem 0 !important;
}

.chart-card-listener-nano .card-header {
    position: relative;
    display: flex !important;
    padding: 0.25rem 0.5rem !important;
    padding-left: 0.5rem !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-radius: calc(0.25rem + 1px) calc(0.25rem + 1px) 0rem 0rem !important;
    flex-wrap: nowrap !important;
    gap: 0.5rem !important;
}

.chart-card-listener-nano .card-header > div:last-child {
    display: flex !important;
    gap: 0.25rem !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    margin-left: auto !important;
}

.chart-card-listener-nano .card-header > div:last-child > div {
    display: flex !important;
    gap: 0.25rem !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
}

.chart-card-listener-nano .card-header .btn {
    border: none;
    padding: 0.25rem 0.5rem !important;
    margin: 0 !important;
    line-height: 1 !important;
    min-width: auto !important;
    height: auto !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.chart-title-listener-nano {
    width: 80%;
    flex-shrink: 1;
}

/* Card Body */
.card-body-nano {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    position: relative !important;
}

/* Ensure graph stays below modal/context-menu overlays.
   Plotly's internal drag layers can capture pointer events,
   so the graph wrapper needs a lower stacking context. */
.card-body-nano > .dynamic-graph-nano,
.card-body-nano .dynamic-graph-nano {
    position: relative;
    z-index: 1;
}

.card-body-nano > .modal-div-nano,
.card-body-nano .modal-div-nano {
    z-index: 3;
}

.card-body-nano > .modal-div-delete-nano,
.card-body-nano .modal-div-delete-nano {
    z-index: 4;
}

/* Map Card */
.map-card-body {
    padding: 0px !important;
    height: 100% !important;
}

/* .map-graph-nano {
    height: 100% !important;
} */

/* Wells Card — .card.wells-card for higher specificity than the global
   .card { margin: 0 ... !important } rule in styles_diagnostics.css */
.card.wells-card {
    margin-top: 20px !important;
    margin-left: 5px !important;
    margin-right: 0px !important;
}

.wells-card-header {
    padding-right: 0px;
    align-items: center;
}

/* ============================================================================
   SECTION 4: FORM INPUTS & CONTROLS
   ============================================================================ */

/* Title Input */
.input_title_nano {
    background-color: transparent !important;
    border: none !important;
    font-weight: bold !important;
    margin-bottom: 0 !important;
    padding: 0.1rem;
}

.input_title_nano::selection {
    background-color: #86b6fe77;
    color: lightgray !important;
}

/* Group Title Input */
.chart-tite-listener__groups {
    width: 100%;
    padding: 0px;
}

.input_title__groups {
    background-color: transparent !important;
    border: none !important;
    margin-bottom: 0 !important;
    font-size: small;
    color: lightgray !important;
}

.input_title__groups::selection {
    background-color: #86b6fe77;
    color: lightgray !important;
}

/* Edit Item Container */
.edit-item {
    background-color: inherit;
    color: lightgray;
    height: 30px;
    font-size: small;
    padding: 0.3rem;
    padding-right: 0.1rem !important;
}

/* Allow multi-select to grow */
.edit-item:has(.dp-select-multi-wrapper) {
    min-height: 30px;
    height: auto;
}

/* Allow range slider input group to grow when it wraps */
.edit-item:has(.input-range-slider) {
    min-height: 30px;
    height: auto;
}

/* Unified Label Styling */
.input-label {
    width: 150px;
    font-size: var(--dp-font-size) !important;
    min-height: 30px;
    height: auto;
    color: lightgray;
    display: flex;
    align-items: center;
}

.input-label-120 {
    width: 120px;
    font-size: var(--dp-font-size) !important;
    min-height: 30px;
    height: auto;
    color: lightgray;
    display: flex;
    align-items: center;
}

.input-label-125 {
    width: 125px;
    font-size: var(--dp-font-size) !important;
    min-height: 30px;
    height: auto;
    color: lightgray;
    display: flex;
    align-items: center;
}

/* Input Number */
.input-number {
    width: 3.5rem;
    height: 30px;
    background-color: #EAEAEB;
    font-size: var(--dp-font-size);
    flex-shrink: 0;
}

/* Input Color */
.input-color {
    max-width: 3rem;
    height: 30px;
    flex-shrink: 0;
}

/* Input Text */
.input-text {
    width: 75px;
    height: 30px;
    font-size: var(--dp-font-size);
    flex-shrink: 0;
}

.input-text__search {
    width: auto !important;
}

/* Input Unit Label */
.input-unit {
    font-size: var(--dp-font-size);
    color: lightgray;
    height: 30px;
    display: flex;
    align-items: center;
    padding-left: 5px;
    padding-right: 5px;
    flex-shrink: 0;
}

/* Slider Wrapper */
.input-slider-wrapper {
    flex-grow: 1;
    height: 30px;
    padding-top: 10px;
}

/* Range Slider */
.input-range-slider {
    flex: 1 1 auto;
    padding-top: 8px;
    padding-left: 0;
    padding-right: 5px;
    height: 30px;
    min-width: 50px;
}

.input-range-slider-inner {
    padding: 0 !important;
}

.input-range-slider .rc-slider {
    width: 100% !important;
}

/* Input Group with Text */
.input-group-wtext {
    font-size: 0.8rem;
    margin-top: 2px;
}

.input-group-wtext__label {
    width: 125px;
    color: lightgray;
}

/* ============================================================================
   SECTION 5: SELECT & DROPDOWN STYLING
   ============================================================================ */

/* Single Select (dbc.Select) */
.dp-select {
    font-size: var(--dp-font-size) !important;
    background-color: #31363b !important;
    color: lightgray;
}

.dp-select.form-select {
    border-color: var(--bs-border-color) !important;
}

/* Specific z-index for select-normalizer-radar */
#select-normalizer-radar {
    position: relative !important;
    z-index: 100 !important;
}

/* Multi Select Wrapper (dcc.Dropdown) */
.dp-select-multi-wrapper {
    flex-grow: 1;
    padding-top: 0px;
}

/* Main dropdown control */
.Select-control {
    padding: 0 !important;
    border-color: var(--bs-border-color) !important;
    border-radius: var(--bs-border-radius-sm);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    min-height: 30px !important;
    height: auto !important;
}

/* Multi-value wrapper */
.Select-multi-value-wrapper {
    min-height: 28px !important;
    height: auto !important;
    margin: 0 !important;
    padding: 2px !important;
    max-height: none !important;
}

/* Placeholder text */
.Select-placeholder {
    line-height: 28px !important;
    color: lightgray;
    font-size: var(--dp-font-size) !important;
}

/* All dropdown divs */
.Select div { 
    background: #31363b !important;  
    color: lightgray !important; 
    font-size: var(--dp-font-size) !important;
}

/* Selected value text */
.Select-value-label {
    color: lightgray !important;
    font-size: var(--dp-font-size) !important;
}

/* Input field inside dropdown */
.Select-input {
    height: 28px !important;
}

.Select-input > input {
    line-height: 28px !important;
    padding: 0 !important;
    color: lightgray !important;
    font-size: var(--dp-font-size) !important;
}

/* Dropdown menu */
.Select-menu-outer {
    background-color: #31363b !important;
    border-color: var(--bs-border-color) !important;
    font-size: var(--dp-font-size) !important;
}

/* Menu options */
.Select-option {
    background-color: #31363b !important;
    color: lightgray !important;
    font-size: var(--dp-font-size) !important;
    padding: 5px 10px;
}

.Select-option:hover {
    background-color: #3d4449 !important;
}

.Select-option.is-focused {
    background-color: #493e3d !important;
}

.Select-option.is-selected {
    background-color: #4a5157 !important;
}

/* Multi-value tags */
.Select-value {
    background-color: #4a5157 !important;
    border-color: #5a6168 !important;
    color: lightgray !important;
    font-size: var(--dp-font-size) !important;
    line-height: 1.1 !important;
    border-radius: 4px !important;
}

/* Remove button on multi-value tags */
.Select-value-icon {
    border-color: #5a6168 !important;
}

.Select-value-icon:hover {
    background-color: #5a6168 !important;
    color: white !important;
}

/* Clear button */
.Select-clear-zone {
    color: lightgray !important;
}

.Select-clear-zone:hover {
    color: white !important;
}

/* Arrow indicator */
.Select-arrow-zone {
    color: lightgray !important;
}

/* Data source select table */
.data-source-select__table {
    padding-left: 0;
    max-width: 600px;
}

/* Select with Label (wlabel variants) */
.dp-select-wlabel-container {
    padding: 0px;
    margin: 0px;
    margin-bottom: 5px;
    margin-right: 5px;
}

.dp-select-wlabel-label {
    font-size: 0.75rem;
    color: lightgray;
    padding: 0px;
    margin: 0px;
}

.dp-select-wlabel {
    font-size: 0.75rem;
    height: 22px;
    padding-top: 0px;
    padding-bottom: 0px;
    background-color: #31363b;
}

.dp-select-multi-wlabel-label {
    font-size: 0.8rem;
    color: lightgray;
    padding: 0px;
    margin: 0px;
}

/* ============================================================================
   SECTION 6: MODAL COMPONENTS
   ============================================================================ */

/* ── Normal mode: graph has a fixed height ── */
/* !important needed to override inline style="height:100%" set by responsive=True */
.dynamic-graph-nano {
    width: 100%;
    height: 370px !important;
}

/* ── Full Screen Mode ── */
.full_screen_nano {
    width: 100vw !important;
    position: fixed;
    height: calc(100vh - 30px - var(--statusbar-height)) !important;  /* subtract navbar + statusbar height */
    top: 30px;  /* below the navbar */
    left: 0;
    z-index: 10001;
    background-color: var(--bs-body-bg, #1e1e1e);
}

.full_screen_nano .card-body-nano {
    height: calc(100vh - 30px - var(--statusbar-height) - 42px) !important;  /* viewport - navbar - statusbar - card header */
    overflow: hidden !important;
}

.full_screen_nano .dynamic-graph-nano {
    height: calc(100vh - 30px - var(--statusbar-height) - 62px) !important;  /* 30px navbar + statusbar + 42px header + 20px padding */
}

/* Widen .tab-content so pointer events reach the fullscreen card */
.tab-content:has(.full_screen_nano) {
    width: 100vw !important;
    overflow: visible !important;
}

/* Modal Overlay */
.modal-div-nano {
    position: absolute !important;
    z-index: 3;
    background-color: rgba(0, 0, 0, 0.85);
    top: 0px;
    left: 0px;
    width: 100% !important;
    height: 100% !important;
}

.modal-div-delete-nano {
    position: absolute !important;
    z-index: 4;
    background-color: rgba(0, 0, 0, 0.5);
    top: 0px;
    left: 0px;
    width: 100% !important;
    height: 100% !important;
}

/* Modal Content */
.modal-content {
    padding: 5px !important;
    border-radius: 0px 0px 0.25rem 0.25rem !important;
    background-color: white;
    opacity: 0.9;
}

.modal-content .edit-item {
    background-color: inherit;
    color: inherit;
    height: 2rem;
    font-size: small;
    padding: 0.3rem;
}

.modal-content .trace-style {
    width: 5rem;
}

.modal-content .color-picker {
    width: 5rem;
    padding: 0.3rem;
}

.modal-content .log {
    width: 5rem;
}

.modal-content .check-grids {
    width: 15rem;
}

.modal-content .show-notes {
    width: 10rem;
}

.modal-content h5 {
    text-align: center;
    margin: 10px 0;
}

.modal-content p {
    text-align: center;
    margin: 1px 0;
    font-size: 0.8rem;
}

.modal-content .icon-box {
    text-align: center;
    color: var(--bs-danger);
    font-size: 50px;
    display: inline-block;
    margin-top: 13px;
}

/* Modal Content Nano Specific */
.modal-content-nano .act-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    width: 4rem !important;
    height: 2rem;
    font-size: small;
}

.modal-content-nano .input-label {
    width: 100px;
}

/* Modal Tab */
.modal-tab {
    padding-top: 0.15rem !important;
    padding-bottom: 0.15rem !important;
    font-size: small;
}

/* ============================================================================
   SECTION 7: CONTEXT MENU
   ============================================================================ */

.main-menu-nano {
    position: absolute;
    visibility: hidden;
    width: 8rem;
    border-radius: 5px !important;
    border: 1px solid rgba(176, 176, 176, 0.473);
    box-shadow: 0px 12px 35px rgba(0, 0, 0, 0.1);
    z-index: 2;
}

.main-menu-nano .list-group-item {
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
}

.main-menu-nano .list-group-item.disabled,
.list-group-item:disabled {
    color: #949494b6;
}

.main-menu-nano .list-group-item:hover {
    background-color: rgba(var(--bs-info-rgb), 1) !important;
}

.main-menu-nano .menu-settings {
    border-top: 1px solid #ccc !important;
}

.main-menu-nano .more {
    display: flex !important;
    justify-content: space-between !important;
}

.more .more-menu {
    position: absolute;
    width: 8rem;
    right: -8.05rem;
    top: -5rem;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.08);
    border-radius: 5px;
    opacity: 0;
    pointer-events: none;
    border: 1px solid rgba(176, 176, 176, 0.473);
}

.more:hover .more-menu {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================================
   SECTION 8: TABLES & DATA DISPLAY
   ============================================================================ */

/* Radar Graph */
.radar-graph {
    max-height: 22rem !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;
    margin-top: 10px !important;
    position: relative !important;
    z-index: 0 !important;
    pointer-events: none !important;
}

.radar-graph .js-plotly-plot {
    width: 100% !important;
    height: 100% !important;
    overflow: visible !important;
    pointer-events: auto !important;
}

/* Stats Graph */
.stats-graph {
    height: 20rem !important;
}

/* ── Wells Table Wrapper (removed - button now inline with Data Source) ── */

/* "Select filtered" button — compact, inline with Data Source selector */
.select-all-filtered-btn-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    height: auto;
    min-height: 30px;

    background: #2a2d31;
    border: 1px solid #424242;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    color: #b0b0b0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    letter-spacing: 0.02em;
}

.select-all-filtered-btn-inline:hover {
    background: #333;
    border-color: #96c5cd;
    color: #e0e0e0;
}

.select-all-filtered-btn-inline:active {
    background: #1a1a1a;
    border-color: #45cfe4;
}

/* Bottom Panel Shared Controls (above tabs) */
.bottom-panel__controls {
    padding: 4px 8px;
    border-bottom: 1px solid #333;
    align-items: center;
    min-height: 38px;
}

/* Search input in bottom panel controls */
.bottom-panel__search-input {
    font-size: 12px;
    max-width: 180px;
}

/* Bottom Panel Table — height set by JS syncTableHeight */
.bottom-panel__table {
    height: 250px;
}

/* ── Active Filter Chips Bar ─────────────────────────────────────────── */

.active-filters-bar {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 4px;
    flex-wrap: wrap;
    min-height: 0;
}

.active-filters-bar:empty {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    background: #2a2d31;
    border: 1px solid #424242;
    border-radius: 12px;
    padding: 1px 4px 1px 10px;
    font-size: 11px;
    color: #b0b0b0;
    white-space: nowrap;
    max-width: 280px;
}

.filter-chip__col {
    font-weight: 600;
    color: #d0d0d0;
    margin-right: 3px;
    flex-shrink: 0;
}

.filter-chip__val {
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-chip__remove {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    padding: 0 3px;
    margin-left: 4px;
    line-height: 1;
    flex-shrink: 0;
}

.filter-chip__remove:hover {
    color: #ff6b6b;
}

.filter-clear-all {
    background: none;
    border: 1px solid #555;
    border-radius: 12px;
    color: #888;
    font-size: 11px;
    padding: 1px 10px;
    cursor: pointer;
    white-space: nowrap;
    margin-right: 2px;
}

.filter-clear-all:hover {
    color: #ff6b6b;
    border-color: #ff6b6b;
}

/* Filter badge toggle button */
.filter-badge {
    display: inline-flex;
    align-items: center;
    background: #2a2d31;
    border: 1px solid #424242;
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 12px;
    color: #555;
    white-space: nowrap;
    height: auto;
    min-height: 30px;
    cursor: default;
    pointer-events: none;
}

.filter-badge--active {
    color: #00bcd4;
    border-color: #00bcd4;
    cursor: pointer;
    pointer-events: auto;
}

.filter-badge--active:hover {
    border-color: #4dd0e1;
    color: #4dd0e1;
}

/* Popover: dark theme + hide arrow */
.filter-popover .popover {
    background-color: #2a2d31;
    border: 1px solid #424242;
}

.filter-popover .popover-body {
    padding: 6px;
}

.filter-popover .popover-arrow::before,
.filter-popover .popover-arrow::after {
    border-bottom-color: #2a2d31 !important;
    border-top-color: #2a2d31 !important;
}

.filter-popover .bs-popover-bottom > .popover-arrow::before {
    border-bottom-color: #424242 !important;
}

.filter-popover .bs-popover-bottom > .popover-arrow::after {
    border-bottom-color: #2a2d31 !important;
}

.filter-popover .bs-popover-top > .popover-arrow::before {
    border-top-color: #424242 !important;
}

.filter-popover .bs-popover-top > .popover-arrow::after {
    border-top-color: #2a2d31 !important;
}

/* Stats Table */
#stats-table .dash-spreadsheet-container {
    max-height: 300px !important;
    overflow-y: auto !important;
    margin-top: 0px !important;
}

/* Wells Table */
#table-wells .dash-spreadsheet-container {
    max-height: 600px !important;
    overflow-y: auto !important;
    margin-top: 0px !important;
}

#table-wells .previous-next-container {
    font-size: x-small !important;
}

#table-wells .previous-next-container .current-page {
    font-size: x-small !important;
}

#table-wells .previous-next-container button {
    font-size: x-small !important;
}

/* Spreadsheet Row Hover */
.dash-spreadsheet-container .dash-spreadsheet-inner table tbody tr:hover {
    background-color: rgba(245, 153, 34, 0.1) !important;
}

/* General Table Container */
.general-table-container {
    width: 100%;
    padding: 0 !important;
    padding-right: 12px !important; 
    margin: 0 !important;
    height: auto !important;
    max-height: 300px !important;
    overflow-y: auto !important;
}

/* Key-Value Table */
.kv-container {
    width: 100%;
}

.kv-row {
    padding: 2px 0;
    border-bottom: 1px solid #2a2a2a;
    margin: 0 !important;
}

.kv-row:hover {
    background-color: rgba(245, 153, 34, 0.1) !important;
}

.kv-key {
    font-weight: 600;
    color: #b1b1b1;
    font-size: 0.75rem;
    text-align: left;
    padding-left: 0 !important;
}

.kv-value {
    color: #b1b1b1;
    font-size: 0.75rem;
    text-align: right;
    padding-right: 0 !important;
}

.table-subtitle {
    color: tan;
    font-size: 0.8rem;
    font-weight: 800;
    padding: 5px 0;
    text-align: left;
    margin: 0;
}

/* ============================================================================
   SECTION 9: ALERTS & NOTIFICATIONS
   ============================================================================ */

.floating-alert {
    position: absolute;
    top: 0px;  
    left: 50%;  
    transform: translateX(-50%);
    z-index: 1000;  
    width: auto;
    opacity: 0.95;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.alert-text {
    margin-bottom: 10px;
}

.alert-buttons {
    display: flex;
    justify-content: center;
    gap: 50px;
}

.alert-btn {
    width: 5rem;
    border: 1px solid rgb(182, 180, 180);
}

.close-btn {
    margin-top: -2px;
    border: none;
    height: 90%;
}

.close-btn:hover {
    background-color: transparent !important;
    color: red; 
}

/* ============================================================================
   SECTION 10: UTILITY CLASSES
   ============================================================================ */

/* Width Helpers */
.w-20 {
    width: 20%;
}

.w-40 {
    width: 40%;
}

/* Action Button */
.act-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    width: 8rem;
    height: 2rem;
    font-size: 0.9rem;
}

/* Accordion */
.accordion-item .accordion-body {
    padding-top: 0;
}

.accordion-item .accordion-header .accordion-button {
    height: 10px;
    font-size: 0.9rem;
}

/* Tooltip */
.tooltip-inner {
    opacity: 0.85;
    font-size: smaller;
}

.tooltip-arrow::before {
    opacity: 0.85 !important;
}

/* Button Focus */
.btn:focus {
    box-shadow: none;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .kv-key, .kv-value {
        text-align: left !important;
    }
}

/* ============================================================================
   GROUPED DROPDOWN (dpg-*) — categorized, collapsible, searchable
   ============================================================================ */

.dpg-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    font-size: var(--dp-font-size);
}

/* Hidden state holder — keep mounted for callback API + persistence */
.dpg-hidden-host {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    left: -9999px;
}

/* Trigger row (visible chips area + caret) */
.dpg-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 3px 8px 3px 6px;
    background-color: #31363b;
    border: 1px solid var(--bs-border-color, #404040);
    border-radius: var(--bs-border-radius-sm, 0.2rem);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    cursor: pointer;
    transition: border-color 0.15s ease;
}
.dpg-trigger:hover { border-color: #5a6068; }
.dpg-wrapper.is-open .dpg-trigger {
    border-color: #4a90e2;
    box-shadow: 0 0 0 1px rgba(74, 144, 226, 0.25);
}

.dpg-chips-area {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

.dpg-chips {
    display: contents;
}

.dpg-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #3d4248;
    color: #e6e6e6;
    border: 1px solid #4a5058;
    border-radius: 3px;
    padding: 1px 4px 1px 6px;
    font-size: 0.72rem;
    line-height: 1.4;
    max-width: 220px;
}
.dpg-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dpg-chip-x {
    cursor: pointer;
    color: #b0b0b0;
    padding: 0 2px;
    font-weight: 600;
}
.dpg-chip-x:hover { color: #ff6b6b; }

.dpg-placeholder {
    color: #888;
    font-size: 0.78rem;
    line-height: 22px;
    pointer-events: none;
}
.dpg-wrapper[data-has-value="true"] .dpg-placeholder { display: none; }

.dpg-caret {
    color: #b0b0b0;
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.dpg-wrapper.is-open .dpg-caret { transform: rotate(180deg); }

/* Panel — accordion of categories */
.dpg-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1050;
    display: none;
    background-color: #2a2e33;
    border: 1px solid #4a5058;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    max-height: 380px;
    overflow: hidden;
    flex-direction: column;
}
.dpg-wrapper.is-open .dpg-panel {
    display: flex;
}

.dpg-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid #3a3f44;
    background-color: #2f3439;
    flex-shrink: 0;
}
/* .dpg-search-icon {
    color: #888;
    font-size: 0.75rem;
} */
.dpg-search {
    flex: 1;
    background-color: #1f2226;
    color: #e6e6e6;
    border: 1px solid #3a3f44;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 0.78rem;
    outline: none;
}
.dpg-search:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 1px rgba(74, 144, 226, 0.25);
}

.dpg-accordion {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    padding: 4px 0;
}

/* Group */
.dpg-group {
    border-bottom: 1px solid #353a40;
}
.dpg-group:last-child { border-bottom: none; }

.dpg-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    color: #E7C582;
    font-weight: 600;
    font-size: 0.78rem;
    transition: background-color 0.12s ease;
}
.dpg-group-header:hover {
    background-color: #34393f;
}

.dpg-chevron {
    display: inline-block;
    font-size: 0.6rem;
    color: #E7C582;
    transition: transform 0.2s ease;
    width: 10px;
}
.dpg-group[data-expanded="true"] > .dpg-group-header > .dpg-chevron {
    transform: rotate(90deg);
}

.dpg-group-name { flex: 1 1 auto; }
.dpg-group-count {
    color: #6b7280;
    font-weight: 400;
    font-size: 0.7rem;
}

.dpg-group-items {
    display: none;
    padding: 2px 0 6px;
}
.dpg-group[data-expanded="true"] > .dpg-group-items {
    display: block;
}

/* Item */
.dpg-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 26px;
    color: #d1d5db;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background-color 0.1s ease;
}
.dpg-item:hover {
    background-color: #34393f;
    color: #fff;
}
.dpg-item[data-selected="true"] {
    background-color: rgba(74, 144, 226, 0.15);
    color: #fff;
}

.dpg-checkbox {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 1px solid #5a6068;
    border-radius: 2px;
    background-color: #1f2226;
    flex-shrink: 0;
    position: relative;
    transition: all 0.12s ease;
}
.dpg-item[data-selected="true"] .dpg-checkbox {
    background-color: #E7C582;
    border-color: #E7C582;
}
.dpg-item[data-selected="true"] .dpg-checkbox::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 0px;
    width: 4px;
    height: 8px;
    border: solid #1f2226;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Single-select variant — render as radio */
.dpg-wrapper[data-multi="false"] .dpg-checkbox {
    border-radius: 50%;
}
.dpg-wrapper[data-multi="false"] .dpg-item[data-selected="true"] .dpg-checkbox::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 5px;
    height: 5px;
    border: none;
    border-radius: 50%;
    background-color: #1f2226;
    transform: none;
}

.dpg-item-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Search filtering — JS toggles these classes */
.dpg-item.is-hidden { display: none; }
.dpg-group.is-hidden { display: none; }

/* When filtering, force-expand groups that contain matches */
.dpg-group.is-search-expanded > .dpg-group-items { display: block; }
.dpg-group.is-search-expanded > .dpg-group-header > .dpg-chevron {
    transform: rotate(90deg);
}

/* Empty state */
.dpg-empty {
    padding: 16px;
    text-align: center;
    color: #6b7280;
    font-size: 0.78rem;
    font-style: italic;
}

/* Scrollbar */
.dpg-accordion::-webkit-scrollbar { width: 8px; }
.dpg-accordion::-webkit-scrollbar-track { background: #2a2e33; }
.dpg-accordion::-webkit-scrollbar-thumb {
    background: #4a5058;
    border-radius: 4px;
}
.dpg-accordion::-webkit-scrollbar-thumb:hover { background: #5a6068; }

/* Override input-group rounding when wrapper is the only sibling */
.edit-item:has(.dpg-wrapper) {
    min-height: 30px;
    height: auto;
}
