/* ========== ComboBox Portal Styles (Global) ========== */
/* Applied to the JS-created portal container in <body> */

.combo-panel {
    position: fixed;
    background: white;
    border: 1px solid #e0e2e7;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    z-index: 10000;

    /* Flex column so search stays pinned and list fills remaining space */
    display: flex;
    flex-direction: column;

    /* Entry animation */
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.combo-panel.combo-portal-active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.combo-panel.combo-portal-upward {
    transform-origin: bottom;
}

/* ========== Search header (integrated, no box) ========== */
.combo-panel .combo-search {
    flex-shrink: 0;
    border-bottom: 1px solid #e0e2e7;
    background: #f9fafb;
}

.combo-panel .combo-search-input {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 0;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    color: var(--bs-body-color);
    box-sizing: border-box;
}

.combo-panel .combo-search-input:focus {
    outline: none;
}

.combo-panel .combo-search-input::placeholder {
    color: #adb5bd;
}

/* ========== Scrollable list (fills remaining space) ========== */
.combo-panel .combo-list {
    flex: 1 1 auto;
    min-height: 0; /* crucial for flex child to shrink and scroll */
    overflow-y: auto;
    overflow-x: hidden;
}

.combo-panel .combo-list::-webkit-scrollbar {
    width: 8px;
}

.combo-panel .combo-list::-webkit-scrollbar-track {
    background: transparent;
}

.combo-panel .combo-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.combo-panel .combo-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========== Items ========== */
.combo-panel .combo-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color 0.1s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.combo-panel .combo-item:hover {
    background: #f8f9fa;
}

.combo-panel .combo-item.is-selected {
    background: var(--bs-primary);
    color: #fff;
    font-weight: 500;
}

.combo-panel .combo-item:active {
    background: #fffbeb;
}

/* ========== Empty ========== */
.combo-panel .combo-empty {
    padding: 20px 14px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

/* ========== Null / Not-applicable option ========== */
.combo-panel .combo-item.combo-item-null {
    color: #6c757d;
    font-style: italic;
    border-bottom: 1px solid #e0e2e7;
}

.combo-panel .combo-item.combo-item-null:hover {
    background: #f8f9fa;
    color: var(--bs-body-color);
}

.combo-panel .combo-item.combo-item-null.is-selected {
    background: var(--bs-primary);
    color: #fff;
    font-style: normal;
}

/* ========== Lazy Loading Indicator ========== */
.combo-panel .combo-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    color: #6c757d;
    font-size: 14px;
    flex-shrink: 0;
}

.combo-panel .combo-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e0e2e7;
    border-top-color: var(--bs-primary);
    border-radius: 50%;
    animation: combo-spin 0.6s linear infinite;
}

@keyframes combo-spin {
    to { transform: rotate(360deg); }
}

/* ========== Manual Input Section ========== */
.combo-panel .combo-manual-separator {
    padding: 8px 14px;
    text-align: center;
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.combo-panel .combo-manual-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
}

.combo-panel .combo-manual-input {
    flex: 1;
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid #e0e2e7;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--bs-body-color);
    transition: border-color 0.15s ease;
    flex-shrink: 0;
    border-top: 1px solid #e0e2e7;
    background: #f9fafb;
}

.combo-panel .combo-manual-input:focus {
    outline: none;
    border-color: var(--bs-primary);
}

.combo-panel .combo-manual-input::placeholder {
    color: #adb5bd;
}

.combo-panel .combo-manual-submit {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.combo-panel .combo-manual-submit:hover {
    background: var(--bs-primary-dark, #d4a006);
}

.combo-panel .combo-manual-submit:active {
    transform: scale(0.95);
}

/* ========== Responsive ========== */
@media (max-width: 576px) {
    .combo-panel {
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
    }
}
