/* ========================================
   Search Input Component
   共用搜尋欄位樣式 - 適用於所有頁面
   ======================================== */

/* Search Input Wrapper */
.search-input-wrapper {
    position: relative;
    width: 340px;
    min-width: 116px;
    height: 42px;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #999999;
    pointer-events: none;
    z-index: 2;
}

/* Search Container (Zendesk form[role='search']) */
.search-input-wrapper .search,
.search-input-wrapper form[role="search"] {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    border: none;
    border-radius: 8px;
    background-color: transparent;
}

/* Search Input Field */
.search-input-wrapper .search input[type="search"],
.search-input-wrapper form[role="search"] input[type="search"],
.search-input-wrapper input[type="search"] {
    width: 100%;
    height: 42px;
    min-width: 116px;
    padding: 0 40px 0 40px; /* 左右預留空間給 icon 和 clear button */
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #1A1A1A;
    background-color: #F4F4F5;
    border: none;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.search-input-wrapper .search input[type="search"]::placeholder,
.search-input-wrapper form[role="search"] input[type="search"]::placeholder,
.search-input-wrapper input[type="search"]::placeholder {
    color: #A1A1AA;
    font-weight: 400;
}

/* Hover State */
.search-input-wrapper .search input[type="search"]:hover,
.search-input-wrapper form[role="search"] input[type="search"]:hover,
.search-input-wrapper input[type="search"]:hover {
    background-color: #E4E4E7;
}

/* Focus State */
.search-input-wrapper .search input[type="search"]:focus,
.search-input-wrapper form[role="search"] input[type="search"]:focus,
.search-input-wrapper input[type="search"]:focus {
    background-color: #FFFFFF;
    box-shadow: 0 0 0 2px #FF6400;
}

/* Remove default search cancel button */
.search-input-wrapper input[type="search"]::-webkit-search-cancel-button,
.search-input-wrapper input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

/* ========================================
   Clear Button - Zendesk 預設結構
   整合在搜尋欄位內，色系一致
   ======================================== */

/* Clear Button 基本樣式 */
.search-input-wrapper .clear-button,
.search-input-wrapper form[role="search"] .clear-button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    padding: 6px;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #A1A1AA; /* 與 placeholder 相同色系 */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.15s ease;
    z-index: 3;
}

/* Clear Button SVG Icon */
.search-input-wrapper .clear-button svg,
.search-input-wrapper form[role="search"] .clear-button svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* 當搜尋框有值時顯示 Clear Button */
.search-input-wrapper .search-has-value .clear-button,
.search-input-wrapper form[role="search"].search-has-value .clear-button,
.search-input-wrapper.search-has-value .clear-button {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Clear Button Hover 狀態 */
.search-input-wrapper .clear-button:hover,
.search-input-wrapper form[role="search"] .clear-button:hover {
    color: #71717A; /* 深一點的灰色 */
    background-color: rgba(0, 0, 0, 0.05);
}

/* Clear Button Focus 狀態 */
.search-input-wrapper .clear-button:focus,
.search-input-wrapper form[role="search"] .clear-button:focus {
    outline: none;
    color: #52525B;
    background-color: rgba(0, 0, 0, 0.08);
}

/* Clear Button Active 狀態 */
.search-input-wrapper .clear-button:active,
.search-input-wrapper form[role="search"] .clear-button:active {
    background-color: rgba(0, 0, 0, 0.1);
}

/* ========================================
   Responsive - Search Input
   ======================================== */
@media (max-width: 1024px) {
    .search-input-wrapper {
        width: 100%;
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .search-input-wrapper {
        max-width: 100%;
    }
}
