/* ============================================
   搜索页 search.php 专属样式
   搜索框 / 标签 / 图片网格
   ============================================ */

/* ===== 搜索区 ===== */
.search-box-wrap { margin-bottom: 22px; }
.search-box {
    display: flex; gap: 0;
    background: var(--card);
    border: 2px solid var(--border);
    max-width: 680px;
}
.search-input {
    flex: 1;
    padding: 12px 16px;
    border: none; outline: none;
    font-size: 15px; color: var(--text); font-family: inherit;
    min-width: 0;
}
.search-input::placeholder { color: #b0bac9; }
.search-btn {
    padding: 12px 28px;
    background: var(--accent); color: #fff; border: none;
    cursor: pointer; font-size: 15px; font-weight: 600;
    letter-spacing: 2px; font-family: inherit; white-space: nowrap;
}
.search-btn:hover { background: var(--accent-hover); }
.search-btn:active { background: #8a1520; }

/* ===== 快捷标签 ===== */
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag-btn {
    padding: 5px 13px;
    background: var(--card);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 12.5px;
    color: var(--muted);
    transition: all .15s;
    font-family: inherit;
}
.tag-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #fff5f5;
}

/* ===== 结果信息 ===== */
.result-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    margin-bottom: 18px;
    font-size: 13.5px; color: #3730a3;
}
.clear-btn {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid #94a3b8;
    cursor: pointer;
    font-size: 12px;
    color: #64748b;
    font-family: inherit;
}
.clear-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== 图片网格 ===== */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}
.grid-item {
    background: var(--card);
    border: 1px solid var(--border);
    overflow: hidden;
    /* 隔离布局/绘制，大幅提升滚动性能 */
    contain: content;
    will-change: auto;   /* 不预合成，按需 */
}
.grid-item:hover {
    box-shadow: 0 3px 12px rgba(0,0,0,.1);
}
.gi-imgwrap {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    cursor: pointer;
    background: #f8f9fa;
}
.gi-imgwrap img {
    width: 100%; height: 100%;
    object-fit: cover;
}
/* 去掉hover缩放，200张图同时GPU合成太贵 */
.gi-cat {
    position: absolute;
    top: 8px; left: 8px;
    padding: 3px 8px;
    background: var(--dark);
    color: #fff;
    font-size: 11px; font-weight: 500;
}
.gi-name {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 6px 8px;
    background: linear-gradient(transparent, rgba(0,0,0,.65));
    color: #fff;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== 滚动加载哨兵 ===== */
.grid-sentinel {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px 0;
}
.sentinel-loading {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 24px;
    font-size: 13px; color: var(--muted);
}
@keyframes sentinelSpin { to{ transform: rotate(360deg); } }
.sentinel-dot {
    width: 16px; height: 16px;
    border: 2.5px solid #d1d5db;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: sentinelSpin .7s linear infinite;
}

/* ===== 上传管理区域 ===== */
.upload-section {
    margin-bottom: 22px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 4px;
}
.upload-toggle {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px;
    cursor: pointer;
    font-size: 14.5px; font-weight: 600; color: var(--text);
    user-select: none;
    border-bottom: 1px solid transparent;
    transition: border-color .15s;
}
.upload-toggle:hover { background: #fafbfc; }
.upload-section .upload-panel {
    padding: 20px 18px;
    display: flex;
}
.upload-subtitle {
    font-size: 13px; font-weight: 600; color: #475569;
    margin: 0 0 10px;
}

/* 左：文件夹 */
.upload-section .upload-left {
    flex: 0 0 260px;
    margin-right: 24px;
    border-right: 1px solid #eef2f6;
    padding-right: 20px;
}
.folder-select-wrap { margin-bottom: 14px; }
.folder-select {
    width: 100%; height: 36px;
    border: 1.5px solid var(--border); border-radius: 4px;
    font-size: 13.5px; outline: none;
    padding: 0 10px;
    font-family: inherit;
    background: #fff;
    cursor: pointer;
}
.folder-select:focus { border-color: var(--accent); }

.new-folder-row {
    display: flex; gap: 8px; margin-bottom: 14px;
}
.new-folder-input {
    flex: 1; height: 34px;
    border: 1.5px solid var(--border); border-radius: 4px;
    padding: 0 10px; font-size: 13px; outline: none;
    font-family: inherit;
}
.new-folder-input:focus { border-color: var(--accent); }
.btn-new-folder {
    height: 34px; padding: 0 16px;
    background: var(--card); border: 1.5px solid var(--border);
    border-radius: 4px; cursor: pointer; font-size: 13px;
    color: var(--text); white-space: nowrap; font-family: inherit;
}
.btn-new-folder:hover { border-color: var(--accent); color: var(--accent); }

/* 文件夹列表 */
.folder-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
}
.folder-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 10px;
    font-size: 12.5px;
    border-bottom: 1px solid #f1f3f5;
    cursor: pointer;
    transition: background .1s;
}
.folder-item:last-child { border-bottom: none; }
.folder-item:hover { background: #fff5f5; }
.folder-item.active { background: #fef2f2; color: var(--accent); font-weight: 600; }
.folder-item-name { display: flex; align-items: center; gap: 6px; overflow: hidden; }
.folder-item-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count { color: #94a3b8; font-size: 11.5px; flex-shrink: 0; }

/* 右：上传区 */
.upload-right { flex: 1; min-width: 0; }
.drop-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 20px;
    border: 2px dashed #cbd5e1; border-radius: 6px;
    cursor: pointer; transition: all .2s;
    background: #fafbfc;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent); background: #fff5f5;
}
.drop-zone p { margin: 10px 0 4px; font-size: 14px; color: #64748b; }
.drop-link { color: var(--accent); text-decoration: underline; cursor: pointer; }
.drop-zone small { color: #94a3b8; font-size: 11.5px; }

/* ====== 上传：结果容器 ====== */
.upload-result {
    margin-top: 14px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}
.upload-result:empty { display: none !important; }

/* 上传结果汇总条 */
.upload-result-item {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 4px;
    margin-top: 6px;
}
.upload-result-item.ok { background: #f0fdf4; color: #15803d; }
.upload-result-item.err { background: #fef2f2; color: #dc2626; }

/* ====== 上传：每个文件独立进度卡片 ====== */
.upload-progress-title {
    margin-top: 14px;
    padding: 8px 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    font-size: 13px; font-weight: 600;
    color: #1d4ed8;
}

/* 每个文件一个独立卡片 */
.upload-task-card {
    display: block;
    padding: 10px 12px;
    margin-top: 8px;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    transition: border-color .2s, box-shadow .2s;
}
.upload-task-card:hover { border-color: #cbd5e1; }

.utc-header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px;
}
.utc-name {
    flex: 1; min-width: 0;
    font-size: 12.5px; font-weight: 500; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.utc-size {
    font-size: 11px; color: #94a3b8; white-space: nowrap; flex-shrink: 0;
}
.utc-status { font-size: 14px; flex-shrink: 0; }
.utc-status-pending { opacity: 0.6; }
.utc-status-ok { }
.utc-status-err { }

/* 独立进度条 */
.utc-progress-wrap {
    display: flex; align-items: center; gap: 8px;
}
.utc-bar-track {
    flex: 1; height: 6px;
    background: #eef2f6; border-radius: 3px; overflow: hidden;
}
.utc-bar-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #3b82f6, #06b6d4);
    border-radius: 3px;
    transition: width .15s linear;
}
.utc-pct {
    font-size: 11.5px; color: #64748b;
    min-width: 32px; text-align: right;
}

/* 完成状态 */
.upload-task-card.utc-done {
    border-color: #86efac; background: #f0fdf4;
}
.upload-task-card.utc-fail {
    border-color: #fca5a5; background: #fef2f2;
}
.utc-msg {
    margin-top: 6px; padding-top: 6px; border-top: 1px dashed #e2e8f0;
    font-size: 11.5px; color: #64748b;
}
.upload-task-card.utc-done .utc-msg { color: #15803d; }
.upload-task-card.utc-fail .utc-msg { color: #dc2626; }

/* ===== 搜索页响应式 ===== */
@media (max-width: 600px) {
    .grid-container { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .search-box { flex-direction: column; }
    .search-btn { text-align: center; }
    .gi-cat { font-size: 10px; padding: 2px 6px; }

    /* 上传区响应式 */
    .upload-section .upload-panel {
        flex-direction: column;
        padding: 16px 14px;
    }
    .upload-section .upload-left {
        flex: none; width: auto; margin-right: 0;
        border-right: none; border-bottom: 1px solid #eef2f6;
        padding-right: 0; padding-bottom: 16px; margin-bottom: 16px;
    }
}
