/* src/components/basic/XWUIInputSelect/XWUIInputSelect.css */
/**
 * XWUIInputSelect Component Styles
 * 
 * Style Dependencies:
 * - Base: reset.css, typography.css, utilities.css
 * - Brand: brand/xwui/brand.css
 * - Style: style/modern/spacing.css, style/modern/shadows.css
 * - Theme: theme/colors/{selected-theme}.css (MANDATORY - provides all color variables)
 * - Theme: theme/accents/{selected-accent}.css (MANDATORY - provides accent color variables)
 * - Lines: theme/lines/input/*.css (component-specific border widths)
 * - Roundness: theme/roundness/input/*.css (component-specific roundness)
 * - Typography: theme/typography/*.css
 */

.xwui-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--xwui-field-label-gap, 0.375rem);
    position: relative;
}

.xwui-select-full-width {
    width: 100%;
}

/* Label */
.xwui-select-label {
    font-size: var(--xwui-field-label-size, var(--font-size-sm, 0.875rem));
    font-weight: var(--xwui-field-label-weight, var(--font-weight-medium, 500));
    font-family: var(--xwui-field-label-family, var(--font-label-family, var(--font-family-base, sans-serif)));
    line-height: var(--xwui-field-label-line-height, 1.5);
    color: var(--xwui-field-label-color, var(--text-primary));
}

/* ── Floating label (Material style) ─────────────────────────────────────────
   `data.label` rides inside the trigger as the placeholder when empty and floats
   up when the dropdown is open ("wanna fill") or a value is selected. Mirrors
   XWUIInputText's floatingLabel so selects and text fields behave identically. */
