/* 前台样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #fafafa;
    color: #1a1a1a;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #2d7d46;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* 导航栏 */
.navbar {
    background: white;
    border-bottom: 1px solid #e5e5e5;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand:hover {
    text-decoration: none;
}

.navbar-brand svg {
    width: 24px;
    height: 24px;
    color: #2d7d46;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.navbar-nav a {
    color: #666;
    font-size: 14px;
    text-decoration: none;
    transition: color 0.2s;
}

.navbar-nav a:hover {
    color: #2d7d46;
}

/* 主内容 */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

/* 页面头部 */
.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.page-header p {
    color: #666;
    font-size: 14px;
}

/* 比赛卡片 */
.contest-grid {
    display: grid;
    gap: 20px;
}

.contest-card {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    padding: 24px;
    transition: box-shadow 0.2s;
}

.contest-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.contest-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.contest-card-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.contest-card-title a {
    color: inherit;
}

.contest-card-title a:hover {
    color: #2d7d46;
    text-decoration: none;
}

.contest-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.contest-status.running {
    background: #dcfce7;
    color: #166534;
}

.contest-status.pending {
    background: #fef3c7;
    color: #92400e;
}

.contest-status.ended {
    background: #f3f4f6;
    color: #4b5563;
}

.contest-card-info {
    display: flex;
    gap: 24px;
    color: #666;
    font-size: 14px;
    margin-bottom: 16px;
}

.contest-card-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.contest-card-info-item svg {
    width: 16px;
    height: 16px;
}

.contest-card-description {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.contest-card-actions {
    display: flex;
    gap: 12px;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: #2d7d46;
    color: white;
}

.btn-primary:hover {
    background: #236b38;
    text-decoration: none;
}

.btn-secondary {
    background: #f3f4f6;
    color: #333;
}

.btn-secondary:hover {
    background: #e5e5e5;
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid #ddd;
    color: #333;
}

.btn-outline:hover {
    border-color: #2d7d46;
    color: #2d7d46;
    text-decoration: none;
}

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

/* 题目列表 */
.problem-list {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    overflow: hidden;
}

.problem-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.problem-item:last-child {
    border-bottom: none;
}

.problem-item:hover {
    background: #f9fafb;
}

.problem-index {
    width: 40px;
    font-size: 14px;
    color: #999;
}

.problem-title {
    flex: 1;
    font-size: 15px;
}

.problem-title a {
    color: #1a1a1a;
}

.problem-title a:hover {
    color: #2d7d46;
    text-decoration: none;
}

.problem-difficulty {
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 4px;
}

.problem-difficulty.d-1 { background: #f3f4f6; color: #6b7280; }
.problem-difficulty.d-2 { background: #dbeafe; color: #1e40af; }
.problem-difficulty.d-3 { background: #c7d2fe; color: #3730a3; }
.problem-difficulty.d-4 { background: #e9d5ff; color: #6b21a8; }
.problem-difficulty.d-5 { background: #fce7f3; color: #9d174d; }
.problem-difficulty.d-6 { background: #fed7aa; color: #c2410c; }
.problem-difficulty.d-7 { background: #fecaca; color: #991b1b; }
.problem-difficulty.d-8 { background: #f3f4f6; color: #6b7280; }

/* 题目详情页 */
.problem-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
}

.problem-content {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    padding: 32px;
}

.problem-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e5e5e5;
}

.problem-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 16px;
}

.problem-meta {
    display: flex;
    gap: 24px;
    font-size: 14px;
    color: #666;
}

.problem-section {
    margin-bottom: 32px;
}

.problem-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #2d7d46;
}

.problem-section p {
    line-height: 1.8;
    margin-bottom: 16px;
}

.problem-section pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 16px;
    font-size: 13px;
}

.problem-section code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.problem-section p code {
    background: #f3f4f6;
    color: #333;
    padding: 2px 6px;
    border-radius: 4px;
}

.sample-block {
    margin-bottom: 24px;
}

.sample-block h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #666;
}

.sample-block pre {
    margin-bottom: 0;
}

/* 侧边栏 */
.problem-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-card {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    padding: 20px;
}

.sidebar-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #666;
}

.sidebar-card .info-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-card .info-item {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.sidebar-card .info-label {
    color: #666;
}

.sidebar-card .info-value {
    font-weight: 500;
}

/* 参赛者表单 */
.join-form {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    padding: 32px;
    max-width: 480px;
    margin: 0 auto;
}

.join-form h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.join-form p {
    color: #666;
    font-size: 14px;
    margin-bottom: 24px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #2d7d46;
}

.form-hint {
    font-size: 13px;
    color: #666;
    margin-top: 6px;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    color: #ddd;
}

.empty-state h2 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #666;
}

.empty-state p {
    font-size: 14px;
}

/* 页脚 */
.footer {
    background: white;
    border-top: 1px solid #e5e5e5;
    padding: 24px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* 响应式 */
@media (max-width: 768px) {
    .navbar {
        padding: 0 16px;
    }
    
    .main-content {
        padding: 20px 16px;
    }
    
    .problem-container {
        grid-template-columns: 1fr;
    }
    
    .contest-card-info {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .problem-item {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .problem-index {
        width: auto;
    }
}

/* Markdown渲染样式 */
.problem-content h1 { font-size: 24px; margin-bottom: 16px; }
.problem-content h2 { font-size: 20px; margin-bottom: 12px; }
.problem-content h3 { font-size: 18px; margin-bottom: 10px; }
.problem-content ul, .problem-content ol { margin-left: 24px; margin-bottom: 16px; }
.problem-content li { margin-bottom: 8px; line-height: 1.6; }
.problem-content blockquote { border-left: 4px solid #2d7d46; padding-left: 16px; margin: 16px 0; color: #666; }
.problem-content table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.problem-content th, .problem-content td { border: 1px solid #e5e5e5; padding: 8px 12px; text-align: left; }
.problem-content th { background: #f9fafb; font-weight: 600; }

/* KaTeX样式覆盖 */
.katex { font-size: 1em; }
.katex-display { margin: 16px 0; overflow-x: auto; }
