/**
 * search_box.css
 * -----------------------------------------------------------------
 * portal_search_box 컴포넌트 전용 스타일. 특정 테마 클래스에 의존하지 않고
 * .portal_search_box 하위로만 스코프되어 있어 다른 테마에 그대로 이식 가능.
 * 사이트의 다크모드 토글(html[data-theme="dark"])과 자동으로 연동됩니다.
 * -----------------------------------------------------------------
 */

.portal_search_box {
    --psb-border: #dadada;
    --psb-bg: #fff;
    --psb-text: #222;
    --psb-sub: #888;
    --psb-accent: #2db400;
    --psb-hover: #f5f5f5;
    --psb-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);

    position: relative;
    width: 100%;
    max-width: 520px;
}

html[data-theme="dark"] .portal_search_box {
    --psb-border: #444;
    --psb-bg: #2a2a2a;
    --psb-text: #eee;
    --psb-sub: #aaa;
    --psb-hover: #383838;
    --psb-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.psb_form {
    display: flex;
    align-items: center;
    border: 2px solid var(--psb-border);
    border-radius: 24px;
    background: var(--psb-bg);
    padding: 4px 6px 4px 16px;
    transition: border-color 0.15s ease;
}
.psb_form:focus-within { border-color: var(--psb-accent); }

.psb_input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--psb-text);
    font-size: 15px;
    padding: 8px 4px;
    min-width: 0;
}

.psb_keyboard_btn, .psb_submit_btn {
    border: 0;
    background: transparent;
    color: var(--psb-sub);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.psb_keyboard_btn:hover, .psb_submit_btn:hover { background: var(--psb-hover); }
.psb_submit_btn { color: #fff; background: var(--psb-accent); }
.psb_submit_btn:hover { background: var(--psb-accent); opacity: 0.9; }

/* ---------------- 가상 키보드 패널 ----------------
 * position:fixed 사용: GNB 등 상위 요소가 자체 stacking context를 만들면
 * position:absolute + z-index 조합은 그 안에 갇혀 무력화된다. fixed는 뷰포트
 * 기준으로 배치되어 이 문제를 원천적으로 피할 수 있다 (좌표는 JS의
 * _positionPanel/_makeDraggable 이 계산해서 style.left/top/width로 지정). */
.psb_keyboard_panel {
    display: none;
    position: fixed;
    background: var(--psb-bg);
    border: 1px solid var(--psb-border);
    border-radius: 12px;
    box-shadow: var(--psb-shadow);
    padding: 12px;
    z-index: 99990;
}
.psb_keyboard_panel.psb_open { display: block; }

.psb_kb_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--psb-border);
    cursor: move;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}
.psb_kb_title { font-size: 13px; font-weight: 600; color: var(--psb-sub); }
.psb_kb_header_close {
    border: 0;
    background: none;
    color: var(--psb-sub);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
}
.psb_kb_header_close:hover { color: var(--psb-text); }

.psb_kb_row {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
    justify-content: center;
}

.psb_key {
    flex: 1;
    min-width: 0;
    max-width: 52px;
    height: 40px;
    border: 1px solid var(--psb-border);
    border-radius: 6px;
    background: var(--psb-bg);
    color: var(--psb-text);
    font-size: 15px;
    cursor: pointer;
}
.psb_key:hover { background: var(--psb-hover); }
.psb_key_active { background: var(--psb-accent); color: #fff; border-color: var(--psb-accent); }
.psb_key_wide { flex: 1.4; max-width: 90px; font-size: 13px; }
.psb_key_shift { flex: 1; max-width: 56px; }
.psb_key_space { flex: 4; max-width: none; }
.psb_key_reset { flex: 1; max-width: 90px; font-size: 13px; background: var(--psb-hover); color: var(--psb-sub); }
.psb_key_search {
    flex: 1;
    max-width: 100px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--psb-accent);
    border-color: var(--psb-accent);
}
.psb_key_search:hover { background: var(--psb-accent); opacity: 0.9; }

/* ---------------- 자동완성 패널 ---------------- */
.psb_ac_panel {
    display: none;
    position: fixed;
    background: var(--psb-bg);
    border: 1px solid var(--psb-border);
    border-radius: 12px;
    box-shadow: var(--psb-shadow);
    overflow: hidden;
    z-index: 99980;
}
.psb_ac_panel.psb_open { display: block; }

.psb_ac_list { padding: 6px 0; max-height: 320px; overflow-y: auto; }

.psb_ac_head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px 4px;
    font-size: 12px;
    color: var(--psb-sub);
}
.psb_ac_clear_all { border: 0; background: none; color: var(--psb-sub); cursor: pointer; font-size: 12px; text-decoration: underline; }

.psb_ac_item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    cursor: pointer;
    color: var(--psb-text);
}
.psb_ac_item:hover { background: var(--psb-hover); }
.psb_ac_label { flex: 1; font-size: 14px; }
.psb_ac_del { border: 0; background: none; color: var(--psb-sub); cursor: pointer; font-size: 16px; padding: 0 4px; }

.psb_ac_settings {
    border-top: 1px solid var(--psb-border);
    padding: 12px 16px;
}
.psb_ac_login_msg {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--psb-sub);
    text-align: center;
}
.psb_ac_toggle_row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--psb-text);
}

.psb_switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.psb_switch input { opacity: 0; width: 0; height: 0; }
.psb_switch_slider {
    position: absolute; inset: 0; background: var(--psb-border); border-radius: 22px;
    transition: 0.15s;
}
.psb_switch_slider::before {
    content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: 0.15s;
}
.psb_switch input:checked + .psb_switch_slider { background: var(--psb-accent); }
.psb_switch input:checked + .psb_switch_slider::before { transform: translateX(16px); }
.psb_switch input:disabled + .psb_switch_slider { opacity: 0.5; cursor: not-allowed; }

.psb_ac_close {
    display: block;
    margin: 10px auto 0;
    border: 0;
    background: none;
    color: var(--psb-sub);
    cursor: pointer;
    font-size: 12px;
}

@media (max-width: 480px) {
    .psb_key { max-width: none; font-size: 14px; }
    .psb_key_wide { font-size: 11px; }
}

#portal_header .search_wrap input {
    width: 380px;
    height: 44px; /* 높이 강제 고정 추가 */
    box-sizing: border-box; /* 패딩을 포함한 높이 계산 보정 */
    padding: 10px 18px;
    border: none;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    color: #1a1a1a;
    background: transparent;
}
#portal_header .search_wrap form > button[type="submit"] {
    padding: 0 22px;
    background: var(--portal-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-family: inherit;
    font-weight: 700;
    transition: background 0.15s;
}