/**
 * 课程详情页完整样式
 * 来自 course-detail.html 模板
 */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --accent-primary: #6366f1;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --success: #22c55e;
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* 页面容器 */
.speakvlog-detail-v2 {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 头部 */
.detail-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.detail-header .header-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
}

.detail-header .header-left {
    min-width: 32px;
}

.detail-header .back-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 50%;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
}

.detail-header .back-btn:hover {
    background: var(--bg-hover);
}

.detail-header .page-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    margin-left: 8px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-center {
    flex: 1;
    text-align: center;
}

.header-center .course-title {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
    margin: 0 auto;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.header-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 容器 */
.detail-container {
    display: flex;
    flex: 1;
    height: calc(100vh - 60px);
    overflow: hidden;
    padding: 20px;
    gap: 20px;
    box-sizing: border-box;
}

/* 视频区域 - 左侧独立滚动 */
.video-area {
    flex: 0 0 55% !important;  /* 固定占 55% 宽度 */
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    flex-shrink: 0;
    overflow: hidden;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 视频信息区域 - 左侧独立滚动 */
.video-info-section {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background: var(--bg-card);
    -webkit-overflow-scrolling: touch;
}

.video-placeholder {
    position: absolute;
    inset: 0;
    cursor: pointer;
}

.video-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.video-placeholder:hover .video-overlay {
    background: rgba(0, 0, 0, 0.4);
}

.big-play-btn {
    width: 72px;
    height: 72px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.big-play-btn:hover {
    transform: scale(1.05);
}

.big-play-btn svg {
    margin-left: 4px;
}

.video-duration {
    position: absolute;
    bottom: 16px;
    right: 16px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
}

.video-header {
    margin-bottom: 16px;
}

.video-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.video-stats {
    display: flex;
    gap: 16px;
}

.video-stats .stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-tertiary);
}

/* 操作按钮 */
.video-actions {
    display: flex;
    gap: 8px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.video-actions .action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.video-actions .action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.video-actions .action-btn.primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

.video-actions .action-btn.primary:hover {
    background: #4f46e5;
}

/* 描述 */
.video-description {
    margin-bottom: 20px;
}

.description-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* 课程信息卡片 */
.course-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}

.course-info-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.course-info-header .tag {
    font-size: 12px;
    padding: 2px 8px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
    border-radius: 4px;
}

.level-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}

.level-tag.beginner {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.course-info-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.course-meta-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-tertiary);
    flex-wrap: wrap;
}

.course-meta-info span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 字幕区域 - 右侧独立滚动 */
.subtitle-area {
    flex: 1 !important;
    min-width: 400px !important;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    min-height: 0;
}

.subtitle-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.subtitle-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.subtitle-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.icon-btn.active {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

/* 下拉菜单样式 */
.dropdown-wrapper {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    padding: 8px 0;
    z-index: 1000;
    display: none;
}

.dropdown-menu.with-header {
    padding-top: 0;
}

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #fff;
}

.dropdown-menu.show {
    display: block;
    animation: fadeInDown 0.2s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.dropdown-header {
    padding: 12px 16px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #f1f5f9;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    color: #334155;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.dropdown-item:hover {
    background: #f8fafc;
}

.dropdown-item.with-check {
    justify-content: flex-start;
}

.dropdown-item.with-check .check-icon {
    margin-left: auto;
    opacity: 0;
    color: #6366f1;
}

.dropdown-item.with-check.active .check-icon {
    opacity: 1;
}

.dropdown-item svg:first-child {
    color: #94a3b8;
    flex-shrink: 0;
}

.dropdown-item.active svg:first-child {
    color: #6366f1;
}

.dropdown-group {
    padding: 4px 0;
}

.dropdown-group-label {
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 500;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 4px 0;
}

/* 悬停提示样式 */
.icon-btn.with-tooltip {
    position: relative;
}

.icon-btn .tooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #e0e7ff;
    color: #4f46e5;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.icon-btn .tooltip::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #e0e7ff;
}

