/* ═══════════════════════════════════════════
   IL Training Agent — Custom Styles
   Institutional palette: one deep blue, no gradients
   ═══════════════════════════════════════════ */

:root {
    --il-primary: #1e3a5f;
    --il-primary-dark: #152a45;
    --il-border: #d8dee6;
    --il-text: #1f2937;
    --il-muted: #5b6b7f;
    --il-bg: #f4f6f8;

    /* Bootstrap 5.3 reads these, so .text-primary/.bg-primary/.border-primary
       follow the institutional blue without per-utility overrides. */
    --bs-primary: #1e3a5f;
    --bs-primary-rgb: 30, 58, 95;
    --bs-primary-text-emphasis: #152a45;
    --bs-primary-bg-subtle: #e8eef5;
    --bs-primary-border-subtle: #c3d3e4;
    --bs-link-color: #1e3a5f;
    --bs-link-color-rgb: 30, 58, 95;
    --bs-link-hover-color: #152a45;
    --bs-link-hover-color-rgb: 21, 42, 69;
}

/* ── Global ── */
body {
    background-color: var(--il-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
}

/* ── Navbar ── */
.navbar {
    background-color: var(--il-primary) !important;
    border-bottom: 1px solid var(--il-primary-dark);
}

/* ── Cards ── */
.card {
    border-radius: 0.375rem;
    border-color: var(--il-border);
    transition: border-color 0.15s ease;
}
.card:hover {
    border-color: #b9c5d4;
}

/* ── Buttons ──
   Bootstrap 5.3 defines .btn-primary with a literal #0d6efd rather than a
   variable, so overriding :root is not enough — every state has to be set,
   including the active/disabled ones the previous version missed. */
.btn-primary {
    --bs-btn-bg: var(--il-primary);
    --bs-btn-border-color: var(--il-primary);
    --bs-btn-hover-bg: var(--il-primary-dark);
    --bs-btn-hover-border-color: var(--il-primary-dark);
    --bs-btn-active-bg: var(--il-primary-dark);
    --bs-btn-active-border-color: var(--il-primary-dark);
    --bs-btn-disabled-bg: #7f8fa3;
    --bs-btn-disabled-border-color: #7f8fa3;
    --bs-btn-focus-shadow-rgb: 30, 58, 95;
}
.btn-outline-primary {
    --bs-btn-color: var(--il-primary);
    --bs-btn-border-color: var(--il-primary);
    --bs-btn-hover-bg: var(--il-primary);
    --bs-btn-hover-border-color: var(--il-primary);
    --bs-btn-active-bg: var(--il-primary-dark);
    --bs-btn-active-border-color: var(--il-primary-dark);
    --bs-btn-focus-shadow-rgb: 30, 58, 95;
}
.btn-link {
    --bs-btn-color: var(--il-primary);
    --bs-btn-hover-color: var(--il-primary-dark);
    --bs-btn-active-color: var(--il-primary-dark);
}

/* ── Progress bars ── */
.progress-bar-striped {
    background-image: linear-gradient(45deg,
        rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%,
        rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
}

/* ── Chat messages ── */
#chatMessages {
    scroll-behavior: smooth;
}
#chatMessages .rounded-4 {
    word-break: break-word;
    white-space: pre-wrap;
}

/* ── Quiz answer options ── */
.form-check.border.rounded {
    cursor: pointer;
    transition: all 0.15s ease;
}
.form-check.border.rounded:hover {
    background-color: #f0f7ff;
    border-color: var(--il-primary) !important;
}

/* ── Certificate ── */
#certificate-card {
    background: white;
}
@media print {
    nav, footer, .no-print, .navbar, .btn {
        display: none !important;
    }
    body { background: white; }
    #certificate-card, .il-cert-frame {
        box-shadow: none !important;
        border: none !important;
        page-break-inside: avoid;
    }
}

/* ── Dashboard ── */
.sticky-top {
    z-index: 100;
}

/* ── 结果页图标（替代原 display-1 emoji） ── */
.il-result-icon {
    font-size: 2.75rem;
    line-height: 1;
}
.il-loading-icon {
    font-size: 3.5rem;
    line-height: 1;
    color: var(--il-primary);
}

/* ── HTMX indicators ── */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .display-4 { font-size: 2rem; }
    .card-body { padding: 1rem !important; }
}

/* ── Loading skeleton ── */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
    height: 1rem;
}

/* ── AI sidebar scrollbar ── */
#aiSidebar::-webkit-scrollbar {
    width: 4px;
}
#aiSidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

