/* ================================================================
   速析视频助手 - 样式表
   移动端优先设计，模拟微信小程序体验
   ================================================================ */

/* ---------- CSS 变量 & 重置 ---------- */
:root {
    --primary: #ff6b35;
    --primary-dark: #e55a2b;
    --primary-light: #ff8c5a;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #333333;
    --text-secondary: #666666;
    --text-light: #999999;
    --border: #e8e8e8;
    --success: #07c160;
    --danger: #fa5151;
    --warning: #ff976a;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --max-width: 480px;
    --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue",
                 Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- 布局容器 ---------- */
.header,
.main,
.footer {
    width: 100%;
    max-width: var(--max-width);
}

.main {
    flex: 1;
    padding: 0 16px;
}

/* ---------- 头部 ---------- */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 24px 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    text-align: center;
}

.header-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.header-subtitle {
    font-size: 0.78rem;
    opacity: 0.9;
    font-weight: 400;
}

/* ---------- 输入卡片 ---------- */
.input-section {
    margin-top: -8px;
    position: relative;
    z-index: 10;
}

.input-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.input-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.label-icon {
    font-size: 1.1rem;
}

.input-wrapper {
    position: relative;
}

.url-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 70px;
    transition: border-color 0.2s;
    font-family: inherit;
    background: #fafafa;
}

.url-input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.url-input::placeholder {
    color: #bbb;
}

.paste-btn {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.paste-btn:active {
    background: var(--primary-dark);
    transform: scale(0.96);
}

.input-tips {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
}

.parse-btn {
    width: 100%;
    margin-top: 14px;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.35);
}

.parse-btn:not(:disabled):active {
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(255, 107, 53, 0.2);
}

.parse-btn:disabled {
    background: #ccc;
    color: #999;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-icon {
    font-size: 1.15rem;
}

/* ---------- 平台列表 ---------- */
.platforms-section {
    margin-bottom: 16px;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
    padding-left: 4px;
}

.platform-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.platform-item {
    flex: 1;
    min-width: 70px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.platform-item:active {
    transform: scale(0.96);
}

.platform-icon {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.platform-name {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ---------- 加载动画 ---------- */
.loading-section {
    margin-bottom: 16px;
}

.loading-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.loading-sub {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ---------- 结果卡片 ---------- */
.result-section {
    margin-bottom: 16px;
}

.result-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

/* 视频预览 */
.video-preview {
    position: relative;
    width: 100%;
    background: #000;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-player {
    width: 100%;
    max-height: 400px;
    display: block;
}

.cover-preview {
    width: 100%;
    position: relative;
    cursor: pointer;
}

.cover-preview img {
    width: 100%;
    display: block;
}

.cover-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

/* 视频信息 */
.video-info {
    padding: 14px 16px;
}

.author-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.author-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--border);
}

.author-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.video-title {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
}

.stat-icon {
    font-size: 0.85rem;
}

.stat-value {
    color: var(--text-secondary);
    font-weight: 500;
}

.music-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-light);
}

.music-icon {
    font-size: 0.85rem;
}

.music-info {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 操作按钮 */
.action-buttons {
    display: flex;
    gap: 10px;
    padding: 0 16px 16px;
}

.action-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.primary-btn:active {
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(255, 107, 53, 0.2);
}

.secondary-btn {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.secondary-btn:active {
    background: #eee;
    transform: scale(0.97);
}

/* ---------- 错误卡片 ---------- */
.error-section {
    margin-bottom: 16px;
}

.error-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.error-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--danger);
    margin-bottom: 6px;
}

.error-msg {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.retry-btn {
    padding: 10px 28px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
}

.retry-btn:active {
    background: var(--primary-dark);
    transform: scale(0.97);
}

/* ---------- 使用教程 ---------- */
.guide-section {
    margin-bottom: 24px;
}

.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.guide-step {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    gap: 12px;
    box-shadow: var(--shadow);
}

.step-number {
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 2px;
}

.step-content h4 {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.step-content p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ---------- 底部 ---------- */
.footer {
    text-align: center;
    padding: 16px;
    font-size: 0.72rem;
    color: var(--text-light);
    line-height: 1.8;
    padding-bottom: calc(16px + var(--safe-bottom));
}

/* ---------- Toast 提示 ---------- */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.78);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.88rem;
    z-index: 9999;
    pointer-events: none;
    animation: toastIn 0.3s ease;
    text-align: center;
    max-width: 80vw;
}

.toast.fade-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* ---------- 响应式适配 ---------- */
@media (min-width: 481px) {
    .header {
        border-radius: 0 0 var(--radius) var(--radius);
        margin: 0 8px;
        width: calc(100% - 16px);
    }
    
    .main {
        padding: 0 8px;
    }

    .input-section {
        margin-top: 16px;
    }

    .input-card {
        padding: 24px 20px;
    }
}

@media (max-width: 360px) {
    .header-title {
        font-size: 1.15rem;
    }
    
    .url-input {
        font-size: 0.85rem;
    }
    
    .action-btn {
        font-size: 0.82rem;
        padding: 10px;
    }
}
