/* ==========================================================
   Query Dropdown — Reusable Component (Figma node 13448-55289)
   For internal/external query questions (types 39, 40, 41, 42).

   Usage: Pair with query_dropdown_v2.js
   ========================================================== */

.v2-pq-query-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    width: 60%;
}

/* Trigger field */
.v2-pq-query-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid #D6D6D6;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    transition: border-color 0.2s;
    min-height: 22px;
}

.v2-pq-query-field:hover {
    border-color: #999;
}

/* Locked extQuery dependent — value is auto-filled from the parent's selected
   row and not directly editable (option_value = -1 + dependent-edit disabled).
   Greyed/readonly look mirrors old UI disabled dependent fields. */
.v2-pq-query-locked .v2-pq-query-field {
    background: #F2F2F2;
    border-color: #E0E0E0;
    cursor: default;
    pointer-events: none;
}
.v2-pq-query-locked .v2-pq-query-field:hover {
    border-color: #E0E0E0;
}
.v2-pq-query-locked .v2-pq-query-chevron {
    display: none;
}

/* Placeholder / selected text */
.v2-pq-query-text {
    font-family: 'Lato', sans-serif;
    font-weight: 400;
    font-size: 16px;
    color: #999;
    line-height: 24px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v2-pq-query-text.v2-pq-query-has-value {
    color: #344054;
}

/* Chevron icon */
.v2-pq-query-chevron {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.2s;
}

/* Single-select: rotate chevron when open (via left-open class now) */
.v2-pq-query-single-wrap .v2-pq-query-multi-left.v2-pq-query-left-open .v2-pq-query-chevron {
    transform: rotate(180deg);
}
/* Multi-select: only rotate the left dropdown's chevron */
.v2-pq-query-multi-left.v2-pq-query-left-open .v2-pq-query-chevron {
    transform: rotate(180deg);
}
/* Multi-select: rotate the selected dropdown's chevron */
.v2-pq-query-multi-right.v2-pq-query-right-open .v2-pq-query-chevron {
    transform: rotate(180deg);
}

/* Multi-select tags (hidden for new multi-wrap layout) */
.v2-pq-query-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.v2-pq-query-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #F0F2FD;
    border: 1px solid #AFB9F2;
    border-radius: 16px;
    padding: 4px 10px;
    font-family: 'Lato', sans-serif;
    font-weight: 500;
    font-size: 13px;
    color: #2541DD;
}

.v2-pq-query-tag-remove {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.v2-pq-query-tag-remove:hover {
    opacity: 0.7;
}

/* Hide old tags area for multi-wrap */
.v2-pq-query-multi-wrap .v2-pq-query-tags {
    display: none !important;
}

/* Dropdown popup */
.v2-pq-query-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid #D6D6D6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-top: 4px;
    max-height: 280px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Search input inside dropdown */
.v2-pq-query-search-wrap {
    padding: 8px;
    border-bottom: 1px solid #EBEBEB;
}

.v2-pq-query-search {
    width: 100%;
    border: 1px solid #D6D6D6;
    border-radius: 6px;
    padding: 8px 12px;
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    color: #344054;
    outline: none;
    box-sizing: border-box;
}

.v2-pq-query-search:focus {
    border-color: #6172F3;
}

/* Options list */
.v2-pq-query-options {
    overflow-y: auto;
    flex: 1;
    max-height: 220px;
}

.v2-pq-query-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    color: #344054;
    cursor: pointer;
    transition: background 0.1s;
}

.v2-pq-query-option:hover {
    background: #F5F5F5;
}

.v2-pq-query-option.v2-pq-query-option-selected {
    background: #F0F2FD;
    color: #2541DD;
    font-weight: 500;
}

/* Loading / empty state */
.v2-pq-query-loading,
.v2-pq-query-no-results {
    padding: 16px;
    text-align: center;
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    color: #999;
}

/* Error state */
.v2-pq-error .v2-pq-query-field {
    border-color: #F96966;
}

/* ==========================================================
   Multi-select layout (two dropdowns side by side)
   ========================================================== */

.v2-pq-query-multi-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.v2-pq-query-multi-left {
    flex: 1;
    min-width: 0;
    position: relative;
}

.v2-pq-query-multi-right {
    width: 160px;
    flex-shrink: 0;
    position: relative;
}

/* Multi-wrap: lock the dropdown column to 60% so the "N selected" badge
   seats beside it (like Clear Selection in single-select) without
   shrinking the main dropdown when a selection is made. */
