/* 基础样式 */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --border-radius: 8px;
    --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    /* 移动端优化 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* 防止移动端双击缩放 */
    touch-action: manipulation;
}

.hidden {
    display: none !important;
}

/* 按钮样式 */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    /* 移动端优化：增加触摸目标大小 */
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--secondary-color);
    border: 2px solid var(--secondary-color);
}

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

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(0);
}

/* 论坛页面样式 */
#forum-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    z-index: 2000;
    overflow-y: auto;
    /* 移动端滚动优化 */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.forum-header {
    background: var(--primary-color);
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--box-shadow);
    min-height: 56px;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    /* 移动端固定头部 */
    position: sticky;
    top: 0;
    z-index: 100;
}

.forum-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
    flex: 1;
    text-align: center;
    margin-left: 0;
    margin-right: 0;
}

.forum-header .btn-secondary {
    white-space: nowrap;
    min-width: 100px;
    z-index: 10;
    margin-right: auto;
}

.forum-header .btn-primary {
    white-space: nowrap;
    min-width: 120px;
    z-index: 10;
    margin-left: auto;
    margin-right: 0;
}

.forum-header .btn-outline {
    white-space: nowrap;
    min-width: 100px;
    z-index: 10;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.forum-container {
    padding: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

.forums-list {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.forum-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--box-shadow);
}

.forum-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    background: #fff;
}

/* 移动端触摸反馈 */
@media (hover: none) and (pointer: coarse) {
    .forum-item:active,
    .topic-item:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .btn:active {
        transform: scale(0.95);
        opacity: 0.9;
    }
}

.forum-item h3 {
    margin: 0 0 10px 0;
    color: var(--dark-color);
    font-size: 1.3rem;
}

.forum-item p {
    margin: 0 0 15px 0;
    color: #6c757d;
    line-height: 1.5;
}

.forum-stats {
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
    color: #6c757d;
}

.topics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.topics-header h3 {
    margin: 0;
    color: var(--dark-color);
    font-size: 1.5rem;
}

.new-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
}

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

.topic-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--box-shadow);
}

.topic-item:hover {
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.topic-item h3,
.topic-item h4 {
    margin: 0 0 8px 0;
    color: var(--dark-color);
    font-size: 1.1rem;
}

.topic-item .topic-link {
    color: inherit;
    text-decoration: none;
    display: inline-block;
    transition: color 0.3s ease;
}

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

.topic-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: #6c757d;
}

.topic-stats {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    font-size: 0.8rem;
    color: #6c757d;
}

.topic-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.topic-header h2,
.topic-header h3 {
    margin: 0 0 10px 0;
    color: var(--dark-color);
    font-size: 1.6rem;
    line-height: 1.4;
}

.topic-content {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    line-height: 1.6;
    box-shadow: var(--box-shadow);
}

.replies-section h4 {
    margin: 0 0 15px 0;
    color: var(--dark-color);
    font-size: 1.2rem;
}

.reply-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: var(--box-shadow);
}

.reply-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #6c757d;
}

.reply-content {
    line-height: 1.6;
}

.reply-form {
    margin-top: 20px;
    position: sticky;
    bottom: 0;
    background: white;
    padding: 15px;
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.reply-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    resize: vertical;
    font-size: 16px; /* 防止iOS自动缩放 */
    -webkit-appearance: none;
    appearance: none;
}

@media (max-width: 768px) {
    .reply-form {
        padding: 12px;
        margin-top: 15px;
    }
    
    .reply-form textarea {
        padding: 12px;
        min-height: 100px;
    }
    
    #submit-reply {
        width: 100%;
        margin-top: 10px;
    }
}

.no-topics, .no-replies {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-style: italic;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    overflow-y: auto;
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 0;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 15px 20px;
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
}

.close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    /* 移动端优化 */
    font-size: 16px; /* 防止iOS自动缩放 */
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* 加载动画 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--secondary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* 响应式设计 */
@media (max-width: 768px) {
    .forum-header {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 15px;
        min-height: auto;
    }
    
    .forum-header .btn-secondary {
        min-width: auto;
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
        order: 1;
    }
    
    .forum-header h2 {
        font-size: 1.2rem;
        order: 2;
        flex: 1 1 100%;
        text-align: center;
        margin: 5px 0;
    }
    
    .forum-header .header-actions {
        order: 3;
        width: 100%;
        justify-content: center;
        gap: 8px;
    }
    
    .forum-header .btn-primary,
    .forum-header .btn-outline {
        min-width: auto;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        flex: 1;
        justify-content: center;
    }
    
    .forum-container {
        padding: 10px;
        padding-bottom: 20px;
    }
    
    .forums-list {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px auto;
        max-height: calc(100vh - 20px);
        display: flex;
        flex-direction: column;
    }
    
    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
    }
    
    .topic-meta {
        flex-direction: column;
        gap: 5px;
        font-size: 0.8rem;
    }
    
    .topic-stats {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .topic-header h2,
    .topic-header h3 {
        font-size: 1.3rem;
        line-height: 1.3;
    }
    
    .topic-content,
    .reply-item {
        padding: 12px;
    }
    
    .reply-form textarea {
        font-size: 16px; /* 防止iOS缩放 */
        min-height: 120px;
    }
}

