/* ============================================
   🔍 検索機能強化 CSS
   ============================================
   Google風サジェストデザイン
   ============================================ */

/* サジェストコンテナ */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 10000;
    margin-top: 0;
}

/* スクロールバーカスタマイズ */
.search-suggestions::-webkit-scrollbar {
    width: 8px;
}

.search-suggestions::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.search-suggestions::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.search-suggestions::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* セクションタイトル */
.suggestion-section-title {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f9f9f9;
    border-bottom: 1px solid #e0e0e0;
}

/* サジェスト項目 */
.suggestion-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: #f5f5f5;
}

.suggestion-item.selected {
    background: #e8f0fe;
}

/* アイコン */
.suggestion-item i {
    color: #999;
    font-size: 0.9rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.suggestion-item:hover i,
.suggestion-item.selected i {
    color: #666;
}

/* 履歴アイコン */
.history-item i {
    color: #999;
}

/* テキスト */
.suggestion-text {
    flex: 1;
    font-size: 0.95rem;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ハイライト */
.suggestion-text mark {
    background: #fff9c4;
    color: #000;
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

/* 視聴数 */
.suggestion-views {
    font-size: 0.8rem;
    color: #999;
    flex-shrink: 0;
}

/* 結果なし */
.no-results {
    color: #999;
    cursor: default;
    justify-content: center;
}

.no-results:hover {
    background: transparent;
}

/* 削除ボタン */
.remove-history {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    margin-left: auto;
    flex-shrink: 0;
}

.remove-history:hover {
    background: #f0f0f0;
    color: #666;
}

.remove-history i {
    font-size: 0.75rem;
}

/* 検索フォームの位置調整 */
.search-form,
.search-container {
    position: relative;
}

/* 検索入力フォーカス時 */
.search-form input[name="q"]:focus {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* アニメーション */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-suggestions {
    animation: slideDown 0.2s ease-out;
}

/* ========================================
   ダークモード対応
   ======================================== */
.dark-mode .search-suggestions {
    background: #2a2a2a;
    border-color: #444;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.dark-mode .suggestion-section-title {
    background: #1e1e1e;
    color: #999;
    border-bottom-color: #444;
}

.dark-mode .suggestion-item {
    border-bottom-color: #333;
}

.dark-mode .suggestion-item:hover {
    background: #333;
}

.dark-mode .suggestion-item.selected {
    background: #2c4a6e;
}

.dark-mode .suggestion-text {
    color: #e0e0e0;
}

.dark-mode .suggestion-text mark {
    background: #5a5a00;
    color: #fff;
}

.dark-mode .suggestion-item i {
    color: #666;
}

.dark-mode .suggestion-item:hover i,
.dark-mode .suggestion-item.selected i {
    color: #999;
}

.dark-mode .suggestion-views {
    color: #666;
}

.dark-mode .no-results {
    color: #666;
}

.dark-mode .remove-history {
    color: #666;
}

.dark-mode .remove-history:hover {
    background: #444;
    color: #999;
}

.dark-mode .search-suggestions::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.dark-mode .search-suggestions::-webkit-scrollbar-thumb {
    background: #555;
}

.dark-mode .search-suggestions::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* ========================================
   モバイル対応
   ======================================== */
@media (max-width: 768px) {
    .search-suggestions {
        max-height: 300px;
        font-size: 0.9rem;
    }
    
    .suggestion-item {
        padding: 0.65rem 0.75rem;
        gap: 0.5rem;
    }
    
    .suggestion-item i {
        font-size: 0.85rem;
    }
    
    .suggestion-text {
        font-size: 0.9rem;
    }
    
    .suggestion-views {
        font-size: 0.75rem;
    }
    
    .suggestion-section-title {
        padding: 0.6rem 0.75rem;
        font-size: 0.7rem;
    }
    
    .remove-history {
        padding: 0.25rem 0.4rem;
    }
}

/* ========================================
   アクセシビリティ
   ======================================== */

/* フォーカス表示 */
.suggestion-item:focus {
    outline: 2px solid #4285f4;
    outline-offset: -2px;
}

.remove-history:focus {
    outline: 2px solid #4285f4;
    outline-offset: 2px;
}

/* 高コントラストモード */
@media (prefers-contrast: high) {
    .search-suggestions {
        border-width: 2px;
    }
    
    .suggestion-item {
        border-bottom-width: 2px;
    }
    
    .suggestion-text mark {
        outline: 2px solid currentColor;
    }
}

/* モーション縮小モード */
@media (prefers-reduced-motion: reduce) {
    .search-suggestions {
        animation: none;
    }
    
    .suggestion-item {
        transition: none;
    }
    
    .remove-history {
        transition: none;
    }
}

/* ========================================
   印刷時は非表示
   ======================================== */
@media print {
    .search-suggestions {
        display: none !important;
    }
}