/**
 * 头部搜索框样式 - 现代化设计
 * 
 * @package Hurricane_Movie_2025
 * @version 1.0.0
 */

/* ==========================================================================
   搜索框容器
   ========================================================================== */

.header-search-box {
    flex: 1;
    max-width: 500px;
    margin: 0 var(--spacing-lg);
    position: relative;
    z-index: 100;
}

.search-form {
    width: 100%;
}

/* ==========================================================================
   搜索输入框 - 圆角胶囊设计
   ========================================================================== */

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 44px;
    background: rgba(26, 26, 46, 0.8);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 22px; /* 胶囊形状 */
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 聚焦时的发光效果 */
.search-input-wrapper:focus-within {
    background: rgba(26, 26, 46, 0.95);
    border-color: var(--primary-color);
    box-shadow: 
        0 4px 16px rgba(102, 126, 234, 0.2),
        0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

/* ==========================================================================
   搜索图标
   ========================================================================== */

.search-icon {
    position: absolute;
    left: 16px;
    color: var(--text-secondary);
    flex-shrink: 0;
    pointer-events: none;
    transition: color 0.3s ease;
}

.search-input-wrapper:focus-within .search-icon {
    color: var(--primary-color);
}

/* ==========================================================================
   搜索输入框
   ========================================================================== */

.search-input {
    flex: 1;
    width: 100%;
    height: 100%;
    padding: 0 48px 0 48px; /* 左右留空给图标和按钮 */
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: var(--font-base);
    font-weight: 500;
    font-family: var(--font-primary);
    transition: all 0.3s ease;
}

/* Placeholder样式 */
.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
    font-weight: 400;
}

.search-input:focus::placeholder {
    opacity: 0.5;
}

/* 移除默认搜索框样式 */
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration {
    display: none;
}

/* ==========================================================================
   搜索按钮 - 渐变设计
   ========================================================================== */

.search-submit {
    position: absolute;
    right: 4px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.search-submit svg {
    flex-shrink: 0;
}

/* 悬停效果 */
.search-submit:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.search-submit:active {
    transform: scale(0.95);
}

/* ==========================================================================
   搜索建议下拉框（可选功能）
   ========================================================================== */

.search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    max-height: 400px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.search-suggestions.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: rgba(102, 126, 234, 0.1);
}

.suggestion-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-dark);
}

.suggestion-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.suggestion-content {
    flex: 1;
    min-width: 0;
}

.suggestion-title {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-meta {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.suggestion-type {
    padding: 2px 8px;
    background: rgba(102, 126, 234, 0.2);
    color: var(--primary-color);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ==========================================================================
   响应式设计 - 桌面端
   ========================================================================== */

@media (min-width: 1280px) {
    .header-search-box {
        max-width: 600px;
    }
}

/* ==========================================================================
   响应式设计 - 平板端
   ========================================================================== */

@media (max-width: 1024px) {
    .header-search-box {
        max-width: 400px;
        margin: 0 var(--spacing-md);
    }
    
    .search-input-wrapper {
        height: 40px;
    }
    
    .search-input {
        font-size: var(--font-sm);
    }
}

/* ==========================================================================
   响应式设计 - 移动端（关键）
   ========================================================================== */

@media (max-width: 767px) {
    /* 搜索框在移动端保持显示，不折叠 */
    .header-search-box {
        flex: 1;
        max-width: none;
        margin: 0 var(--spacing-sm);
        order: 2; /* Logo后面，菜单按钮前面 */
    }
    
    .search-input-wrapper {
        height: 38px;
    }
    
    .search-icon {
        left: 12px;
        width: 16px;
        height: 16px;
    }
    
    .search-input {
        padding: 0 42px 0 40px;
        font-size: var(--font-sm);
    }
    
    .search-input::placeholder {
        font-size: var(--font-sm);
    }
    
    .search-submit {
        width: 32px;
        height: 32px;
        right: 3px;
    }
    
    .search-submit svg {
        width: 14px;
        height: 14px;
    }
    
    /* 移动端搜索建议优化 */
    .search-suggestions {
        left: -12px;
        right: -12px;
        max-height: 300px;
    }
}

/* ==========================================================================
   超小屏幕优化
   ========================================================================== */

@media (max-width: 480px) {
    .search-input-wrapper {
        height: 36px;
    }
    
    .search-input {
        font-size: 14px;
    }
    
    .search-input::placeholder {
        font-size: 14px;
    }
    
    .search-submit {
        width: 30px;
        height: 30px;
    }
}

/* ==========================================================================
   键盘导航和无障碍
   ========================================================================== */

.search-input:focus {
    outline: none;
}

.search-submit:focus {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.search-submit:focus:not(:focus-visible) {
    outline: none;
}

/* ==========================================================================
   动画效果
   ========================================================================== */

@keyframes search-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(102, 126, 234, 0);
    }
}

/* 加载状态 */
.search-form.loading .search-submit {
    animation: search-pulse 1.5s infinite;
}

.search-form.loading .search-submit svg {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   暗黑模式优化
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .search-input-wrapper {
        background: rgba(26, 26, 46, 0.9);
    }
    
    .search-input-wrapper:focus-within {
        background: rgba(26, 26, 46, 0.95);
    }
}

/* ==========================================================================
   打印样式
   ========================================================================== */

@media print {
    .header-search-box {
        display: none;
    }
}

/* ==========================================================================
   性能优化
   ========================================================================== */

/* 使用will-change提示浏览器优化 */
.search-input-wrapper {
    will-change: transform, box-shadow;
}

.search-submit {
    will-change: transform;
}

/* GPU加速 */
.search-suggestions {
    transform: translateY(-10px) translateZ(0);
    backface-visibility: hidden;
}