/* ── AI 助教卡片标题栏的算力等待提示 ── */
.il-chat-hint {
    font-size: 0.7rem;
    line-height: 1.25;
    opacity: 0.85;
    margin-top: 0.15rem;
}

/* ═══════════════════════════════════════════
   机构官网风组件（首页 + 管理面板共用）
   作用域由「谁引用它」决定，未引用的页面不受影响
   ═══════════════════════════════════════════ */

/* ── 页面标题栏 ── */
.il-page-header {
    background-color: var(--il-primary);
    color: #fff;
    padding: 2rem 0 1.75rem;
}
.il-page-title {
    font-size: 1.6rem;
    font-weight: 600;
    margin: .3rem 0 .5rem;
}
.il-page-sub {
    color: rgba(255, 255, 255, .84);
    max-width: 58rem;
    font-size: .95rem;
    margin-bottom: .8rem;
}
.il-breadcrumb {
    --bs-breadcrumb-divider-color: rgba(255, 255, 255, .55);
    margin-bottom: .15rem;
    font-size: .82rem;
}
.il-breadcrumb a {
    color: rgba(255, 255, 255, .82);
    text-decoration: none;
}
.il-breadcrumb a:hover {
    color: #fff;
    text-decoration: underline;
}
.il-breadcrumb .active {
    color: rgba(255, 255, 255, .65);
}
.il-header-meta {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1.75rem;
    padding: 0;
    margin: 0;
    font-size: .85rem;
    color: rgba(255, 255, 255, .8);
}
.il-header-meta strong {
    color: #fff;
    font-weight: 600;
}

/* ── 服务入口条 ── */
.il-quicklinks {
    background: #fff;
    border-bottom: 1px solid var(--il-border);
}
.il-quicklinks-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1.75rem;
    margin: 0;
    padding: .6rem 0;
}
.il-quicklinks-list a {
    color: var(--il-primary);
    font-size: .9rem;
    text-decoration: none;
}
.il-quicklinks-list a:hover {
    text-decoration: underline;
}
.il-quicklinks-list i {
    margin-right: .3rem;
}

/* ── 内容分区 ── */
.il-section {
    padding: 2.25rem 0;
}
.il-section-bordered {
    border-top: 1px solid var(--il-border);
}
.il-section-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--il-text);
    margin-bottom: .35rem;
}
.il-section-hint {
    color: var(--il-muted);
    font-size: .88rem;
    margin-bottom: 1rem;
}

/* ── 服务说明分栏 ── */
.il-service-col {
    border-top: 2px solid var(--il-primary);
    padding-top: .85rem;
}
.il-service-head {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: .6rem;
}
.il-service-head i {
    color: var(--il-primary);
    margin-right: .4rem;
}
.il-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.il-list li {
    position: relative;
    padding-left: 1rem;
    margin-bottom: .45rem;
    font-size: .9rem;
    color: var(--il-muted);
}
.il-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: .55em;
    width: 4px;
    height: 4px;
    background: var(--il-primary);
    border-radius: 50%;
}

/* ── 服务流程（序号由 CSS 计数器生成） ── */
.il-steps {
    counter-reset: il-step;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    padding: 0;
    margin: 0;
}
.il-steps > li {
    counter-increment: il-step;
    border-top: 2px solid var(--il-primary);
    padding-top: .7rem;
}
.il-steps > li::before {
    content: counter(il-step);
    display: block;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .08em;
    color: var(--il-primary);
    margin-bottom: .2rem;
}
.il-steps h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .3rem;
}
.il-steps p {
    font-size: .88rem;
    color: var(--il-muted);
    margin: 0;
}
@media (max-width: 768px) {
    .il-steps { grid-template-columns: repeat(2, 1fr); }
}

/* ── 表格 ── */
.il-table {
    font-size: .9rem;
}
.il-table > thead > tr > th {
    font-size: .82rem;
    font-weight: 600;
    color: var(--il-muted);
    border-bottom: 1px solid var(--il-border);
    white-space: nowrap;
}
.il-table > tbody > tr > td {
    border-color: #e8ecf1;
}
.il-muted {
    color: var(--il-muted);
}
.il-strong {
    font-weight: 600;
}
.il-link-plain {
    color: inherit;
    text-decoration: none;
}
.il-link-plain:hover {
    color: var(--il-primary);
    text-decoration: underline;
}

/* ── 管理面板二级导航 ── */
.il-subnav {
    background: #fff;
    border-bottom: 1px solid var(--il-border);
    padding: .5rem 0;
}
.il-subnav-pills .nav-link {
    color: var(--il-muted);
    font-size: .9rem;
    padding: .35rem .8rem;
    border-radius: .25rem;
}
.il-subnav-pills .nav-link:hover {
    background: var(--bs-primary-bg-subtle);
    color: var(--il-primary);
}
.il-subnav-pills .nav-link.active {
    background: var(--il-primary);
    color: #fff;
}

