/* ================================================
   VidGrab - 现代简约视频下载应用样式
   ================================================ */

/* === 主题变量 === */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #222230;
    --bg-input: #0f0f18;
    --bg-nav: rgba(10, 10, 15, 0.92);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --accent-bg: rgba(99, 102, 241, 0.1);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #2a2a3a;
    --border-light: #3a3a4a;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #f1f5f9;
    --bg-nav: rgba(248, 250, 252, 0.92);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.2);
    --accent-bg: rgba(99, 102, 241, 0.08);
    --border: #e2e8f0;
    --border-light: #cbd5e1;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* === 基础重置 === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    transition: background 0.3s, color 0.3s;
}
input, button, textarea { font-family: inherit; font-size: inherit; border: none; outline: none; background: none; color: inherit; }
button { cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* === 加载动画 === */
.loading-overlay {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-primary);
}
.loading-content { text-align: center; }
.loading-spinner { width: 48px; height: 48px; margin: 0 auto 16px; }
.loading-spinner svg { animation: spin 1s linear infinite; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-message { color: var(--text-secondary); font-size: 0.95rem; }
.loading-progress { margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.progress-bar { width: 200px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; width: 0%; }
.progress-text { color: var(--text-muted); font-size: 0.8rem; }

/* === App 容器 === */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; position: relative; background: var(--bg-primary); }

/* === 顶部栏 === */
.top-bar { position: sticky; top: 0; z-index: 100; background: var(--bg-nav); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); padding-top: var(--safe-top); }
.top-bar-content { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 24px; }
.brand-name { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.action-btn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--text-secondary); transition: all 0.2s; }
.action-btn:hover { background: var(--bg-card); color: var(--text-primary); }
.action-btn:active { transform: scale(0.92); }

/* === 主内容区 === */
.main { flex: 1; overflow-y: auto; padding-bottom: calc(70px + var(--safe-bottom)); }

/* === 页面 === */
.page { display: none; padding: 0 16px; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* === 首页 === */
.hero-section { text-align: center; padding: 32px 0 28px; }
.hero-title { font-size: 2rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.03em; margin-bottom: 8px; background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-light) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-desc { color: var(--text-secondary); font-size: 0.9rem; }

/* === 输入卡片 === */
.input-card { margin-bottom: 24px; }
.input-wrapper { display: flex; flex-direction: column; gap: 12px; }
.input-field { display: flex; align-items: center; gap: 12px; background: var(--bg-input); border: 2px solid var(--border); border-radius: var(--radius-lg); padding: 0 16px; transition: all 0.25s; }
.input-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.input-icon { flex-shrink: 0; color: var(--text-muted); }
.url-input { flex: 1; height: 52px; background: transparent; font-size: 0.95rem; color: var(--text-primary); }
.url-input::placeholder { color: var(--text-muted); }
.paste-btn { flex-shrink: 0; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-muted); transition: all 0.2s; }
.paste-btn:hover { background: var(--bg-card); color: var(--text-secondary); }
.paste-btn:active { transform: scale(0.9); }
.download-btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 52px; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; font-size: 1rem; font-weight: 600; border-radius: var(--radius-lg); transition: all 0.25s; box-shadow: 0 4px 16px var(--accent-glow); }
.download-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow); }
.download-btn:active:not(:disabled) { transform: scale(0.98); }
.download-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* === 区块标题 === */
.section-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 12px; }

/* === 快捷平台 === */
.quick-section { margin-bottom: 28px; }
.platform-chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.platform-chips::-webkit-scrollbar { display: none; }
.chip { display: flex; align-items: center; gap: 6px; padding: 10px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 50px; white-space: nowrap; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); transition: all 0.2s; flex-shrink: 0; }
.chip:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
.chip:active { background: var(--accent); color: #fff; border-color: var(--accent); transform: scale(0.95); }

/* === 功能特点 === */
.features-section { margin-bottom: 28px; }
.features-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.feature-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; transition: all 0.2s; }
.feature-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.feature-icon { font-size: 1.5rem; margin-bottom: 8px; }
.feature-card h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.feature-card p { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }

/* === 支持平台 === */
.platforms-section { margin-bottom: 24px; }
.platform-list { display: flex; flex-wrap: wrap; gap: 8px; }
.platform-tag { padding: 6px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 50px; font-size: 0.8rem; color: var(--text-secondary); }