.icon-btn.with-tooltip:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* 下拉菜单打开时隐藏tooltip */
.dropdown-wrapper .dropdown-menu.show ~ .tooltip,
.dropdown-menu.show + .tooltip {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* 循环播放激活状态 */
.icon-btn.loop-active {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

.icon-btn.loop-active:hover {
    background: #4f46e5;
    border-color: #4f46e5;
}

.icon-btn.loop-active .tooltip {
    background: var(--accent-primary);
}

.icon-btn.loop-active .tooltip::after {
    border-top-color: var(--accent-primary);
}

/* 字幕模式样式 */
.subtitle-content.mode-english .subtitle-chinese {
    display: none;
}

.subtitle-content.mode-chinese .subtitle-english {
    display: none;
}

.subtitle-content.mode-bilingual .subtitle-english,
.subtitle-content.mode-bilingual .subtitle-chinese {
    display: block;
}
}

/* 字幕内容 */
.subtitle-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    min-height: 0; /* 确保flex子项可以正确收缩 */
    -webkit-overflow-scrolling: touch; /* 移动端平滑滚动 */
    /* 隐藏滚动条但保留滚动功能 */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* 隐藏 Webkit 滚动条 */
.subtitle-content::-webkit-scrollbar {
    display: none;
}

.subtitle-block {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    position: relative;
}

.subtitle-block:hover {
    background: var(--bg-hover);
}

.subtitle-block:hover .subtitle-copy {
    opacity: 1;
}

.subtitle-block.active {
    background: rgba(99, 102, 241, 0.12);
    border-left: 3px solid var(--accent-primary);
}

.subtitle-time {
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-primary);
    min-width: 36px;
    padding-top: 2px;
}

.subtitle-text {
    flex: 1;
}

.subtitle-english {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 4px;
}

.subtitle-chinese {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.subtitle-copy {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--text-tertiary);
    opacity: 0;
    transition: all 0.2s;
    background: none;
    border: none;
    cursor: pointer;
}

.subtitle-copy:hover {
    background: var(--bg-card);
    color: var(--accent-primary);
}

.subtitle-copy.copied {
    color: var(--success);
    opacity: 1;
}

/* 字幕工具栏 */
.subtitle-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    flex-shrink: 0;
}

.subtitle-toolbar .tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    transition: all 0.2s;
    min-width: 70px;
    background: none;
    border: none;
    cursor: pointer;
}

.subtitle-toolbar .tool-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.subtitle-toolbar .tool-btn.highlight {
    background: var(--accent-primary);
    color: #fff;
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

/* 响应式 */
@media (max-width: 1024px) {
    .detail-container {
        flex-direction: column;
    }

    .subtitle-area {
        width: 100%;
        height: 400px;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
}

@media (max-width: 768px) {
    .detail-header .header-row {
        padding: 10px 12px;
    }

    .detail-header .page-title {
        font-size: 15px;
    }

    .video-actions {
        flex-wrap: wrap;
    }

    .video-actions .action-btn {
        flex: 1;
        justify-content: center;
        min-width: calc(50% - 4px);
    }

    .video-info-section {
        padding: 16px;
    }

    .subtitle-area {
        height: 350px;
    }
}

/* 增强字幕样式 - 从 style-subtitle-enhanced.css */
.subtitle-block {
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.subtitle-block:hover {
    background: var(--bg-hover);
    transform: translateX(2px);
}

/* 当前播放的字幕高亮 */
.subtitle-block.active {
    background: rgba(99, 102, 241, 0.1);
    border-left-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.subtitle-block.active .subtitle-english {
    color: var(--accent-primary);
    font-weight: 600;
}

/* 重点单词标记 */
.highlight-word {
    position: relative;
    display: inline;
    cursor: pointer;
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: #FF6B6B;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    transition: all 0.2s ease;
}

.highlight-word:hover {
    color: #FF6B6B;
    background-color: rgba(255, 107, 107, 0.1);
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: 4px;
}

/* 单词释义弹窗 */
.word-definition-popup {
    display: none;
    position: fixed;
    z-index: 10000;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    min-width: 320px;
    max-width: 480px;
    border: 1px solid #E5E7EB;
    animation: popupFadeIn 0.2s ease-out;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #E5E7EB;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px 12px 0 0;
}

.popup-header h4 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.close-popup {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.close-popup:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.popup-content {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.definition-item {
    margin-bottom: 16px;
}

.definition-item:last-child {
    margin-bottom: 0;
}

.definition-item strong {
    display: block;
    color: var(--accent-primary);
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 600;
}

.definition-item p {
    margin: 0;
    color: #333;
    font-size: 15px;
    line-height: 1.6;
}

.play-pronunciation {
    background: var(--accent-primary);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.play-pronunciation:hover {
    background: #4f46e5;
}

/* 字幕滚动增强 */
.subtitle-content {
    scroll-behavior: smooth;
    padding: 16px;
    /* 隐藏滚动条但保留滚动功能 */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* 隐藏 Webkit 滚动条 */
.subtitle-content::-webkit-scrollbar {
    display: none;
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .subtitle-block {
        background: #2D3748;
    }

    .subtitle-block:hover {
        background: #374151;
    }

    .subtitle-block.active {
        background: rgba(99, 102, 241, 0.2);
    }

    .word-definition-popup {
        background: #1F2937;
        border-color: #374151;
    }

    .popup-content {
        color: #E2E8F0;
    }

    .definition-item p {
        color: #D1D5DB;
    }
}
