/* ==========================================================
   OJ 测评系统 样式
   ========================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --border: #e3e8ef;
    --text: #1f2937;
    --text-sub: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #7c3aed;

    --ac: #10b981;      /* Accepted 绿 */
    --wa: #ef4444;      /* Wrong Answer 红 */
    --tle: #f59e0b;     /* TLE 橙 */
    --mle: #f97316;     /* MLE 深橙 */
    --re:  #ec4899;     /* Runtime Error 粉 */
    --ce:  #8b5cf6;     /* Compilation Error 紫 */
    --pe:  #0ea5e9;     /* Presentation Error 天蓝 */
    --se:  #64748b;     /* System Error 灰蓝 */

    --sample-bg: #fef9c3;
    --hint-bg:   #eff6ff;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
pre { font-family: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace; }

/* ---------- 顶部 Header ---------- */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(135deg, #1e3a8a 0%, #4338ca 100%);
    color: #fff;
    box-shadow: 0 2px 12px rgba(30,58,138,0.15);
}
.header-inner {
    max-width: 1920px;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 56px;
}
.logo {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.logo span { opacity: 0.95; }
.problem-badge {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 8px;
    padding: 4px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(6px);
}
.badge-id {
    background: rgba(255,255,255,0.9);
    color: #4338ca;
    font-weight: 700;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
}
.badge-title { font-weight: 600; font-size: 15px; }
.header-actions { margin-left: auto; display: flex; gap: 12px; }
.limit-info {
    background: rgba(255,255,255,0.14);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 500;
}

/* ---------- 主体 双栏布局 ---------- */
.main {
    max-width: 1920px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    grid-template-columns: 440px 1fr;
    gap: 16px;
    height: calc(100vh - 56px);
    min-height: 0;
}

@media (max-width: 1024px) {
    .main {
        grid-template-columns: 1fr;
        height: auto;
    }
    .problem-panel { max-height: 50vh; }
}

/* ---------- 左：题目面板 ---------- */
.problem-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
}
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb {
    background: #d1d5db; border-radius: 8px;
}
.p-section { margin-bottom: 22px; }
.p-section h3 {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 10px;
    padding-left: 6px;
    border-left: 3px solid var(--primary);
    line-height: 1.4;
}
.p-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13.5px;
    line-height: 1.75;
    color: #374151;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
}
.limit-block {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
}
.limit-row {
    font-size: 13.5px;
    line-height: 2;
    color: #374151;
    font-family: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
}
.hint-text { background: var(--hint-bg); border-color: #bfdbfe; color: #1e40af; }

.sample-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sample-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sub);
    margin: 4px 0 2px 2px;
}
.sample-box {
    background: #0b1020;
    color: #e5e7eb;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid #1f2937;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.sample-box.in  { border-left: 3px solid #22d3ee; }
.sample-box.out { border-left: 3px solid #34d399; }

/* ---------- 右：工作区 ---------- */
.work-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

/* 工具栏 */
.editor-toolbar {
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafbfc;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.select-lang {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    outline: none;
}
.select-lang:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.12); }

.btn {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.btn-ghost {
    background: #fff;
    color: #374151;
    border-color: var(--border);
}
.btn-ghost:hover { background: #f3f4f6; border-color: #d1d5db; }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 1px 2px rgba(37,99,235,0.25);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-disabled { opacity: 0.6; cursor: not-allowed; }

/* 编辑器 */
.editor-wrap {
    flex: 1 1 50%;
    min-height: 260px;
    position: relative;
    border-bottom: 1px solid var(--border);
}
.editor-inner {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 260px;
    overflow: hidden;
}
.line-numbers {
    flex-shrink: 0;
    width: 48px;
    min-height: 100%;
    padding: 14px 8px 14px 0;
    text-align: right;
    background: #0d1326;
    border-right: 1px solid #1f2937;
    color: #4b5563;
    font-family: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
    font-size: 14px;
    line-height: 1.7;
    tab-size: 4;
    user-select: none;
    overflow: hidden;
    white-space: pre;
}
.code-editor {
    flex: 1;
    height: 100%;
    min-height: 260px;
    resize: none;
    padding: 14px 16px;
    border: none;
    outline: none;
    font-family: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
    font-size: 14px;
    line-height: 1.7;
    tab-size: 4;
    color: #e5e7eb;
    background: #0b1020;
    overflow: auto;
}
.code-editor::placeholder { color: #6b7280; }

/* 结果面板 */
.result-panel {
    flex: 1 1 50%;
    overflow-y: auto;
    padding: 16px 20px;
    background: #fcfcfd;
    border-top: 1px solid var(--border);
}
.result-panel::-webkit-scrollbar { width: 8px; }
.result-panel::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 8px; }

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.result-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
}
.result-time {
    font-size: 12px;
    color: var(--text-sub);
    font-weight: 500;
}

.result-summary {
    display: grid;
    grid-template-columns: 1.3fr repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
@media (max-width: 900px) {
    .result-summary { grid-template-columns: repeat(2, 1fr); }
}
.sum-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}
.sum-status {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px;
    padding: 10px 14px !important;
}
.st-big {
    font-size: 22px;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 8px;
    color: #fff;
    letter-spacing: 1px;
}
.st-full { font-size: 13px; font-weight: 600; color: var(--text); }
.sum-label {
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 4px;
    font-weight: 500;
}
.sum-num {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

/* 状态颜色 */
.st-ac .st-big  { background: var(--ac); }
.st-wa .st-big  { background: var(--wa); }
.st-tle .st-big { background: var(--tle); }
.st-mle .st-big { background: var(--mle); }
.st-re  .st-big { background: var(--re); }
.st-ce  .st-big { background: var(--ce); }
.st-pe  .st-big { background: var(--pe); }
.st-se  .st-big { background: var(--se); }

.sc-status.st-ac  { border-left: 3px solid var(--ac); }
.sc-status.st-wa  { border-left: 3px solid var(--wa); }
.sc-status.st-tle { border-left: 3px solid var(--tle); }
.sc-status.st-mle { border-left: 3px solid var(--mle); }
.sc-status.st-re  { border-left: 3px solid var(--re); }
.sc-status.st-ce  { border-left: 3px solid var(--ce); }
.sc-status.st-pe  { border-left: 3px solid var(--pe); }
.sc-status.st-se  { border-left: 3px solid var(--se); }

.score-100, .score-80, .score-60 { color: var(--ac) !important; }
.score-40, .score-20 { color: var(--tle) !important; }
.score-0            { color: var(--wa) !important; }

/* 错误框 */
.result-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
}
.result-error h4 {
    font-size: 13px;
    color: #991b1b;
    margin-bottom: 8px;
}
.result-error pre {
    background: #fff;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12.5px;
    line-height: 1.6;
    color: #7f1d1d;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 测试点列表 */
.tc-list { margin-bottom: 16px; }
.tc-list > h4 {
    font-size: 13.5px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}
.tc-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}
.tc-item.st-ac-border  { border-left: 4px solid var(--ac); }
.tc-item.st-wa-border  { border-left: 4px solid var(--wa); }
.tc-item.st-tle-border { border-left: 4px solid var(--tle); }
.tc-item.st-mle-border { border-left: 4px solid var(--mle); }
.tc-item.st-re-border  { border-left: 4px solid var(--re); }
.tc-item.st-ce-border  { border-left: 4px solid var(--ce); }
.tc-item.st-pe-border  { border-left: 4px solid var(--pe); }
.tc-item.st-se-border  { border-left: 4px solid var(--se); }

.tc-head {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background: #fafbfc;
    border-bottom: 1px solid transparent;
    transition: background 0.12s;
}
.tc-head:hover { background: #f3f4f6; }
.tc-num {
    font-size: 12.5px;
    font-weight: 700;
    color: #374151;
    min-width: 30px;
}
.tc-sample {
    background: var(--sample-bg);
    color: #854d0e;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
}
.tc-status {
    flex: 1;
    font-size: 12.5px;
    font-weight: 700;
}
.tc-status.st-ac  { color: var(--ac); }
.tc-status.st-wa  { color: var(--wa); }
.tc-status.st-tle { color: var(--tle); }
.tc-status.st-mle { color: var(--mle); }
.tc-status.st-re  { color: var(--re); }
.tc-status.st-ce  { color: var(--ce); }
.tc-status.st-pe  { color: var(--pe); }
.tc-status.st-se  { color: var(--se); }
.tc-meta {
    font-size: 12px;
    color: var(--text-sub);
    font-weight: 600;
}
.tc-toggle {
    color: #9ca3af;
    font-size: 12px;
    transform-origin: center;
    transition: transform 0.15s;
}

.tc-body {
    padding: 10px 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    border-top: 1px dashed var(--border);
    background: #fff;
}
@media (max-width: 900px) { .tc-body { grid-template-columns: 1fr; } }
.tc-io-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-sub);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tc-io pre {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-all;
    color: #374151;
    max-height: 160px;
    overflow: auto;
}
.io-actual { background: #eff6ff !important; border-color: #bfdbfe !important; }
.io-err {
    background: #fef2f2 !important;
    border-color: #fecaca !important;
    color: #991b1b !important;
}

/* 代码预览框 */
.result-code-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.rcb-header {
    padding: 8px 12px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}
.btn-copy {
    background: #fff;
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    color: #374151;
    font-weight: 600;
}
.btn-copy:hover { background: #f3f4f6; }
.result-code-box pre {
    background: #0b1020;
    color: #e5e7eb;
    padding: 12px 14px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.65;
    max-height: 260px;
}

/* ---------- Loading ---------- */
.loading-mask {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.loading-box {
    background: #fff;
    border-radius: 14px;
    padding: 32px 40px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    animation: popIn 0.2s ease-out;
}
@keyframes popIn {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.spinner {
    width: 46px;
    height: 46px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 6px;
}
.loading-sub {
    font-size: 12.5px;
    color: var(--text-sub);
}
