/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary-color: #333333;
    --secondary-color: #666666;
    --accent-color: #999999;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-dark: #333333;
    --text-light: #999999;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 
                 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* 头部样式 */
header {
    background: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.header-content {
    text-align: center;
}

header h1 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 400;
}

.mini-header {
    padding: 1rem 0;
}

.mini-header .container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-btn {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
}

.back-btn:hover {
    background: var(--secondary-color);
}

/* 主容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* 欢迎卡片 */
.welcome-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--border-color);
}

.welcome-card h2 {
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.welcome-card p {
    color: var(--text-light);
    font-size: 1rem;
    line-height: 1.8;
}

.welcome-card .disclaimer {
    font-size: 0.85rem;
    color: #999;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-style: italic;
}

.welcome-card .disclaimer a {
    color: var(--text-dark);
    text-decoration: none;
    transition: color 0.3s;
}

.welcome-card .disclaimer a:hover {
    color: #666;
    text-decoration: underline;
}

/* 区块 */
.section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section h2, .section h3 {
    color: var(--text-dark);
    font-size: 1.3rem;
    font-weight: 600;
}

/* 按钮样式 */
.btn-refresh {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.btn-refresh:hover {
    background: var(--bg-color);
}

.refresh-icon {
    display: inline-block;
    transition: transform 0.3s;
}

.btn-play {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn-play:hover {
    background: var(--secondary-color);
}

/* 故事卡片 */
.story-card {
    background: white;
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s;
    border: 1px solid var(--border-color);
}

.story-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--text-light);
}

.story-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-dark);
    min-width: 50px;
    text-align: center;
}

.story-icon {
    font-size: 2.5rem;
}

.story-info {
    flex: 1;
    min-width: 0;
}

.story-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    font-size: 0.85rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* 隐藏文件大小 */
.meta-item:nth-child(2) {
    display: none !important;
}

.story-description {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.3rem;
    line-height: 1.4;
}

/* 状态展示 */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

