/**
 * OJ 前端全局样式
 * 纯手写，无 CDN
 */

/* ===== 重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background: #f5f7fa;
    min-height: 100vh;
}

a {
    color: #1a73e8;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== 布局 ===== */
.container {
    max-width: 50vw;
    margin: 0 auto;
    padding: 0 16px;
}

.page {
    padding: 24px 0;
}

/* ===== 顶部导航 ===== */
.header {
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 50vw;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-logo {
    font-size: 20px;
    font-weight: bold;
    color: #1a73e8;
}

.header-nav a {
    margin-left: 20px;
    color: #555;
    font-size: 14px;
}

.header-nav a:hover {
    color: #1a73e8;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-user span {
    color: #666;
}

/* ===== 卡片 ===== */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

/* ===== 表格 ===== */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

th {
    background: #fafafa;
    font-weight: 600;
    color: #666;
}

tr:hover td {
    background: #fafafa;
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #1a73e8;
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.form-error {
    color: #d93025;
    font-size: 13px;
    margin-top: 6px;
    display: none;
}

.form-error.show {
    display: block;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: #1a73e8;
    color: #fff;
}

.btn-primary:hover {
    background: #1557b0;
}

.btn-secondary {
    background: #fff;
    color: #555;
    border: 1px solid #d9d9d9;
}

.btn-secondary:hover {
    border-color: #1a73e8;
    color: #1a73e8;
}

.btn-danger {
    background: #d93025;
    color: #fff;
}

.btn-danger:hover {
    background: #b31412;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ===== 标签 ===== */
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.tag-diff-entry,
.tag-diff-popm,
.tag-diff-popp,
.tag-diff-impvm,
.tag-diff-impvp,
.tag-diff-prov,
.tag-diff-ctsc,
.tag-diff-none {
    background: #f5f5f5;
    color: #555;
}

.tag-accepted {
    background: #e6f7e6;
    color: #2e7d32;
}

.tag-wrong_answer,
.tag-time_limit_exceeded,
.tag-memory_limit_exceeded,
.tag-runtime_error {
    background: #ffebee;
    color: #c62828;
}

.tag-compilation_error,
.tag-compile_error {
    background: #fff3e0;
    color: #ef6c00;
}

.tag-pending,
.tag-compiling,
.tag-running {
    background: #e3f2fd;
    color: #1565c0;
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination-btn {
    padding: 8px 16px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    background: #fff;
    color: #555;
    cursor: pointer;
    font-size: 14px;
}

.pagination-btn:hover {
    border-color: #1a73e8;
    color: #1a73e8;
}

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

/* ===== 代码编辑器 ===== */
.code-editor {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 14px;
    line-height: 1.6;
    background: #fafafa;
    resize: vertical;
}

.code-editor:focus {
    outline: none;
    border-color: #1a73e8;
    background: #fff;
}

.code-block {
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.code-block-wrap {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: hidden;
}

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

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

/* ===== 加载中 ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* ===== 消息提示 ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.toast-success {
    background: #2e7d32;
}

.toast-error {
    background: #c62828;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== 首页公告 + 题目列表容器 ===== */
.container.has-sidebar {
    position: relative;
}

.home-sidebar {
    position: absolute;
    left: calc(100% + 20px);
    top: 0;
    width: 220px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

/* ===== 倒计时卡片 ===== */
.countdown-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-bottom: 16px;
}

.countdown-header {
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #333;
}

.countdown-list {
    list-style: none;
}

.countdown-item {
    border-bottom: 1px solid #f5f5f5;
    padding: 10px 16px;
}

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

.countdown-title {
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-bottom: 2px;
}

.countdown-time {
    font-size: 16px;
    font-weight: 700;
    color: #1a73e8;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    letter-spacing: 1px;
}

.countdown-item.expired .countdown-time {
    color: #c62828;
}

.countdown-empty {
    padding: 20px 16px;
    text-align: center;
    color: #ccc;
    font-size: 13px;
}

/* ===== 公告卡片 ===== */
.announcement-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}

.announcement-header {
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #333;
}

.announcement-list {
    list-style: none;
}

.announcement-item {
    border-bottom: 1px solid #f5f5f5;
}

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

.announcement-item-title {
    display: block;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.announcement-item-title:hover {
    background: #f8f9fc;
    color: #1a73e8;
    text-decoration: none;
}

.announcement-body {
    padding: 0 16px 20px;
    font-size: 14px;
    color: #333;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}

.announcement-empty {
    padding: 20px 16px;
    text-align: center;
    color: #ccc;
    font-size: 13px;
}
.split-container {
    display: flex;
    gap: 16px;
    max-width: 75vw;
    height: calc(100vh - 56px);
}

.split-left,
.split-right {
    flex: 1 1 0;
    min-width: 0;
    overflow-y: auto;
}

.split-left {
    padding-right: 8px;
}

.split-right {
    padding-left: 8px;
}

.split-left::-webkit-scrollbar,
.split-right::-webkit-scrollbar {
    width: 6px;
}

.split-left::-webkit-scrollbar-thumb,
.split-right::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.split-left::-webkit-scrollbar-thumb:hover,
.split-right::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

.split-right .code-editor {
    min-height: 400px;
    resize: none;
    tab-size: 4;
}

/* ===== 用户主页 ===== */
.user-info-card {
    padding: 28px 24px;
}

.user-avatar-lg {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-avatar-placeholder {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #1a73e8;
    color: #fff;
    font-size: 32px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-nickname {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.user-username {
    font-size: 14px;
    color: #999;
}

.user-bio {
    margin-top: 8px;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.user-meta {
    margin-top: 8px;
    color: #999;
    font-size: 13px;
}

.tag-admin {
    background: #ffebee;
    color: #c62828;
}

.ac-status {
    font-size: 16px;
    font-weight: bold;
    color: #2e7d32;
}

.tried-status {
    font-size: 14px;
    font-weight: bold;
    color: #c62828;
    opacity: 0.7;
}

.loading-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* ===== 已通过题目 ===== */
.ac-problem-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ac-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #f0f7ff;
    border: 1px solid #d0e3f7;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    text-decoration: none;
    transition: all 0.15s;
}

.ac-tag:hover {
    background: #dceeff;
    border-color: #1a73e8;
    color: #1a73e8;
    text-decoration: none;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
    }

    .header-nav a {
        margin-left: 12px;
        font-size: 13px;
    }

    th, td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .container {
        padding: 0 12px;
    }

    .page {
        padding: 0;
    }

    .split-container {
        flex-direction: column;
        height: auto;
    }

    .split-left {
        height: 50vh;
    }

    .split-right {
        min-width: 0;
    }
}