.v2-pq-query-wrap.v2-pq-query-multi-wrap {
    width: 100%;
}
.v2-pq-query-multi-wrap .v2-pq-query-multi-left {
    flex: 0 0 60%;
    max-width: 60%;
}

/* Selected badge field */
.v2-pq-query-selected-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #F6F7FE;
    border: 1px solid #AFB9F2;
    border-radius: 8px;
    cursor: pointer;
    min-height: 44px;
    box-sizing: border-box;
}

.v2-pq-query-selected-text {
    flex: 1;
    font-family: 'Lato', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #4F66E4;
    line-height: 24px;
    white-space: nowrap;
}

/* Selected items dropdown */
.v2-pq-query-selected-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 280px;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #EBEBEB;
    border-radius: 8px;
    box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03);
    z-index: 10;
    margin-top: 4px;
    padding: 4px 0;
}

.v2-pq-query-selected-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: default;
    background: #fff;
}

.v2-pq-query-selected-item:hover {
    background: #F2F2F2;
}

.v2-pq-query-selected-item-text {
    flex: 1;
    font-family: 'Lato', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #1F1F1F;
    line-height: 24px;
}

.v2-pq-query-selected-item-remove {
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.v2-pq-query-selected-item-remove:hover svg circle {
    stroke: #666;
}

/* Checkbox in multi-select options */
.v2-pq-query-checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: 1px solid #C2C2C2;
    border-radius: 4px;
    background: #fff;
    flex-shrink: 0;
}

.v2-pq-query-checkbox.v2-pq-query-checkbox-checked {
    background: #F0F2FD;
    border-color: #4F66E4;
}

/* Multi-select option row overrides */
.v2-pq-query-multi-wrap .v2-pq-query-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.v2-pq-query-multi-wrap .v2-pq-query-option:hover {
    background: #F9F9F9;
}

.v2-pq-query-multi-wrap .v2-pq-query-option.v2-pq-query-option-selected {
    background: #F6F7FE;
    color: #1F1F1F;
    font-weight: 500;
}

.v2-pq-query-option-label {
    font-family: 'Lato', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #1F1F1F;
    line-height: 24px;
}

/* ==========================================================
   Single-select layout (two-column with clear button)
   ========================================================== */

/* Single-select wrapper uses same row layout as multi */
.v2-pq-query-single-wrap .v2-pq-query-multi-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* Lock the dropdown column to 60% of the question width so it stays the same
   size whether or not the Clear Selection button is visible. The wrap expands
   beyond 60% to seat the button to the right. */
.v2-pq-query-wrap.v2-pq-query-single-wrap {
    width: 100%;
}
.v2-pq-query-single-wrap .v2-pq-query-multi-left {
    flex: 0 0 60%;
    max-width: 60%;
}

/* Selected value text in indigo for single-select */
.v2-pq-query-single-wrap .v2-pq-query-text.v2-pq-query-has-value {
    color: #2541DD;
}

/* Locked dependents (auto-filled from the parent's row, not user-editable) show
   the value as plain readonly text — the indigo is for active user selections. */
.v2-pq-query-single-wrap.v2-pq-query-locked .v2-pq-query-text.v2-pq-query-has-value {
    color: #344054;
}

/* Radio circle for single-select */
.v2-pq-query-radio {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: 1px solid #C2C2C2;
    border-radius: 50%;
    background: #fff;
    flex-shrink: 0;
}
.v2-pq-query-radio.v2-pq-query-radio-checked {
    background: #F0F2FD;
    border-color: #4F66E4;
}
.v2-pq-query-radio.v2-pq-query-radio-checked::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4F66E4;
}

/* Single-select option rows with radio */
.v2-pq-query-single-wrap .v2-pq-query-option {
    display: flex;
    align-items: center;
    gap: 8px;
}
.v2-pq-query-single-wrap .v2-pq-query-option:hover {
    background: #F9F9F9;
}
.v2-pq-query-single-wrap .v2-pq-query-option.v2-pq-query-option-selected {
    background: #F6F7FE;
    color: #1F1F1F;
    font-weight: 500;
}

/* Clear Selection button */
.v2-pq-query-clear-wrap {
    flex-shrink: 0;
}
.v2-pq-query-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #C2C2C2;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Lato', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #7A7A7A;
    line-height: 24px;
    white-space: nowrap;
    min-height: 44px;
    box-sizing: border-box;
}
.v2-pq-query-clear-btn:hover {
    background: #F5F5F5;
}