/* ── 指标卡 ── */
.il-kpi-value {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--il-primary);
    display: block;
}
.il-kpi-label {
    font-size: .8rem;
    color: var(--il-muted);
    margin-top: .3rem;
}

/* ── 图表容器 ── */
.il-chart {
    position: relative;
    height: 260px;
}
.il-chart-wide {
    height: 320px;
}

/* ── 列表内联微调 ── */
.il-pagination {
    border-top: 1px solid var(--il-border);
    padding-top: .75rem;
    margin-top: .75rem;
}
.il-pagination .page-link {
    color: var(--il-primary);
}
.il-details-toggle {
    cursor: pointer;
}
.il-move {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.il-move form {
    margin: 0;
    line-height: 1;
}
.il-move .btn {
    font-size: .7rem;
    line-height: 1;
    padding: .1rem .35rem;
}

/* ── 证书预览（保留金色语义，压平渐变）── */
.il-cert-frame {
    max-width: 380px;
    background: #fbf7ea;
    border: 3px double #c9a84c;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
    position: relative;
    font-family: Georgia, "Songti SC", "SimSun", serif;
}
.il-cert-seal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    width: 90px;
    height: 90px;
    border: 3px solid rgba(201, 168, 76, .3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.il-cert-seal span {
    color: rgba(201, 168, 76, .45);
    font-weight: bold;
    font-size: .7rem;
}
.il-cert-inner {
    position: relative;
    z-index: 1;
}
.il-cert-kicker {
    color: #8b6914;
    font-size: .7rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.il-cert-title {
    color: #5a3e00;
    font-size: 1.1rem;
    margin-bottom: 6px;
}
.il-cert-rule {
    width: 60px;
    height: 2px;
    background: #c9a84c;
    margin: 8px auto;
}
.il-cert-line {
    color: #6b4f10;
    font-size: .75rem;
    margin: 6px 0;
}
.il-cert-subject {
    color: #8b6914;
    font-weight: bold;
    font-size: .8rem;
    margin: 4px 0;
}
.il-cert-meta {
    margin-top: 8px;
    font-size: .65rem;
    color: #8b6914;
    display: flex;
    justify-content: center;
    gap: 1rem;
}
.il-cert-foot {
    margin-top: 8px;
    font-size: .6rem;
    color: #a08040;
    font-style: italic;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.il-cert-note {
    font-size: .78rem;
    color: var(--il-muted);
    margin: .6rem 0 0;
    max-width: 380px;
}

/* ── 正式证书页（放大版，与预览同构、居中展示） ── */
.il-cert-issued {
    max-width: 680px;
    margin: 0 auto;
    padding: 44px 48px;
}
.il-cert-issued .il-cert-kicker { font-size: .8rem; }
.il-cert-issued .il-cert-title { font-size: 1.7rem; margin-bottom: 10px; }
.il-cert-issued .il-cert-rule { width: 90px; margin: 12px auto; }
.il-cert-issued .il-cert-line { font-size: 1rem; margin: 10px 0; }
.il-cert-issued .il-cert-subject { font-size: 1.15rem; }
.il-cert-issued .il-cert-meta { font-size: .85rem; gap: 1.5rem; }
.il-cert-issued .il-cert-foot { font-size: .78rem; gap: .25rem; }
.il-cert-issued .il-cert-seal { width: 130px; height: 130px; }
.il-cert-issued .il-cert-seal span { font-size: .9rem; }
.il-cert-name {
    color: #5a3e00;
    font-size: 1.5rem;
    font-weight: bold;
    margin: .5rem 0;
    letter-spacing: .08em;
}

/* ── 登录页测试账号说明（评审需用它登录三种角色，故保留账号本身） ── */
.il-demo-accounts {
    border-left: 3px solid var(--il-primary);
    background: #f7f9fb;
    padding: .6rem .8rem;
    font-size: .85rem;
}
.il-demo-title {
    font-weight: 600;
    margin-bottom: .35rem;
}
.il-demo-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .2rem .6rem;
    margin: 0;
}
.il-demo-list dt {
    font-weight: 500;
    color: var(--il-muted);
}
.il-demo-list dd {
    margin: 0;
}

/* Alpine 初始化前隐藏 x-cloak 元素，避免遮罩/弹层首帧闪现 */
[x-cloak] {
    display: none !important;
}