/* === 结果页 === */
.back-btn { display: flex; align-items: center; gap: 6px; padding: 12px 0; color: var(--text-secondary); font-size: 0.9rem; font-weight: 500; margin-bottom: 8px; }
.back-btn:hover { color: var(--text-primary); }
.preview-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 20px; }
.preview-thumbnail { position: relative; padding-top: 56.25%; background: var(--bg-secondary); }
.preview-thumbnail img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.duration-badge { position: absolute; bottom: 8px; right: 8px; padding: 4px 8px; background: rgba(0, 0, 0, 0.75); border-radius: 4px; font-size: 0.75rem; font-weight: 600; color: #fff; }
.preview-info { padding: 16px; }
.video-title { font-size: 1rem; font-weight: 600; line-height: 1.4; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-meta { display: flex; gap: 16px; }
.meta-item { display: flex; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--text-muted); }

/* === 下载选项 === */
.download-section { margin-bottom: 24px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.format-count { font-size: 0.8rem; color: var(--accent); font-weight: 500; }
.format-list { display: flex; flex-direction: column; gap: 10px; }
.format-item { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); transition: all 0.2s; }
.format-item:hover { border-color: var(--accent); }
.format-item:active { transform: scale(0.98); }
.format-icon { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-size: 1.2rem; flex-shrink: 0; }
.format-icon.video { background: var(--accent-bg); }
.format-icon.audio { background: rgba(34, 197, 94, 0.1); }
.format-info { flex: 1; min-width: 0; }
.format-name { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.format-meta { font-size: 0.75rem; color: var(--text-muted); }
.format-btn { padding: 10px 20px; background: var(--accent); color: #fff; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; transition: all 0.2s; flex-shrink: 0; }
.format-btn:hover { background: var(--accent-light); }
.format-btn:active { transform: scale(0.95); }
.format-btn.downloading { opacity: 0.6; pointer-events: none; }

/* === 错误卡片 === */
.error-card { text-align: center; padding: 40px 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.error-icon { font-size: 3rem; margin-bottom: 12px; }
.error-card h3 { font-size: 1.1rem; margin-bottom: 8px; }
.error-card p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 20px; }
.error-actions { display: flex; gap: 10px; justify-content: center; }
.btn-outline { padding: 10px 20px; background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); transition: all 0.2s; }
.btn-outline:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.btn-outline:active { transform: scale(0.95); }

/* === 历史页 === */
.history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.clear-btn { font-size: 0.85rem; color: var(--danger); padding: 4px 8px; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); transition: all 0.2s; cursor: pointer; }
.history-item:hover { border-color: var(--border-light); }
.history-item:active { transform: scale(0.98); }
.history-thumb { width: 56px; height: 56px; border-radius: var(--radius-sm); object-fit: cover; background: var(--bg-secondary); flex-shrink: 0; }
.history-thumb-placeholder { width: 56px; height: 56px; border-radius: var(--radius-sm); background: var(--bg-secondary); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; }
.history-info { flex: 1; min-width: 0; }
.history-title { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; }
.history-meta { font-size: 0.72rem; color: var(--text-muted); }
.history-delete { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--text-muted); transition: all 0.2s; }
.history-delete:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-state p { color: var(--text-muted); font-size: 0.95rem; }

/* === 底部 Tab 栏 === */
.tab-bar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; display: flex; align-items: stretch; background: var(--bg-nav); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--border); padding-bottom: var(--safe-bottom); z-index: 100; }
.tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 8px; color: var(--text-muted); font-size: 0.65rem; font-weight: 500; transition: all 0.2s; }
.tab-item.active { color: var(--accent); }
.tab-item.active svg { filter: drop-shadow(0 0 8px var(--accent-glow)); }
.tab-item:active { transform: scale(0.92); }

/* === Toast === */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); padding: 12px 24px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); font-size: 0.85rem; font-weight: 500; color: var(--text-primary); z-index: 1000; white-space: nowrap; max-width: 90%; text-align: center; backdrop-filter: blur(10px); animation: toastIn 0.3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* === 模态框 === */
.modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: fadeIn 0.2s ease; }
.modal-content { width: 90%; max-width: 320px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; animation: slideUp 0.3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { padding: 20px 20px 0; text-align: center; }
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-body { padding: 24px 20px; }
.modal-footer { padding: 0 20px 20px; display: flex; justify-content: center; }
.btn-ghost { padding: 12px 32px; border-radius: var(--radius-md); font-size: 0.9rem; font-weight: 500; color: var(--text-secondary); transition: all 0.2s; }
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* === 下载进度 === */
.download-progress { text-align: center; }
.progress-circle { width: 100px; height: 100px; margin: 0 auto 16px; position: relative; }
.progress-circle svg { transform: rotate(-90deg); }
.progress-circle circle { transition: stroke-dashoffset 0.3s ease; }
.progress-value { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.download-status { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 4px; }
.download-name { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 250px; margin: 0 auto; }

/* === 响应式 === */
@media (min-width: 480px) {
    .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* === iOS 防止输入框缩放 === */
@media screen and (max-width: 480px) {
    input, select, textarea { font-size: 16px !important; }
}