@media (max-width: 576px) {
    .forum-header {
        padding: 8px 10px;
    }
    
    .forum-header h2 {
        font-size: 1rem;
        margin: 3px 0;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        min-height: 44px;
    }
    
    .forum-item {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .forum-item h3 {
        font-size: 1.05rem;
        margin-bottom: 8px;
    }
    
    .forum-item p {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    .forum-stats {
        font-size: 0.8rem;
        gap: 10px;
    }
    
    .topic-item {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .topic-item h3,
    .topic-item h4 {
        font-size: 0.95rem;
        line-height: 1.3;
        margin-bottom: 6px;
    }
    
    .topic-meta {
        font-size: 0.75rem;
        gap: 8px;
    }
    
    .topic-header h2,
    .topic-header h3 {
        font-size: 1.1rem;
    }
    
    .topic-content {
        padding: 12px;
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    .reply-item {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .reply-header {
        font-size: 0.8rem;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .reply-content {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    .modal-content {
        width: 98%;
        margin: 5px auto;
        max-height: calc(100vh - 10px);
        border-radius: 8px;
    }
    
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .modal-footer {
        padding: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: calc(50% - 4px);
    }
    
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 12px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    .close {
        font-size: 24px;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 图片预览优化 */
    .images-preview {
        gap: 8px;
    }
    
    .image-preview-item {
        width: 80px;
        height: 80px;
    }
    
    .remove-image {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
}


/* 图片预览样式 */
.images-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.image-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    overflow: hidden;
    flex-shrink: 0;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.remove-image:hover {
    background: rgba(255, 0, 0, 1);
}

/* 内容中的图片样式 */
.topic-content img,
.reply-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin: 10px 0;
    box-shadow: var(--box-shadow);
}

/* 话题图片容器 */
.topic-image-container {
    margin: 15px 0;
    text-align: center;
}

.topic-image-container .topic-image {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.topic-image-container .topic-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 移动端图片优化 */
@media (max-width: 768px) {
    .topic-image-container .topic-image {
        max-height: 300px;
    }
}

/* 确保图片不会溢出容器 */
.topic-content,
.reply-content {
    overflow-wrap: break-word;
    word-wrap: break-word;
    /* 移动端优化：更好的文本换行 */
    word-break: break-word;
    hyphens: auto;
}

.topic-content *,
.reply-content * {
    max-width: 100%;
}

/* 移动端链接优化 */
.topic-content a,
.reply-content a {
    color: var(--secondary-color);
    text-decoration: underline;
    word-break: break-all;
}

/* 移动端表格优化 */
@media (max-width: 768px) {
    .topic-content table,
    .reply-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }
}

/* 移动端列表优化 */
.topic-content ul,
.topic-content ol,
.reply-content ul,
.reply-content ol {
    padding-left: 20px;
    margin: 10px 0;
}

@media (max-width: 576px) {
    .topic-content ul,
    .topic-content ol,
    .reply-content ul,
    .reply-content ol {
        padding-left: 15px;
    }
}

/* 移动端代码块优化 */
.topic-content pre,
.topic-content code,
.reply-content pre,
.reply-content code {
    overflow-x: auto;
    word-wrap: normal;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .topic-content pre,
    .reply-content pre {
        font-size: 0.85rem;
        padding: 10px;
        border-radius: 4px;
    }
}


/* 管理员操作按钮样式 */
.admin-actions {
    display: flex;
    gap: 5px;
    margin-left: auto;
    align-items: center;
}

.admin-actions .btn {
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
    min-width: auto;
}

.admin-actions .btn-sm {
    padding: 3px 6px;
    font-size: 0.75rem;
}

.admin-actions .btn-danger {
    background: var(--danger-color);
    color: white;
}

.admin-actions .btn-warning {
    background: var(--warning-color);
    color: white;
}

.admin-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* 主题列表中的管理员按钮 */
.topic-item .admin-actions {
    margin-left: 10px;
}

.topic-header .admin-actions {
    margin-top: 10px;
}

/* 回复中的管理员按钮 */
.reply-header .admin-actions {
    margin-left: 10px;
}

/* 管理员模式样式 */
.admin-mode .topic-item,
.admin-mode .reply-item {
    border-left: 3px solid var(--warning-color);
}

/* 响应式设计中的管理员按钮 */
@media (max-width: 768px) {
    .admin-actions {
        flex-direction: row;
        gap: 5px;
        flex-wrap: wrap;
        margin-top: 8px;
    }
    
    .admin-actions .btn {
        padding: 6px 10px;
        font-size: 0.75rem;
        min-height: 36px;
        min-width: 36px;
    }
    
    .topic-header .admin-actions {
        margin-top: 8px;
        width: 100%;
    }
    
    .reply-header .admin-actions {
        margin-top: 5px;
        width: 100%;
    }
}

@media (max-width: 576px) {
    .admin-actions {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .admin-actions .btn {
        padding: 8px 12px;
        font-size: 0.75rem;
        min-height: 40px;
        min-width: 40px;
        flex: 1;
        justify-content: center;
    }
    
    .admin-actions .btn i {
        margin-right: 4px;
    }
    
    /* 移动端管理员按钮更明显 */
    .admin-actions .btn-danger {
        background: var(--danger-color);
    }
    
    .admin-actions .btn-warning {
        background: var(--warning-color);
    }
}

/* 超小屏幕优化 (小于400px) */
@media (max-width: 400px) {
    .forum-header {
        padding: 6px 8px;
    }
    
    .forum-header h2 {
        font-size: 0.9rem;
    }
    
    .forum-header .btn {
        padding: 0.5rem 0.7rem;
        font-size: 0.75rem;
    }
    
    .forum-container {
        padding: 8px;
    }
    
    .forum-item,
    .topic-item,
    .reply-item {
        padding: 10px;
    }
    
    .modal-content {
        width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .modal-header {
        padding: 10px;
    }
    
    .modal-body {
        padding: 10px;
    }
    
    .admin-actions .btn {
        padding: 6px 10px;
        font-size: 0.7rem;
    }
}