/* ============================================================
   提交记录弹窗（测评结果 / 源码 / 编译错误）
   ------------------------------------------------------------
   为什么单独拆一个文件：
   views/solution/result.php 与 source.php 是 layout=false 的片段，
   由 #solution-info 弹窗通过 ajax 注入。它们不只出现在记录页 ——
   比赛题目页(contest/problem.php)、比赛状态页(contest/status.php)、
   用户组页(group/view.php) 也复用同一套片段。
   如果样式全写在 record.css 里，那些页面不加载 record.css，
   弹窗就会裸奔成无样式文本。所以这里把弹窗样式独立成文件，
   由片段自己带 <link> 进来，任何宿主页都能正确渲染。

   变量全部来自 theme.css，全站可用；规则限定在 .rec-dlg 与
   #solution-info 内，不会影响比赛页原有的弹窗骨架以外的区域。
   ============================================================ */

/* ---------------------------------------------------------------- 状态胶囊 */
.rec-dlg .vd {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 2px 9px 2px 8px;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 18px;
    white-space: nowrap;
    border-radius: 3px;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.rec-dlg .vd-dot {
    flex: 0 0 auto;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

/* 等待类：灰蓝 + 呼吸点（与新闻页新条目同一种语言） */
.rec-dlg .vd-wait {
    color: #5B6B78;
    background: #EEF2F5;
}

.rec-dlg .vd-wait .vd-dot {
    position: relative;
    color: #5B6B78;
    animation: rec-dot-pulse 1.8s ease-in-out infinite;
}

@keyframes rec-dot-pulse {
    0%, 100% { opacity: 0.35; transform: scale(1); }
    50%      { opacity: 1;    transform: scale(1.35); }
}

/* 通过：绿 */
.rec-dlg .vd-ok {
    color: var(--ok, #2E6B3E);
    background: #EDF5EF;
}

/* 需注意（超时/超内存/格式/运行/编译错误）：琥珀 */
.rec-dlg .vd-warn {
    color: var(--warn, #A85B00);
    background: #FBF3E8;
}

/* 失败（答案错误/系统错误/无测试数据）：红 */
.rec-dlg .vd-err {
    color: var(--danger, #A32D2D);
    background: #FBEEEE;
}

/* ---------------------------------------------------------------- 弹窗 */
/* result.php / source.php 以 layout=false 返回片段，注入 #solution-content。
   这里只影响记录页弹出的窗口，比赛页弹窗结构不变 */
.rec-dlg {
    padding: 2px 2px 4px;
    font-size: 13px;
    color: var(--ink-2);
}

.rec-dlg .dlg-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.rec-dlg .dlg-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
}

.rec-dlg .dlg-title .rid {
    font-variant-numeric: tabular-nums;
    color: var(--brand);
    text-decoration: none;
}

.rec-dlg .dlg-meta {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.rec-dlg .dlg-meta .sep {
    margin: 0 6px;
    color: var(--line);
}

.rec-dlg .dlg-sub {
    margin: 0 0 10px;
    font-size: 12.5px;
    color: var(--ink-3);
}

/* 编译错误信息 */
.rec-dlg pre.ce {
    padding: 12px 14px;
    margin: 0;
    font-size: 12.5px;
    line-height: 1.8;
    color: #3B2B12;
    background: #FDF7EC;
    border: 1px solid #F0E2C8;
    border-left: 3px solid #D9A441;
    border-radius: 3px;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}

/* 测试点：app.js 输出的是 bootstrap panel 结构，这里在弹窗内重排成清爽列表 */
.rec-dlg .test-for-popup.panel {
    margin: 0 0 8px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 3px;
    box-shadow: none;
}

.rec-dlg .test-for-popup .panel-heading {
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 3px;
}

.rec-dlg .test-for-popup .panel-title {
    font-size: 12.5px;
    line-height: 1.6;
}

.rec-dlg .test-for-popup .panel-title > a {
    display: block;
    padding: 9px 12px;
    color: var(--ink-2);
    text-decoration: none;
}

.rec-dlg .test-for-popup .panel-title > a:hover {
    background: #FAFCFB;
    color: var(--ink);
}

.rec-dlg .test-for-popup .panel-body {
    padding: 10px 12px 4px;
    font-size: 12.5px;
    border-top: 1px solid var(--line-soft);
}

/* app.js 的 testHtml 给所有测试点都套 panel-default，只在内部文字上带
   text-success / text-danger，所以用 :has() 反向给外框加状态色条。
   不支持 :has 的浏览器只是没有这条竖线，不影响阅读 */
.rec-dlg .test-for-popup:has(.panel-heading .text-success) {
    border-left: 3px solid #7FB48C;
}

.rec-dlg .test-for-popup:has(.panel-heading .text-danger) {
    border-left: 3px solid #C07070;
}

.rec-dlg .test-for-popup:has(.panel-heading .text-warning) {
    border-left: 3px solid #D9A441;
}

.rec-dlg .test-for-popup:has(.panel-heading .text-muted) {
    border-left: 3px solid #C3CBD1;
}

.rec-dlg .test-for-popup.panel-success {
    border-left: 3px solid #7FB48C;
}

.rec-dlg .test-for-popup.panel-warning {
    border-left: 3px solid #D9A441;
}

/* 面板内的颜色来自 app.js 的 text-success / text-warning / text-danger，改成本站色阶 */
.rec-dlg .test-for-popup .text-success {
    color: var(--ok, #2E6B3E) !important;
}

.rec-dlg .test-for-popup .text-warning {
    color: var(--warn, #A85B00) !important;
}

.rec-dlg .test-for-popup .text-danger {
    color: var(--danger, #A32D2D) !important;
}

.rec-dlg .test-for-popup .text-muted {
    color: var(--muted) !important;
}

.rec-dlg .test-for-popup .test {
    display: inline-block;
    margin-left: 4px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* 测试点详情：输入 / 输出 / 答案
   site.css 里有一套老样式（.sample-test .input{border:1px solid #888} 等），
   会在每块外面套一圈深灰粗边框，这里整套覆盖掉 */
.rec-dlg .sample-test .input, .rec-dlg .sample-test .output {
    position: static;
    margin: 0 0 10px;
    border: 0;
}

.rec-dlg .sample-test .output {
    top: 0;
}

.rec-dlg .sample-test h4 {
    padding: 0;
    margin: 0 0 5px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.4px;
    text-transform: none;
    border-bottom: 0;
}

.rec-dlg .sample-test pre {
    padding: 9px 11px;
    margin: 0;
    font-size: 12px;
    line-height: 1.7;
    color: var(--ink-2);
    background: #FAFBFA;
    border: 1px solid var(--line);
    border-radius: 3px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 240px;
    overflow: auto;
}

/* 源码：hljs 用的是深色主题，底色必须深，否则浅底浅字看不见 */
.rec-dlg .src {
    margin: 0;
    padding: 0;
    background: #23241F;
    border: 1px solid #1B1C18;
    border-radius: 3px;
    overflow: hidden;
}

.rec-dlg .src p {
    margin: 0;
    padding: 14px 16px;
    font-size: 12.5px;
    line-height: 1.75;
    color: #F8F8F2;
    white-space: pre;
    overflow-x: auto;
}

/* 权限不足时的提示 */
.rec-dlg .deny {
    padding: 24px 16px;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    background: #FAFBFA;
    border: 1px dashed var(--line);
    border-radius: 3px;
}

/* ---------------------------------------------------------------- 弹窗外观 */
/* Modal 自带的白底圆角，这里收一下，跟卡片风格一致 */
#solution-info .modal-content {
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 8px 30px rgba(22, 32, 42, 0.12);
}

#solution-info .modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

#solution-info .modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}

#solution-info .modal-body {
    padding: 16px;
    max-height: 70vh;
    overflow-y: auto;
}

#solution-info .modal-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--line);
}

@media (max-width: 767px) {
#solution-info .modal-body {
        padding: 12px;
        max-height: 78vh;
    }
}

/* 尊重系统的减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
.rec-dlg .vd-wait .vd-dot {
        animation: none;
        opacity: 0.8;
    }
}