.spinner {
    width: 45px;
    height: 45px;
    border: 4px solid var(--border-color);
    border-top-color: var(--text-dark);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-spinner p {
    margin-top: 1rem;
    color: var(--text-light);
}

.empty-state, .error-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-icon, .error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state p, .error-state p {
    color: var(--text-dark);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.empty-state small, .error-state small {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* 音频播放器 */
.player-container {
    max-width: 800px;
    margin: 0 auto;
}

.player-section {
    margin-bottom: 2rem;
}

.story-cover {
    width: 100%;
    max-width: 300px;
    height: 300px;
    margin: 0 auto 2rem;
    background: var(--bg-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.cover-icon {
    font-size: 6rem;
    width: 150px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cover-icon svg {
    width: 100%;
    height: 100%;
    color: var(--text-light);
}

.story-title-large {
    text-align: center;
    color: var(--text-dark);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    padding: 0 1rem;
    font-weight: 600;
}

.story-description-large {
    text-align: center;
    color: var(--text-light);
    font-size: 1rem;
    margin: 0 auto 2rem;
    padding: 0 1rem;
    max-width: 600px;
}

.audio-player-modern audio {
    width: 100%;
    height: 60px;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* 视频播放器 */
.video-player-container {
    width: 100%;
    margin: 2rem auto;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.video-player-container video {
    width: 100%;
    max-height: 70vh;
    display: block;
    background: #000;
}

.player-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.control-btn {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    padding: 0.8rem 1.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.95rem;
    font-weight: 500;
}

.control-btn:hover {
    background: var(--bg-color);
}

.control-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.control-btn.primary:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* 播放列表 */
.playlist-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.playlist-title {
    color: var(--text-dark);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.playlist {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.playlist-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.playlist-item:hover {
    background: var(--bg-color);
    transform: translateX(5px);
}

.playlist-item.active {
    background: #f0f8ff;
    border-color: var(--text-dark);
}

.playlist-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.playlist-info {
    flex: 1;
    min-width: 0;
}

.playlist-title-text {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playlist-description {
    font-size: 0.85rem;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playing-indicator {
    font-size: 0.85rem;
    color: var(--text-dark);
    font-weight: 500;
    flex-shrink: 0;
}

.no-content {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
    font-style: italic;
}

/* PDF查看器 */
.pdf-container {
    max-width: 100%;
}

.pdf-info-section {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-bottom: 1.5rem;
}

.pdf-viewer-wrapper {
    position: relative;
    width: 100%;
    height: 80vh;
    background: var(--bg-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

#pdfViewer {
    width: 100%;
    height: 100%;
    border: none;
    display: none;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: white;
}

.pdf-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-download {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 1rem 2.5rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-download:hover {
    background: var(--secondary-color);
}

/* 评论区 */
.comments-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.comments-title {
    color: var(--text-dark);
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.comment-form {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.comment-textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    resize: vertical;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-dark);
    margin-bottom: 0.8rem;
}

.comment-textarea:focus {
    outline: none;
    border-color: var(--text-dark);
}

.comment-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    font-size: 0.85rem;
    color: var(--text-light);
}

.btn-submit-comment {
    background: var(--text-dark);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.btn-submit-comment:hover {
    background: #666;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.comment-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

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

.comment-time {
    font-size: 0.85rem;
    color: var(--text-light);
}

.comment-content {
    color: var(--text-dark);
    line-height: 1.6;
    font-size: 0.95rem;
    word-wrap: break-word;
}

.no-comments {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
    font-style: italic;
}

/* 管理后台 */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.login-container {
    background: white;
    border-radius: 12px;
    padding: 3rem 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: var(--text-dark);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-light);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-field label {
    color: var(--text-dark);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-field input, .form-field textarea {
    padding: 0.9rem 1.2rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
    font-family: inherit;
}

.form-field input:focus, .form-field textarea:focus {
    outline: none;
    border-color: var(--text-dark);
}

.field-hint {
    display: block;
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

.btn-login {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-login:hover {
    background: var(--secondary-color);
}

.login-error {
    color: #e74c3c;
    text-align: center;
    padding: 0.8rem;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 8px;
    display: none;
}

.back-to-home {
    display: block;
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.3s;
}

.back-to-home:hover {
    color: var(--text-dark);
}

.btn-logout {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: #c0392b;
}

/* 上传区域 */
.upload-tabs, .manage-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    font-size: 1rem;
    transition: all 0.3s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-btn.active {
    color: var(--text-dark);
    border-bottom-color: var(--text-dark);
    font-weight: 600;
}

.upload-drop-zone {
    position: relative;
    margin-bottom: 1.5rem;
}

.upload-drop-zone input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.upload-drop-zone label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 2rem;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-color);
}

.upload-drop-zone label:hover {
    border-color: var(--text-light);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-drop-zone label span {
    font-size: 1rem;
    color: var(--text-dark);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.upload-drop-zone label small {
    color: var(--text-light);
    font-size: 0.85rem;
}

.btn-upload {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s;
}

.btn-upload:hover {
    background: var(--secondary-color);
}

.upload-status {
    margin-top: 1rem;
    text-align: center;
}

.success-message {
    color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
}

.error-message {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
}

/* 管理列表 */
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 评论管理 */
.comment-admin-item {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.comment-admin-info {
    flex: 1;
}

.comment-admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

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

.comment-admin-time {
    font-size: 0.85rem;
    color: var(--text-light);
}

.comment-admin-content {
    background: var(--bg-color);
    padding: 0.8rem;
    border-radius: 6px;
    color: var(--text-dark);
    line-height: 1.6;
    word-wrap: break-word;
}

.comment-admin-actions {
    display: flex;
    justify-content: flex-end;
}

.admin-item {
    background: white;
    border-radius: 12px;
    padding: 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}

.admin-item-sort {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.btn-sort {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.btn-sort:hover:not(:disabled) {
    background: #e0e0e0;
    transform: scale(1.1);
}

.btn-sort:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.admin-item:hover {
    box-shadow: var(--shadow-hover);
}

.admin-item-icon {
    font-size: 2rem;
}

.admin-item-info {
    flex: 1;
    min-width: 0;
}

.admin-item-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.3rem;
    word-break: break-all;
}

.admin-item-meta {
    font-size: 0.85rem;
    color: var(--text-light);
}

.admin-item-description {
    font-size: 0.9rem;
    color: var(--text-dark);
    margin-top: 0.3rem;
    font-style: italic;
}

.admin-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-edit, .btn-delete {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    color: white;
}

.btn-edit {
    background: #3498db;
}

.btn-edit:hover {
    background: #2980b9;
}

.btn-delete {
    background: #e74c3c;
}

.btn-delete:hover {
    background: #c0392b;
}

/* 页脚 */
footer {
    background: white;
    margin-top: 3rem;
    padding: 2rem 1rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

footer p {
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.admin-link {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.admin-link:hover {
    color: var(--secondary-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    .section {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .welcome-card {
        padding: 1.5rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .story-card {
        flex-wrap: wrap;
        padding: 1rem;
    }

    .story-number {
        order: -1;
    }

    .story-info {
        order: 0;
        width: 100%;
    }

    .story-meta {
        flex-direction: column;
        gap: 0.3rem;
    }

    .btn-play {
        order: 1;
        width: 100%;
        justify-content: center;
    }

    .story-cover {
        width: 200px;
        height: 200px;
    }

    .cover-icon {
        font-size: 4rem;
    }

    .player-controls {
        flex-direction: column;
    }

    .control-btn {
        width: 100%;
    }

    .admin-item {
        flex-wrap: wrap;
    }

    .admin-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .login-container {
        padding: 2rem 1.5rem;
    }
}

/* 动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.story-card {
    animation: fadeIn 0.5s ease-out;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* 辅助类 */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: var(--secondary-color);
}

.btn-secondary {
    background: var(--text-light);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--text-dark);
}

.btn-success {
    background: #27ae60;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-success:hover {
    background: #229954;
}

.audio-player-simple audio {
    width: 100%;
    margin: 1rem 0;
    border-radius: 8px;
}
