/* ============================================================
   Douy 抖音原画解析 - Vercel版 样式表
   支持深色/浅色主题，通过 data-theme 属性切换
   ============================================================ */

/* 主题变量 */
:root[data-theme="dark"] {
    --bg-primary: #1c1c1e;
    --bg-secondary: #232326;
    --bg-card: #2a2a2d;
    --bg-input: #333336;
    --bg-hover: #3a3a3d;
    --text-primary: #ececec;
    --text-secondary: #b8b8b8;
    --text-muted: #8a8a8a;
    --accent: #d9d9d9;
    --accent-hover: #f0f0f0;
    --on-accent: #1c1c1e;
    --success: #6dce7a;
    --warning: #e5c07b;
    --error: #e06c75;
    --border: #3c3c3f;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    --modal-bg: rgba(0, 0, 0, 0.7);
}

:root[data-theme="light"] {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f0f0f5;
    --bg-hover: #007aff;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #86868b;
    --accent: #007aff;
    --accent-hover: #0051d5;
    --success: #34c759;
    --warning: #ff9500;
    --error: #ff3b30;
    --border: #e5e5ea;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --modal-bg: rgba(0, 0, 0, 0.4);
    --on-accent: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

/* 顶部导航 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    gap: 8px;
}

.text-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-align: center;
}

.text-btn:hover {
    background: var(--accent);
    color: var(--on-accent);
    transform: translateY(-1px);
}

/* 主内容 */
.main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* 输入区 */
.input-section {
    margin-bottom: 24px;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.input-with-btn {
    flex: 1;
    position: relative;
}

#urlInput {
    width: 100%;
    padding: 14px 68px 14px 18px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

#urlInput:focus {
    border-color: var(--accent);
}

#urlInput::placeholder {
    color: var(--text-muted);
}

.paste-inside-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    padding: 7px 16px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.paste-inside-btn:hover {
    opacity: 0.82;
}

.primary-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.input-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

/* 进度条 */
.progress-section {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 4px;
    transition: width 0.3s;
    width: 0%;
}

/* 不确定进度条动画（同步解析时使用） */
.progress-fill.indeterminate {
    width: 30% !important;
    position: absolute;
    animation: indeterminate 1.5s infinite ease-in-out;
}

@keyframes indeterminate {
    0% { left: -30%; }
    100% { left: 100%; }
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

/* 结果区 */
.results-section {
    margin-bottom: 24px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.results-header h3 {
    font-size: 18px;
}

.results-header-actions {
    display: flex;
    gap: 10px;
}

.count-badge {
    display: inline-block;
    padding: 2px 10px;
    background: var(--accent);
    color: var(--on-accent);
    border-radius: 12px;
    font-size: 13px;
    margin-left: 8px;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.result-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.result-thumb {
    width: 160px;
    height: 90px;
    border-radius: 8px;
    background: var(--bg-input);
    object-fit: cover;
    flex-shrink: 0;
}

.result-thumb-placeholder {
    width: 160px;
    height: 90px;
    border-radius: 8px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.result-info {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.result-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.quality-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--success);
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-btn.download {
    background: var(--accent);
    color: var(--on-accent);
}

.action-btn.download:hover {
    background: var(--accent-hover);
}

.action-btn.copy {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.action-btn.copy:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-title {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-hint {
    font-size: 13px !important;
    color: var(--text-muted) !important;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
}

.close-text-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.close-text-btn:hover {
    background: var(--error);
    color: white;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* 设置项 */
.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.setting-group input[type="text"],
.setting-group input[type="number"],
.setting-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.setting-group input:focus,
.setting-group textarea:focus {
    border-color: var(--accent);
}

.setting-group textarea {
    resize: vertical;
    font-family: monospace;
    font-size: 12px;
}

.setting-hint {
    margin-top: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.theme-options {
    display: flex;
    gap: 20px;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
}

/* 下载方式选择弹窗 */
.download-modal-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: 8px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.download-option {
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.download-option:hover {
    border-color: var(--accent);
}

.download-option-header {
    margin-bottom: 10px;
}

.download-option-title {
    font-size: 15px;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.download-option-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.download-option-url {
    font-size: 11px;
    font-family: monospace;
    color: var(--text-secondary);
    background: var(--bg-input);
    padding: 8px 10px;
    border-radius: 6px;
    word-break: break-all;
    margin-bottom: 12px;
    max-height: 60px;
    overflow-y: auto;
    line-height: 1.4;
}

.download-option-actions {
    display: flex;
    gap: 8px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: 10px;
    box-shadow: var(--shadow);
    font-size: 14px;
    z-index: 2000;
    animation: toastIn 0.3s ease;
    border: 1px solid var(--border);
    max-width: 90%;
    text-align: center;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* 工具类 */
.hidden {
    display: none !important;
}

/* 响应式 */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
    }
    .main {
        padding: 16px 12px;
    }
    .input-wrapper {
        flex-direction: column;
    }
    .result-card {
        flex-direction: column;
    }
    .result-thumb,
    .result-thumb-placeholder {
        width: 100%;
        height: 180px;
    }
    .subtitle {
        display: none;
    }
    .results-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}
