/* ============================================================
   Short Video Parser v2 — 表单和输入组件样式
   ============================================================ */

/* ========== 提取行显示 ========== */
.extracted-line {
    min-height: 24px;
    padding: 2px 0;
    overflow-wrap: anywhere;
    color: var(--text-muted);
    font-size: 13px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    line-height: 1.6;
}

.extracted-line.ok {
    color: var(--primary);
    font-weight: 600;
}

/* ========== 质量选择面板 ========== */
.quality-panel,
.share-password-panel {
    position: relative;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg,
        rgba(99, 102, 241, 0.08) 0%,
        rgba(139, 92, 246, 0.05) 100%);
    backdrop-filter: var(--blur-sm);
    animation: slideInUp 0.3s ease both;
}

.quality-panel {
    overflow: visible;
}

.quality-panel label,
.share-password-panel label {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.quality-panel select,
.share-password-panel input {
    width: min(280px, 100%);
    border: 2px solid var(--border-base);
    border-radius: var(--radius-md);
    padding: 11px 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.9);
    font: inherit;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.quality-panel select:focus,
.share-password-panel input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.quality-panel select.quality-native {
    display: none;
}

/* 自定义质量选择器 */
.quality-select {
    position: relative;
    z-index: 600;
    width: min(280px, 100%);
}

.quality-select-trigger {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 2px solid var(--border-base);
    border-radius: var(--radius-md);
    padding: 11px 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.quality-select-trigger:hover {
    border-color: var(--border-strong);
    background: white;
}

.quality-select.open .quality-select-trigger,
.quality-select-trigger:focus-visible {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
    outline: none;
}

.quality-select.disabled {
    opacity: 0.6;
}

.quality-select.disabled .quality-select-trigger {
    cursor: not-allowed;
}

.quality-select.disabled .quality-select-trigger:hover {
    border-color: var(--border-base);
    background: rgba(255, 255, 255, 0.9);
}

.quality-select-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
}

.quality-select-icon {
    position: relative;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border-radius: 6px;
}

.quality-select-icon::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 5px;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: all 0.3s ease;
}

.quality-select.open .quality-select-icon::before {
    top: 8px;
    border-color: var(--primary);
    transform: rotate(225deg);
}

.quality-select-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 700;
    display: grid;
    width: 100%;
    min-width: 240px;
    padding: 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: var(--blur-xl);
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quality-select.open .quality-select-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.quality-select-option {
    display: flex;
    width: 100%;
    min-height: 40px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-soft);
    background: transparent;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quality-select-option:hover,
.quality-select-option:focus-visible {
    color: var(--text);
    background: rgba(99, 102, 241, 0.08);
    outline: none;
}

.quality-select-option.selected {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.12);
    font-weight: 700;
}

.quality-select-option.selected::after {
    content: "";
    width: 6px;
    height: 11px;
    margin-right: 4px;
    border-right: 2.5px solid var(--primary);
    border-bottom: 2.5px solid var(--primary);
    transform: rotate(45deg);
}

/* ========== YouTube 质量按钮组 ========== */
.youtube-quality-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px;
    border: 1px solid var(--border-base);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: var(--blur-sm);
}

.quality-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 62px;
    min-width: 90px;
    padding: 10px 14px;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.quality-chip:hover {
    color: var(--text);
    background: rgba(249, 250, 251, 0.8);
    transform: translateY(-2px);
}

.quality-chip-label {
    display: block;
    color: inherit;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
}

.quality-chip small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 20px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.quality-chip-cost {
    color: #8a6116;
    background: rgba(245, 185, 58, 0.2);
}

.quality-chip-free {
    color: #64748b;
    background: rgba(148, 163, 184, 0.18);
}

.quality-chip.active {
    color: white;
    background: var(--gradient-primary);
    box-shadow: var(--shadow-md), 0 0 20px rgba(99, 102, 241, 0.3);
}

.quality-chip.active .quality-chip-cost,
.quality-chip.active .quality-chip-free {
    color: rgba(255, 255, 255, 0.98);
    background: rgba(255, 255, 255, 0.2);
}

/* ========== YouTube 任务列表 ========== */
.youtube-job-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-base);
}

.youtube-job-title {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.youtube-job-item {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border-base);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: var(--blur-sm);
}

.youtube-job-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    color: var(--text);
    font-size: 13px;
}

