/**
 * Kitchen CRM — поля и выпадающие списки
 */

/* —— Нативный select (fallback до JS) —— */
html.kcrm-theme select:not(.kcrm-select__native) {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 42px;
    cursor: pointer;
    border-radius: 12px;
}

html.kcrm-theme[data-kcrm-theme="dark"]
    select:not(.kcrm-select__native) option {
    background: #1e293b;
    color: #f8fafc;
}

html.kcrm-theme[data-kcrm-theme="light"]
    select:not(.kcrm-select__native) option {
    background: #fff;
    color: #1c2329;
}

/* —— Кастомный select (kcrm-select.js) —— */
.kcrm-select {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
}

.kcrm-select__native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.kcrm-select__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

.kcrm-select__trigger::after {
    content: "";
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.18s ease;
}

.kcrm-select.is-open .kcrm-select__trigger::after {
    transform: rotate(180deg);
}

.kcrm-select__trigger:hover {
    border-color: color-mix(in srgb, #1f8f5f 35%, var(--border));
}

.kcrm-select__trigger:focus {
    outline: none;
    border-color: var(--green-600, #1f8f5f);
    box-shadow: 0 0 0 4px rgba(31, 143, 95, 0.12);
}

html.kcrm-theme[data-kcrm-theme="dark"] .kcrm-select__trigger:focus {
    border-color: #7ed957;
    box-shadow: 0 0 0 3px rgba(126, 217, 87, 0.28);
}

.kcrm-select__menu {
    position: absolute;
    z-index: 200;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    margin: 0;
    padding: 6px;
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    background: var(--bg-card);
    box-shadow:
        0 16px 40px rgba(15, 23, 42, 0.14),
        0 2px 8px rgba(15, 23, 42, 0.08);
}

html.kcrm-theme[data-kcrm-theme="dark"] .kcrm-select__menu {
    background: #111827;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.kcrm-select__menu[hidden] {
    display: none !important;
}

.kcrm-select__option {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text);
    cursor: pointer;
}

.kcrm-select__option:hover {
    background: var(--green-softer, #f4faf7);
}

.kcrm-select__option.is-selected {
    background: var(--green-soft, #e8f3ec);
    color: var(--green-800, #176b45);
}

html.kcrm-theme[data-kcrm-theme="dark"] .kcrm-select__option:hover {
    background: #1e293b;
    color: #f8fafc;
}

html.kcrm-theme[data-kcrm-theme="dark"] .kcrm-select__option.is-selected {
    background: rgba(126, 217, 87, 0.16);
    color: #7ed957;
}

.kcrm-select.is-open .kcrm-select__trigger {
    border-color: var(--green-600, #1f8f5f);
}

html.kcrm-theme[data-kcrm-theme="dark"]
    .kcrm-select.is-open
    .kcrm-select__trigger {
    border-color: #7ed957;
    box-shadow: 0 0 0 3px rgba(126, 217, 87, 0.22);
}

/* Тёмная тема: закрытое поле */
html.kcrm-theme[data-kcrm-theme="dark"] .kcrm-select__trigger {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
}

html.kcrm-theme[data-kcrm-theme="dark"]
    .kcrm-select__trigger::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
