/* 公共样式 - Common Styles */

/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基础样式 */
body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* 容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 顶部头部样式 */
.top-header {
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
    /* 使用 CSS 变量，默认 10px，便于布局中统一引用 */
    --th-pb: 10px;
    padding: var(--th-pb) 0;
}

.top-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
}

.ti-logo {
    height: 40px;
    width: auto;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.user-avatar:hover {
    background-color: #f0f0f0;
}

.avatar-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #ddd;
}

/* 语言切换 */
.language-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.lang-btn.active,
.lang-btn:hover {
    background-color: #0066cc;
    color: white;
    border-color: #0066cc;
}

/* 用户菜单 */
.user-menu {
    position: relative;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 180px;
    z-index: 1000;
    display: none;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown a {
    display: block;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.3s ease;
}

.user-dropdown a:hover {
    background-color: #f8f9fa;
}

.user-dropdown a:last-child {
    border-bottom: none;
}

/* 主导航 */
.main-header {
    background-color: #0066cc;
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 30px;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 10px 15px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 搜索容器 */
.search-container {
    display: flex;
    align-items: center;
    background-color: white;
    border-radius: 25px;
    padding: 5px;
    min-width: 300px;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    color: #333;
}

.search-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.search-btn:hover {
    background-color: #f0f0f0;
}

.advanced-search-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    border-radius: 4px;
    margin-left: 5px;
    transition: all 0.3s ease;
}

.advanced-search-btn:hover {
    background-color: #f0f0f0;
    color: #0066cc;
}

/* 面包屑导航 */
.breadcrumb {
    background-color: #fff;
    padding: 15px 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

.breadcrumb .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.breadcrumb-left {
    flex: 1;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    word-break: break-word;
}

.breadcrumb-right {
    flex-shrink: 0;
}

.breadcrumb .current {
    color: #0066cc;
    font-weight: 500;
}

.breadcrumb-left a {
    color: #666;
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb-left a:hover {
    color: #0066cc;
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    line-height: 1.4;
}

.btn-primary {
    background-color: #0066cc;
    color: white;
}

.btn-primary:hover {
    background-color: #0052a3;
}

.btn.btn-primary.new-question-btn:hover {
    color: #fff;
}

.btn-secondary {
    background-color: #f8f9fa;
    color: #333;
    border: 1px solid #dee2e6;
}

.btn-secondary:hover {
    background-color: #e9ecef;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

.form-control.error {
    border-color: #dc3545;
}

.form-text {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.form-error {
    font-size: 12px;
    color: #dc3545;
    margin-top: 5px;
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 30px 0;
}

.page-btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background-color: white;
    color: #666;
    cursor: pointer;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.page-btn:hover:not(.active):not(:disabled):not(.disabled):not(.ellipsis) {
    background-color: #f8f9fa;
    border-color: #0066cc;
    color: #0066cc;
}

.page-btn.active {
    background-color: #0066cc;
    color: white;
    border-color: #0066cc;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 统一为分页中的禁用与省略号样式（与“我的帖子”一致） */
.page-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.page-btn.ellipsis {
    border-color: transparent;
    cursor: default;
    pointer-events: none;
}

.page-info {
    margin: 0 15px;
    color: #666;
    font-size: 14px;
}

/* 标签样式 */
.tag {
    display: inline-block;
    background-color: #f0f0f0;
    color: #666;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 2px;
}

.tag:hover {
    background-color: #0066cc;
    color: white;
}

.tag.active {
    background-color: #0066cc;
    color: white;
}

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-badge.answered {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.unanswered {
    background-color: #f8d7da;
    color: #721c24;
}

.status-badge.closed {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status-badge.sticky {
    background-color: #fff3cd;
    color: #856404;
}

/* 加载状态 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #666;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0066cc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 提示消息 */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

/* Toast 通知 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
}

.toast {
    background: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 20px 0;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 0 20px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 底部样式 */
.footer {
    background-color: #333;
    color: white;
    padding: 40px 0 20px;
    margin-top: 50px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(7, minmax(160px, 1fr));
    gap: 18px;
    margin-bottom: 30px;
}

.footer-section h4 {
    margin-bottom: 15px;
    color: #fff;
    font-size: 16px;
}

.footer-section ul {
    list-style: none;
}

/* 底部板块列表嵌套层级缩进（支持3级） */
.footer-section ul ul { margin-left: 12px; }
.footer-section ul ul ul { margin-left: 12px; }

/* 底部分组标题链接样式（保持白色并可悬停变色） */
.footer-section h4 a { color: #fff; text-decoration: none; }
.footer-section h4 a:hover { color: #0066cc; }

.footer-section li {
    margin-bottom: 6px;
}

.footer-section a {
    color: #ccc;
    text-decoration: none;
    transition: color 0.3s ease;
    font-size: 14px;
}

.footer-section a:hover {
    color: #0066cc;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #555;
    color: #ccc;
    font-size: 14px;
}

/* 工具类 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: #666; }
.text-primary { color: #0066cc; }
.text-success { color: #28a745; }
.text-danger { color: #dc3545; }
.text-warning { color: #ffc107; }

.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .main-nav {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    
    .search-container {
        min-width: 250px;
    }
    
    .top-header .container {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .logo-section,
    .user-section {
        justify-content: center;
    }
    
    .breadcrumb .container {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .page-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .footer-content { grid-template-columns: 1fr; }
    .btn {
        padding: 8px 16px;
        font-size: 12px;
    }
    
    .form-control {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .search-container {
        min-width: 200px;
    }
    
    .nav-menu {
        gap: 10px;
    }
    
    .nav-link {
        padding: 8px 12px;
        font-size: 14px;
    }
}
