/* ========== 语音帖功能样式 ========== */

/* 语音帖按钮样式 */
.compose-audio-post-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-blue);
}

.compose-audio-post-btn:hover {
    background: rgba(19, 91, 255, 0.1);
}

/* 语音帖发布弹窗 */
.audio-post-compose-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.audio-post-compose-container {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.audio-post-compose-header {
    background: linear-gradient(135deg, #135BFF 0%, #4047FF 100%);
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.audio-post-compose-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.audio-post-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.audio-post-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.audio-post-compose-body {
    padding: 24px;
    box-sizing: border-box;
}

.audio-post-compose-field {
    margin-bottom: 20px;
    box-sizing: border-box;
}

.audio-post-compose-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.audio-post-compose-field textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
    min-height: 80px;
    resize: vertical;
}

.audio-post-compose-field textarea:focus {
    outline: none;
    border-color: #135BFF;
}

/* 音频文件上传区域 */
.audio-file-upload {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: 2px dashed #e5e7eb;
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #f9fafb;
}

.audio-file-upload:hover {
    border-color: #135BFF;
    background: rgba(19, 91, 255, 0.02);
}

.audio-file-upload-placeholder p {
    margin: 12px 0 0 0;
    font-size: 14px;
    color: #6b7280;
}

#audioFileInfo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 100%;
    overflow: hidden;
}

#audioFileName {
    font-size: 14px;
    font-weight: 500;
    color: #135BFF;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 350px;
}

.audio-post-compose-actions {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.audio-post-compose-actions button {
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.audio-post-compose-cancel {
    background: #f3f4f6;
    color: #1a1a1a;
}

.audio-post-compose-cancel:hover {
    background: #e5e7eb;
}

.audio-post-compose-submit {
    background: linear-gradient(135deg, #135BFF 0%, #4047FF 100%);
    color: white;
}

.audio-post-compose-submit:hover:not(:disabled) {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(19, 91, 255, 0.3);
}

.audio-post-compose-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== Thread风格音频播放器 ========== */
.audio-player-container {
    margin-top: 12px;
    margin-left: 60px;
    margin-bottom: 10px;
    background: #f7f9fa;
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #e1e8ed;
    transition: all 0.2s;
    width: calc(100% - 60px);
    max-width: calc(100% - 60px);
    box-sizing: border-box;
}

.audio-player-container:hover {
    background: #f0f3f5;
}

/* 播放按钮 */
.audio-play-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: #000000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.audio-play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.audio-play-btn svg {
    fill: white;
    width: 18px;
    height: 18px;
}

/* 播放中状态 */
.audio-play-btn.playing {
    background: #333333;
}

/* 波形/进度条区域 */
.audio-waveform {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 时间显示 */
.audio-time {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #000000;
    font-weight: 500;
}

.audio-current-time {
    color: #000000;
}

/* 进度条 */
.audio-progress-bar {
    width: 100%;
    height: 4px;
    background: #e1e8ed;
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.audio-progress-fill {
    height: 100%;
    background: #000000;
    border-radius: 2px;
    transition: width 0.1s linear;
    position: relative;
}

.audio-progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: #000000;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.2s;
}

.audio-progress-bar:hover .audio-progress-fill::after,
.audio-progress-bar.seeking .audio-progress-fill::after {
    opacity: 1;
}

/* 可视化波形（可选） */
.audio-visualization {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 32px;
}

.audio-bar {
    width: 3px;
    background: #d1d5db;
    border-radius: 2px;
    transition: all 0.2s;
}

.audio-bar.active {
    background: linear-gradient(180deg, #135BFF 0%, #4047FF 100%);
}

/* 实际的audio元素（隐藏） */
.audio-player-container audio {
    display: none;
}

/* ========== Spoiler Feature（黑点遮罩效果） ========== */
.audio-post-spoiler-wrapper {
    position: relative;
    display: inline-block;
    cursor: pointer;
    user-select: none;
    vertical-align: baseline;
    line-height: 0; /* 防止额外高度 */
    margin: 0;
    padding: 0;
    text-align: left;
}

.audio-post-spoiler-wrapper.revealed {
    cursor: default;
}

/* 文本内容 */
.spoiler-text-content {
    display: inline-block;
    position: relative;
    z-index: 1;
    opacity: 0;
    color: transparent;
    user-select: none;
    line-height: 20px; /* 恢复正常行高 */
    vertical-align: baseline;
    margin: 0;
    padding: 0;
    text-align: left;
}

/* 已揭示的文本 */
.audio-post-spoiler-wrapper.revealed .spoiler-text-content {
    opacity: 1;
    color: inherit;
    user-select: text;
    animation: revealText 0.3s ease-out;
}

/* 黑点遮罩层 - Canvas 版本 */
.spoiler-canvas {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* 在post-content内的遮罩层额外确保 */
.post-content .audio-post-spoiler-wrapper .spoiler-canvas {
    position: absolute !important;
}

/* 已揭示时隐藏 Canvas */
.audio-post-spoiler-wrapper.revealed .spoiler-canvas {
    animation: fadeOutDots 0.3s ease-out forwards;
}

/* 确保包含Spoiler的post-content左对齐并移除额外间距 */
.post-content:has(.audio-post-spoiler-wrapper) {
    text-align: left;
    display: block;
    margin-top: -31px !important;  /* 保持与其他帖子一致 */
    margin-bottom: 0 !important;   /* 移除底部间距 */
    padding: 0 !important;
    min-height: auto !important;
}

/* Spoiler wrapper在post-content内强制左对齐 */
.post-content .audio-post-spoiler-wrapper {
    display: block;
    width: fit-content;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left;
    line-height: 0 !important; /* 保持0防止额外高度 */
    overflow: visible;
}

/* text-content在wrapper内强制左对齐 */
.post-content .audio-post-spoiler-wrapper .spoiler-text-content {
    display: block;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left;
    line-height: 20px !important; /* 确保文本正常行高 */
}

@keyframes fadeOutDots {
    to {
        opacity: 0;
        transform: scale(1.5);
    }
}

@keyframes revealText {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 加载状态 */
.audio-player-container.loading .audio-play-btn {
    background: #9ca3af;
    cursor: wait;
}

.audio-player-container.loading .audio-play-btn::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* 移动端优化 */
@media (max-width: 768px) {
    .audio-post-compose-container {
        width: 95%;
        max-width: none;
    }

    .audio-player-container {
        padding: 10px 12px;
    }

    .audio-play-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .audio-play-btn svg {
        width: 16px;
        height: 16px;
    }
}