.youtube-job-row span {
    min-width: 0;
    overflow: hidden;
    color: var(--text-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.youtube-job-row.small {
    font-size: 12px;
}

.youtube-job-row a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.youtube-job-row a:hover {
    text-decoration: underline;
}

.youtube-job-progress {
    overflow: hidden;
    height: 7px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
}

.youtube-job-progress i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transition: width 0.3s ease;
}

.youtube-job-error .youtube-job-progress i {
    background: var(--error);
}

.youtube-job-done .youtube-job-progress i {
    background: var(--success);
}

/* ========== 视频缩略图 ========== */
.video-thumb {
    position: relative;
    display: block;
    text-decoration: none;
}

.video-thumb video {
    pointer-events: none;
}

.video-thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        transparent 40%,
        rgba(0, 0, 0, 0.25));
    pointer-events: none;
}

.video-thumb span {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 1;
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
}

.video-thumb:hover span {
    transform: translate(-50%, -50%) scale(1.15);
    background: white;
}

.video-thumb span::before {
    content: "";
    position: absolute;
    left: 11px;
    top: 8px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 9px solid #1f2937;
}

/* ========== 音频预览 ========== */
.audio-preview {
    grid-area: audio;
    width: 100%;
    height: auto;
    padding: 12px 14px;
    place-items: stretch;
    background: rgba(249, 250, 251, 0.8);
    border-radius: var(--radius-sm);
}

.audio-preview audio {
    width: 100%;
}

/* ========== 文件预览 ========== */
.file-preview {
    display: grid;
    place-items: center;
}

.file-preview span {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.resources-file .file-preview {
    width: 80px;
    height: 64px;
    border-color: rgba(99, 102, 241, 0.2);
    background: linear-gradient(145deg,
        rgba(247, 243, 255, 0.9) 0%,
        rgba(248, 250, 252, 0.95) 100%);
}

.resources-file .file-preview span {
    color: var(--primary);
    font-size: 13px;
    letter-spacing: 0.03em;
}

/* ========== 音乐资源卡片 ========== */
.resource-card-music {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "meta actions"
        "audio audio";
    align-items: start;
}

.resource-card-music .resource-meta {
    grid-area: meta;
}

.resource-card-music .resource-actions {
    grid-area: actions;
    justify-self: end;
}

/* ========== 歌词下载按钮 ========== */
.lyrics-actions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding-left: 6px;
}

.lyrics-download {
    padding: 7px 12px;
    border: 1px solid var(--border-base);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    background: white;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lyrics-download:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
}

/* ========== 同步歌词 ========== */
.synced-lyrics {
    display: grid;
    gap: 8px;
    max-height: 240px;
    min-height: 0;
    overflow: auto;
    padding: 4px 16px 16px;
    scroll-behavior: smooth;
}

.synced-lyrics::-webkit-scrollbar {
    width: 6px;
}

.synced-lyrics::-webkit-scrollbar-thumb {
    border-radius: 6px;
    background: rgba(148, 163, 184, 0.7);
}

.synced-lyrics p {
    margin: 0;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.7;
    text-align: center;
    transition: all 0.3s ease;
}

.synced-lyrics p.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    font-weight: 700;
    transform: scale(1.05);
}

/* ========== 原始JSON ========== */
.raw-json {
    overflow: auto;
    margin-top: 20px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-base);
    color: var(--text-soft);
    background: rgba(249, 250, 251, 0.8);
    backdrop-filter: var(--blur-sm);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.7;
}

/* ========== 资源URL ========== */
.resource-url {
    overflow: hidden;
    color: var(--text-lighter);
    font-size: 12px;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.resource-url:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* ========== 响应式 ========== */
@media (max-width: 640px) {
    .quality-panel,
    .share-password-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .quality-panel select,
    .share-password-panel input,
    .quality-select {
        width: 100%;
    }

    .youtube-quality-actions {
        justify-content: stretch;
    }

    .quality-chip {
        flex: 1;
    }

    .resource-card-music {
        grid-template-areas:
            "meta"
            "audio"
            "actions";
    }

    .resource-card-music .resource-meta,
    .resource-card-music .resource-actions {
        grid-area: auto;
    }

    .resource-actions {
        width: 100%;
    }

    .mini-download,
    .resource-card button {
        flex: 1;
    }
}