.xwui-select-floating .xwui-select-trigger {
    position: relative;
}
.xwui-select-float-label {
    position: absolute;
    left: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    padding: 0 0.25rem;
    max-width: calc(100% - 3rem);
    color: var(--text-tertiary, #94a3b8);
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: var(--font-weight-medium, 500);
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    transform-origin: left center;
    transition: top 0.16s ease, transform 0.16s ease, color 0.16s ease;
    z-index: 1;
}
/* RTL pages: the label anchors with a physical `left`, so mirror it - the
   float label belongs at the field's start edge in both directions. */
html[dir="rtl"] .xwui-select-float-label {
    left: auto;
    right: 0.625rem;
    transform-origin: right center;
}
.xwui-select-floating.xwui-select-float-up .xwui-select-float-label {
    top: 0;
    transform: translateY(-50%) scale(0.8);
}
.xwui-select-floating.xwui-select-float-focus .xwui-select-float-label {
    color: var(--accent-primary, #4f46e5);
}
.xwui-select-floating.xwui-select-error.xwui-select-float-focus .xwui-select-float-label {
    color: var(--accent-error, #ef4444);
}
.xwui-select-floating.xwui-select-outlined.xwui-select-float-up .xwui-select-float-label {
    background: var(--bg-primary, #ffffff);
}
.xwui-select-floating.xwui-select-filled.xwui-select-float-up .xwui-select-float-label {
    top: var(--xwui-select-float-filled-label-top, 0.69rem);
    transform: scale(0.8);
    background: transparent;
}
/* When the label floats, seat the value on the bottom row so it never collides
   with the shrunken label. Padding tokens are set on the wrapper from TS
   (FLOAT_TRIGGER_PAD in XWUIInputSelect.ts). Specificity must beat the per-size
   `padding:` shorthand on `.xwui-select-trigger`. */
.xwui-select-floating.xwui-select-float-up .xwui-select-trigger {
    align-items: flex-end;
}
.xwui-select-floating.xwui-select-float-up .xwui-select-value {
    line-height: 1.25;
}
.xwui-select-floating.xwui-select-float-up:is(.xwui-select-s,.xwui-select-sm,.xwui-select-xs,.xwui-select-xxs,.xwui-select-xxxs,.xwui-select-xxxxs,.xwui-select-m,.xwui-select-md,.xwui-select-l,.xwui-select-lg,.xwui-select-xl,.xwui-select-xxl,.xwui-select-xxxl,.xwui-select-xxxxl) .xwui-select-trigger {
    padding: var(--xwui-select-float-pad-top, 1.4375rem) var(--xwui-select-float-pad-inline, var(--spacing-sm, 0.875rem)) var(--xwui-select-float-pad-bottom, 0.5175rem);
    /* Beats the size-rule height lock (same token, extra :is). */
    height: auto;
}

/* Trigger */
.xwui-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    box-sizing: border-box;
    line-height: var(--xwui-control-line-height, 1);
    border-radius: var(--radius-input, var(--radius-md, 6px));
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Outlined variant */
.xwui-select-outlined .xwui-select-trigger {
    border: var(--border-input-width, var(--border-width-regular, 1.5px)) var(--border-input-style, solid) var(--border-input-color, var(--border-color, #dee2e6));
    background: var(--bg-primary, #ffffff);
}

.xwui-select-outlined .xwui-select-trigger:hover {
    border-color: var(--border-strong, #adb5bd);
}

.xwui-select-outlined.xwui-select-open .xwui-select-trigger {
    border-color: var(--accent-primary, #4f46e5);
    box-shadow: var(--shadow-xs);
}

/* Filled variant */
.xwui-select-filled .xwui-select-trigger {
    border: var(--border-input-width, var(--border-width-regular, 1.5px)) var(--border-input-style, solid) transparent;
    background: var(--bg-secondary, #f8f9fa);
}

.xwui-select-filled .xwui-select-trigger:hover {
    background: var(--bg-tertiary, #f1f3f5);
}

.xwui-select-filled.xwui-select-open .xwui-select-trigger {
    background: var(--bg-primary, #ffffff);
    border-color: var(--accent-primary, #4f46e5);
}

/* Size variants - canonical 11-step scale: xxxxs|xxxs|xxs|xs|sm|md|lg|xl|xxl|xxxl|xxxxl.
   Smaller-than-sm sizes are needed for dense grids/cells; larger sizes mirror
   the rest of the xwui scale. */
:is(.xwui-select-4xs,.xwui-select-xxxxs) .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-xxxxs, 1px) var(--xwui-size-pad-x-xxxxs, 3px);
    font-size: var(--xwui-size-font-xxxxs, 8px);
    height: var(--xwui-select-height-xxxxs);
    min-height: var(--xwui-select-height-xxxxs);
}
:is(.xwui-select-3xs,.xwui-select-xxxs) .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-xxxs, 1px) var(--xwui-size-pad-x-xxxs, 4px);
    font-size: var(--xwui-size-font-xxxs, 9px);
    height: var(--xwui-select-height-xxxs);
    min-height: var(--xwui-select-height-xxxs);
}
:is(.xwui-select-2xs,.xwui-select-xxs) .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-xxs, 2px) var(--xwui-size-pad-x-xxs, 6px);
    font-size: var(--xwui-size-font-xxs, 10px);
    height: var(--xwui-select-height-xxs);
    min-height: var(--xwui-select-height-xxs);
}
.xwui-select-xs .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-xs, 3px) var(--xwui-size-pad-x-xs, 8px);
    font-size: var(--xwui-size-font-xs, 11px);
    height: var(--xwui-select-height-xs);
    min-height: var(--xwui-select-height-xs);
}
:is(.xwui-select-s,.xwui-select-sm) .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-sm, 4px) var(--xwui-size-pad-x-sm, 10px);
    font-size: var(--xwui-size-font-sm, 12px);
    height: var(--xwui-select-height-sm);
    min-height: var(--xwui-select-height-sm);
}

:is(.xwui-select-m,.xwui-select-md) .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-md, 6px) var(--xwui-size-pad-x-md, 14px);
    font-size: var(--xwui-size-font-md, 14px);
    height: var(--xwui-select-height-md);
    min-height: var(--xwui-select-height-md);
}

:is(.xwui-select-l,.xwui-select-lg) .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-lg, 8px) var(--xwui-size-pad-x-lg, 18px);
    font-size: var(--xwui-size-font-lg, 16px);
    height: var(--xwui-select-height-lg);
    min-height: var(--xwui-select-height-lg);
}
.xwui-select-xl .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-xl, 10px) var(--xwui-size-pad-x-xl, 22px);
    font-size: var(--xwui-size-font-xl, 20px);
    height: var(--xwui-select-height-xl);
    min-height: var(--xwui-select-height-xl);
}
:is(.xwui-select-2xl,.xwui-select-xxl) .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-xxl, 12px) var(--xwui-size-pad-x-xxl, 28px);
    font-size: var(--xwui-size-font-xxl, 24px);
    height: var(--xwui-select-height-xxl);
    min-height: var(--xwui-select-height-xxl);
}
:is(.xwui-select-3xl,.xwui-select-xxxl) .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-xxxl, 16px) var(--xwui-size-pad-x-xxxl, 36px);
    font-size: var(--xwui-size-font-xxxl, 32px);
    height: var(--xwui-select-height-xxxl);
    min-height: var(--xwui-select-height-xxxl);
}
:is(.xwui-select-4xl,.xwui-select-xxxxl) .xwui-select-trigger {
    padding: var(--xwui-size-pad-y-xxxxl, 24px) var(--xwui-size-pad-x-xxxxl, 56px);
    font-size: var(--xwui-size-font-xxxxl, 48px);
    height: var(--xwui-select-height-xxxxl);
    min-height: var(--xwui-select-height-xxxxl);
}

