/* ============================================
   MOTOR EXPERT — PortalSelect CSS
   Custom dropdown styling pro klientský portál
   
   Prefix: ps- (Portal Select)
   Designově identické s admin dt-select,
   přizpůsobené pro portal CSS variables.
   ============================================ */

/* ── Container ── */
.ps-select {
    position: relative;
    min-width: 140px;
    display: inline-block;
}

/* ── Trigger Button ── */
.ps-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    height: 36px;
    padding: 0 12px;
    background: var(--portal-card, #fff);
    border: 2px solid var(--portal-border, #e5e7eb);
    border-radius: var(--radius-sm, 8px);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--portal-text, #1f2937);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    outline: none;
}

.ps-trigger:hover:not(.disabled) {
    border-color: var(--portal-primary, #2d8a4e);
    background: var(--portal-primary-light, #e8f5ec);
}

.ps-trigger.open {
    border-color: var(--portal-primary, #2d8a4e);
    box-shadow: 0 0 0 3px rgba(45, 138, 78, 0.12);
}

.ps-trigger.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f9fafb;
}

/* Chevron icon */
.ps-trigger .ps-icon {
    width: 15px;
    height: 15px;
    color: var(--portal-text-light, #6b7280);
    transition: transform 0.2s ease, color 0.15s ease;
    flex-shrink: 0;
}

.ps-trigger.open .ps-icon {
    transform: rotate(180deg);
    color: var(--portal-primary, #2d8a4e);
}

/* Value display */
.ps-value {
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: left;
}

.ps-value.placeholder {
    color: var(--portal-text-light, #6b7280);
    font-weight: 400;
}

/* ── Dropdown ── */
.ps-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    max-height: 280px;
    background: var(--portal-card, #fff);
    border: 1px solid var(--portal-border, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: 1000;
    padding: 4px;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    display: flex;
    flex-direction: column;
}

.ps-dropdown.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Scrollbar */
.ps-options {
    overflow-y: auto;
    flex: 1;
}

.ps-options::-webkit-scrollbar {
    width: 5px;
}

.ps-options::-webkit-scrollbar-track {
    background: transparent;
}

.ps-options::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* ── Options ── */
.ps-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    font-size: 14px;
    color: var(--portal-text, #1f2937);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s ease;
    white-space: nowrap;
}

.ps-option:hover {
    background: #f3f4f6;
}

.ps-option.selected {
    color: var(--portal-primary-dark, #1a5a32);
    font-weight: 500;
    background: var(--portal-primary-light, #e8f5ec);
}

.ps-option.selected:hover {
    background: #dcfce7;
}

.ps-option.hidden {
    display: none;
}

/* Checkmark */
.ps-check {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--portal-primary, #2d8a4e);
}

.ps-icon-check {
    width: 14px;
    height: 14px;
}

.ps-option-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Search box ── */
.ps-search-wrap {
    padding: 6px 6px 4px;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 2px;
    flex-shrink: 0;
}

.ps-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--portal-border, #e5e7eb);
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    color: var(--portal-text, #1f2937);
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.ps-search::placeholder {
    color: #9ca3af;
}

.ps-search:focus {
    border-color: var(--portal-primary, #2d8a4e);
    box-shadow: 0 0 0 3px rgba(45, 138, 78, 0.12);
}

/* ── Form context (full-width, taller) ── */
.ps-form {
    width: 100%;
    min-width: 0;
}

.ps-form .ps-trigger {
    height: 42px;
    font-weight: 400;
    font-size: 14px;
    padding: 0 14px;
}

.ps-form .ps-dropdown {
    max-width: 100%;
    right: 0;
}

.ps-form .ps-option {
    white-space: normal;
    line-height: 1.35;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .ps-select {
        min-width: 0;
        width: 100%;
    }

    .ps-trigger {
        width: 100%;
    }

    .ps-dropdown {
        max-width: calc(100vw - 40px);
    }
    
    /* Filter groups stack on mobile */
    .filter-group .ps-select {
        min-width: 120px;
    }
}

@media (max-width: 600px) {
    .ps-trigger {
        height: 42px;
        font-size: 15px;
    }

    .ps-option {
        padding: 10px 12px;
        font-size: 15px;
    }
    
    .ps-search {
        font-size: 16px; /* prevent iOS zoom */
    }
}