/* shared/dropdownControl.css -- Shared SCDropdown styles.
   Loaded BEFORE templateStudio.css so consumer CSS can override.

   Uses Template Studio CSS vars (--bg, --card, --panel, --line, --line-em,
   --text, --sub, --muted, --teal, --hover) with safe fallbacks for non-Studio
   pages (e.g. light-theme admin shells).

   Design rules respected (CLAUDE.md + feedback_no_colored_chips_badges):
   - no badges/chip pills with tinted backgrounds
   - text plain with --sub / --muted for secondary
   - single hover effect (background, NU bg + border)
   - no decorative dots / gratuitous shadows
*/

:root {
    /* Above StudioDialog (1000), below Toast (2000). */
    --z-dropdown: 1200;
}

/* ═══════════════════════════════════════════════════════════════
   Trigger
   ═══════════════════════════════════════════════════════════════ */
.scdd-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    /* Width is determined either by:
       1. inline style copied from <select> (e.g. width:100%) at attach time, or
       2. natural content of the trigger.
       NEVER force 100% globally — that breaks toolbar/inline contexts. */
}

.scdd-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;
    background: var(--card, #fff);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 8px;
    color: var(--text, #1a202c);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
    box-sizing: border-box;
    line-height: 1.3;
}
.scdd-trigger:hover:not(.is-disabled) {
    border-color: var(--line-em, #cbd5e0);
}
.scdd-trigger:focus-visible {
    outline: 2px solid var(--teal, #00A884);
    outline-offset: 2px;
}
.scdd-trigger[aria-expanded="true"] {
    border-color: var(--line-em, #cbd5e0);
}
.scdd-trigger.is-disabled {
    opacity: .55;
    cursor: not-allowed;
}

.scdd-trigger-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text, #1a202c);
}
.scdd-trigger-label.scdd-placeholder {
    color: var(--sub, #8696a0);
    font-weight: 400;
}

.scdd-trigger-chevron {
    display: inline-flex;
    align-items: center;
    color: var(--sub, #8696a0);
    transition: transform 150ms ease;
    flex-shrink: 0;
}
.scdd-trigger[aria-expanded="true"] .scdd-trigger-chevron {
    transform: rotate(180deg);
}

/* ═══════════════════════════════════════════════════════════════
   Popup (portaled to <body>)
   ═══════════════════════════════════════════════════════════════ */
.scdd-popup {
    position: fixed;
    z-index: var(--z-dropdown, 1200);
    min-width: 160px;
    background: var(--card, #fff);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: scdd-pop-in 120ms ease;
}
.scdd-popup.is-above {
    transform-origin: bottom left;
}

@keyframes scdd-pop-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.scdd-search {
    flex-shrink: 0;
    padding: 8px;
    border-bottom: 1px solid var(--line, #e2e8f0);
    background: var(--card, #fff);
}
.scdd-search-input {
    width: 100%;
    padding: 7px 10px;
    background: var(--bg, #f7fafc);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 6px;
    color: var(--text, #1a202c);
    font-family: inherit;
    font-size: 13px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 150ms ease;
}
.scdd-search-input:focus {
    border-color: var(--teal, #00A884);
}
.scdd-search-input::placeholder {
    color: var(--sub, #8696a0);
}

.scdd-listbox {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px;
}
.scdd-listbox::-webkit-scrollbar {
    width: 8px;
}
.scdd-listbox::-webkit-scrollbar-thumb {
    background: var(--line-em, #3d5060);
    border-radius: 4px;
}
.scdd-listbox::-webkit-scrollbar-track {
    background: transparent;
}

/* ═══════════════════════════════════════════════════════════════
   Items
   ═══════════════════════════════════════════════════════════════ */
.scdd-group-header {
    padding: 8px 10px 4px 10px;
    color: var(--sub, #8696a0);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    user-select: none;
}

.scdd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text, #1a202c);
    font-size: 13px;
    cursor: pointer;
    transition: background 100ms ease;
    user-select: none;
    line-height: 1.3;
}
.scdd-item:not(.is-disabled):hover,
.scdd-item.is-active {
    background: var(--panel, var(--hover, rgba(0,0,0,.05)));
}
.scdd-item.is-disabled {
    opacity: .45;
    cursor: not-allowed;
}
.scdd-item.is-selected {
    color: var(--teal, #00A884);
}

.scdd-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.scdd-item-sub {
    flex-shrink: 0;
    color: var(--sub, #8696a0);
    font-size: 11px;
    font-weight: 400;
    margin-left: 8px;
}
/* When custom renderers stack label + subtitle vertically, support a column variant. */
.scdd-item.scdd-item-stack {
    flex-direction: row;
    align-items: flex-start;
}
.scdd-item.scdd-item-stack .scdd-item-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.scdd-item.scdd-item-stack .scdd-item-sub {
    margin-left: 0;
}

/* Selected check icon (default renderer only). */
.scdd-item-check {
    display: none;
    flex-shrink: 0;
    color: var(--teal, #00A884);
}
.scdd-item.is-selected .scdd-item-check {
    display: inline-flex;
}

/* ═══════════════════════════════════════════════════════════════
   Empty / loading states
   ═══════════════════════════════════════════════════════════════ */
.scdd-empty,
.scdd-loading {
    padding: 16px 12px;
    color: var(--muted, #4a5568);
    font-size: 12px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   Mobile bottom-sheet
   ═══════════════════════════════════════════════════════════════ */
.scdd-sheet-handle,
.scdd-sheet-close {
    display: none;
}

@media (max-width: 640px) {
    .scdd-popup.is-mobile {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 70vh !important;
        border-radius: 14px 14px 0 0;
        padding-top: 18px;
        animation: scdd-sheet-up 180ms ease;
    }
    .scdd-popup.is-mobile .scdd-sheet-handle {
        display: block;
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: var(--line-em, #3d5060);
    }
    .scdd-popup.is-mobile .scdd-sheet-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 12px;
        right: 12px;
        width: 28px;
        height: 28px;
        background: transparent;
        border: none;
        color: var(--sub, #8696a0);
        cursor: pointer;
        border-radius: 6px;
    }
    .scdd-popup.is-mobile .scdd-sheet-close:hover {
        background: var(--panel, var(--hover, rgba(0,0,0,.05)));
        color: var(--text, #1a202c);
    }
    .scdd-popup.is-mobile .scdd-listbox {
        max-height: calc(70vh - 80px);
    }
    .scdd-popup.is-mobile .scdd-item {
        min-height: 44px;
        padding: 10px 14px;
    }
}

@keyframes scdd-sheet-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