/* Value display */
.xwui-select-value {
    flex: 1;
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary, #212529);
}

.xwui-select-trigger:not(:has(.xwui-select-value:not(:empty))) .xwui-select-value {
    color: var(--text-tertiary, #adb5bd);
}

/* Icons */
.xwui-select-icons {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs, 0.25rem);
    flex-shrink: 0;
}

.xwui-select-arrow {
    display: flex;
    align-items: center;
    color: var(--text-secondary, #6c757d);
    transition: transform 0.2s;
}

.xwui-select-arrow svg {
    width: 16px;
    height: 16px;
}

.xwui-select-open .xwui-select-arrow {
    transform: rotate(180deg);
}

.xwui-select-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-tertiary, #adb5bd);
    transition: color 0.2s;
}

.xwui-select-clear:hover {
    color: var(--text-secondary, #6c757d);
}

.xwui-select-clear svg {
    width: 14px;
    height: 14px;
}

/* Dropdown - floats above every other card / row / table.
   The `.xwui-select-open` rule below promotes the host element into its
   own stacking context so the panel clears its siblings even when the
   containing column uses grid/flex layout. */
.xwui-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bg-primary, #ffffff);
    border: var(--border-input-width, var(--border-width-regular, 1.5px)) var(--border-input-style, solid) var(--border-input-color, var(--border-color, #dee2e6));
    border-radius: var(--radius-input, var(--radius-md, 6px));
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.15));
    /* Tokenized so a consuming app can slot the (body-portaled) panel into its
       own z-scale - e.g. BELOW a sticky site header - instead of always winning
       at 9999. Default stays 9999 so selects still open above modals/dialogs. */
    z-index: var(--xwui-select-dropdown-z, 9999);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.xwui-select-open {
    /* The panel portals to <body> while open (see open()), so it no longer
       lives under this host. Promoting the host to a high z-index therefore
       does nothing for the panel and actively lifts the trigger/field above
       app chrome (e.g. a sticky site header) - so the host is NOT promoted.
       Only the portaled panel carries the overlay z-index (below). */
    position: relative;
}
.xwui-select-open .xwui-select-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
/* While open the panel is portaled to <body> (see XWUIInputSelect.ts open()), so it
   is no longer a descendant of `.xwui-select-open`. It carries its own open-state
   class to drive the same reveal transition from wherever it is mounted. */
.xwui-select-dropdown.xwui-select-dropdown-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
/* Host element - xwui-input-select. The open panel is portaled to <body>, so
   the host has nothing to lift and must NOT create a high-z stacking context
   (that would push the trigger above a sticky header / other app chrome). */
xwui-input-select:has(.xwui-select-open),
xwui-input-select.xwui-open {
    position: relative;
}

/* Search */
.xwui-select-search {
    padding: var(--spacing-sm, 0.5rem);
    border-bottom: 1px solid var(--border-color, #dee2e6);
}

.xwui-select-search-input {
    width: 100%;
    padding: var(--spacing-sm, 0.5rem) var(--spacing-sm, 0.75rem);
    border: var(--border-input-width, var(--border-width-regular, 1.5px)) var(--border-input-style, solid) var(--border-input-color, var(--border-color, #dee2e6));
    border-radius: var(--radius-input, var(--radius-sm, 4px));
    font-size: var(--font-size-sm, 0.875rem);
    outline: none;
}

.xwui-select-search-input:focus {
    border-color: var(--accent-primary, #4f46e5);
}

/* Options */
.xwui-select-options {
    overflow-y: auto;
    max-height: inherit;
}

.xwui-select-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: var(--spacing-sm, 0.625rem) var(--spacing-sm, 0.875rem);
    cursor: pointer;
    transition: background 0.1s;
}

.xwui-select-option:hover {
    background: var(--bg-hover, #f8f9fa);
}

.xwui-select-option-selected {
    background: var(--bg-hover);
}

.xwui-select-option-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.xwui-select-option-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: var(--border-input-width, var(--border-width-thick, 2px)) var(--border-input-style, solid) var(--border-input-color, var(--border-color, #dee2e6));
    border-radius: var(--radius-input, var(--radius-xs, 3px));
    color: var(--text-inverse);
    flex-shrink: 0;
}

.xwui-select-option-selected .xwui-select-option-checkbox {
    background: var(--accent-primary, #4f46e5);
    border-color: var(--accent-primary, #4f46e5);
}

.xwui-select-option-checkbox svg {
    width: 12px;
    height: 12px;
}

.xwui-select-option-label {
    flex: 1;
    min-inline-size: 0;
    overflow-wrap: anywhere;
    color: var(--text-primary, #212529);
}

.xwui-select-option-check {
    color: var(--accent-primary, #4f46e5);
}

.xwui-select-option-check svg {
    width: 16px;
    height: 16px;
}

/* Groups */
.xwui-select-group {
    padding-top: var(--spacing-sm, 0.5rem);
}

.xwui-select-group:first-child {
    padding-top: 0;
}

.xwui-select-group-label {
    padding: var(--spacing-sm, 0.5rem) var(--spacing-sm, 0.875rem);
    font-size: var(--font-size-xs, 0.75rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-secondary, #6c757d);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Empty state */
.xwui-select-empty {
    padding: var(--spacing-md, 1rem);
    text-align: center;
    color: var(--text-secondary, #6c757d);
}

/* Helper text */
.xwui-select-helper {
    font-size: var(--font-size-xs, 0.75rem);
    color: var(--text-secondary, #6c757d);
}

.xwui-select-helper-error {
    color: var(--accent-error, #ef4444);
}

/* Error state */
.xwui-select-error .xwui-select-trigger {
    border-color: var(--accent-error, #ef4444) !important;
}

/* Disabled state */
.xwui-select-disabled .xwui-select-trigger {
    background: var(--bg-secondary, #f8f9fa);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Note: Dark theme support is handled automatically via theme/colors/{theme}.css files */


/* Per-option logo/image (XWUIInputSelectOption.image) - dropdown rows + selected
   trigger. Ported from XWUISelect. Inert unless an option supplies `image`. */
.xwui-select-option-image {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    object-fit: contain;
    border-radius: 4px;
}
.xwui-select-value {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.xwui-select-value-image {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    object-fit: contain;
    border-radius: 4px;
}
.xwui-select-value-text {
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Room under the line for descenders and Arabic marks: the trigger sets line-height 1, so the hidden overflow cut 2-3px
       off the bottom ("Company", "العالمية"). The negative margin gives the room back, so the control keeps its height. */
    padding-block: 0.25em;
    margin-block: -0.25em;
}
.xwui-select-value-placeholder {
    color: var(--text-tertiary, #adb5bd);
}

/* The panel is mounted on body, so its density must travel with it. */
.xwui-select-dropdown:is(.xwui-select-menu-xs,.xwui-select-menu-xxs,.xwui-select-menu-xxxs,.xwui-select-menu-xxxxs) .xwui-select-option {
    font-size: var(--xwui-size-font-xs, 11px);
    line-height: 1.35;
    padding: 5px 8px;
}
.xwui-select-dropdown:is(.xwui-select-menu-s,.xwui-select-menu-sm) .xwui-select-option {
    font-size: var(--xwui-size-font-sm, 12px);
    line-height: 1.35;
    padding: 6px 10px;
}

/* Generated native control surfaces: tools/build-styles/native-control-contract.mjs */
.xwui-select-search-input {
    height: var(--xwui-control-height, var(--xwui-input-height-md));
    min-height: var(--xwui-control-height, var(--xwui-input-height-md));
    box-sizing: border-box;
    font-family: var(--font-input-family, var(--font-family-base, sans-serif));
    font-size: var(--xwui-control-font-size, var(--xwui-size-font-md));
}
