/* MCP 管理后台：保留必要的信息层级与表单反馈。 */
:root {
    --primary-color: #176b66;
    --primary-hover: #10544f;
    --secondary-color: #176b66;
    --bg-color: #f5f7f6;
    --sidebar-bg: #1e3034;
    --text-main: #243638;
    --text-muted: #687b7b;
    --border-color: #dce5e1;
    --card-shadow: none;
    --hover-shadow: none;
    --site-footer-height: 36px;
}

body { font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: .875rem; background: var(--bg-color); padding-bottom: var(--site-footer-height); }
.navbar { height: 56px; min-height: 56px; padding: .5rem 1.25rem !important; border-bottom: 1px solid var(--border-color); box-shadow: none !important; }
.navbar-brand { color: #20383a !important; font-size: 1.08rem; font-weight: 700; }
.navbar-brand:hover { color: #176b66 !important; }
.sidebar { padding: 56px 0 0; bottom: var(--site-footer-height); box-shadow: none; border-right: 1px solid #2a4245; }
.sidebar-sticky { height: calc(100dvh - 56px - var(--site-footer-height)); padding: .65rem 0; }
.sidebar .nav-link { display: flex; align-items: center; gap: .45rem; color: #c8d6d4; margin: .1rem .7rem; padding: .7rem .9rem; border-radius: 7px; font-size: .9rem; font-weight: 500; }
.sidebar .nav-link i { width: 20px; margin: 0; font-size: 1rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; transform: none; }
.sidebar .nav-link.active { background: #e7f3ed; color: #125b55; box-shadow: none; font-weight: 700; }

.main-content { margin-top: 0; padding: 1rem 1.4rem !important; }
.main-content > .d-flex:first-child { flex-shrink: 0; border-color: var(--border-color) !important; padding-bottom: .7rem !important; margin-bottom: .8rem !important; gap: .75rem; }
.page-title { color: #21383a; font-size: 1.4rem; font-weight: 700; letter-spacing: -.025em; }
.card { border: 1px solid var(--border-color); border-radius: 10px; box-shadow: none; transition: none; overflow: hidden; margin-bottom: 0; }
.card:hover { box-shadow: none; }
.card-header, .card-footer { background: #fff !important; border-color: var(--border-color); }
.card-header { color: #314648; font-size: .9rem; padding: .75rem 1rem; flex-shrink: 0; }
.card-header h5 { font-size: 1rem; }
.card-body { padding: 1rem; }
.form-label { color: #435b5c; font-size: .8rem; font-weight: 600; margin-bottom: .35rem; }
.form-control, .form-select { border-color: #cedbd5; border-radius: 7px; color: #263b3c; font-size: .85rem; }
.form-text { font-size: .74rem; }
.form-control[readonly], .form-control:disabled, .form-select:disabled { background: #edf0f2; color: #7a858e; border-color: #dde2e6; box-shadow: none; }
.form-control[readonly] { pointer-events: none; caret-color: transparent; }
.form-control:focus, .form-select:focus { border-color: #2f8178; box-shadow: 0 0 0 .18rem rgba(29, 117, 106, .12); }
.btn { border-radius: 7px; font-size: .85rem; font-weight: 600; box-shadow: none !important; }
.btn-sm { font-size: .8rem; }
.btn-primary, .btn-primary:focus { background: #176b66; border-color: #176b66; }
.btn-primary:hover, .btn-primary:active { background: #10544f !important; border-color: #10544f !important; transform: none; }
.btn-outline-primary, .btn-outline-success, .btn-outline-info { border-color: #a9c8bf; color: #176b66; }
.btn-outline-primary:hover, .btn-outline-success:hover, .btn-outline-info:hover { background: #e9f4ef; border-color: #78aa9b; color: #10544f; }
.btn-light { background: #f1f5f2; border-color: #e3ebe5; color: #405554; }
.table thead th, .table th { background: #f6f8f6 !important; border-bottom-color: var(--border-color); color: #637577; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.table td { border-bottom-color: #edf1ee; color: #263a3d; font-size: .82rem; overflow-wrap: anywhere; }
.table th, .table td { padding: .6rem .75rem; }
.table { margin-bottom: 0; }
.table-hover tbody tr:hover { background: #f5faf7; }
.badge { border-radius: 5px; font-weight: 600; }
code { background: #edf4f0; color: #176b66; }
.site-footer { position: fixed; right: 0; bottom: 0; left: 0; z-index: 1030; display: flex; align-items: center; justify-content: center; height: var(--site-footer-height); padding: 0 1rem; border-top: 1px solid var(--border-color); background: #fff; font-size: .75rem; }
.site-footer a { color: #536765; text-decoration: none; }
.site-footer a:hover { color: var(--primary-color); text-decoration: underline; }
.site-footer a:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 3px; border-radius: 2px; }
.toast-container { bottom: var(--site-footer-height) !important; }
.modal-content { border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 20px 50px rgba(18, 44, 43, .13); }
.modal-header, .modal-footer { border-color: var(--border-color); }
.modal-content { max-height: calc(100dvh - 3.5rem); }
.modal-body { overflow-y: auto; min-height: 0; }
.pagination .page-link { color: #176b66; border-color: var(--border-color); }
.pagination .active .page-link { background: #176b66; border-color: #176b66; }

.dashboard-heading { margin-bottom: 1.2rem; }
.dashboard-heading p { margin: .25rem 0 0; color: #728381; font-size: .9rem; }
.service-status { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: 1rem 1.2rem; background: #fff; border: 1px solid var(--border-color); border-radius: 10px; margin-bottom: 1rem; font-size: .86rem; }
.service-status-label { color: #687a79; font-weight: 600; }
.service-status strong { color: #435557; }
.service-status strong.is-ready { color: #167658; }
.service-status strong.is-error { color: #bd563e; }
.service-status > span:nth-of-type(2) { color: #7d8d89; }
.service-status code { margin-left: auto; overflow-wrap: anywhere; }
.metric-card { display: flex; justify-content: space-between; align-items: center; min-height: 98px; padding: 1.2rem; background: #fff; border: 1px solid var(--border-color); border-radius: 10px; }
.metric-card span { color: #5a6f70; font-size: .87rem; font-weight: 600; }
.metric-card strong { color: #233c3e; font-size: 1.75rem; line-height: 1; font-weight: 700; }

/* 测试页：配置与结果等高，长内容在各自卡片内部滚动。 */
.gateway-test-main { --bs-gutter-x: 1.2rem; align-items: stretch; }
.gateway-test-main > div { min-width: 0; }
.gateway-test-main .card-header { min-height: 52px; display: flex; align-items: center; }
.gateway-test-main .card-header .btn-sm { padding: .25rem .5rem; }
.gateway-chat-card { display: flex; flex-direction: column; height: clamp(360px, 60dvh, 620px); }
.gateway-chat-body { flex: 1 1 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; background: #f8fafc; }
#chat-window { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-wrap: anywhere; scrollbar-gutter: stable; overscroll-behavior-y: contain; }
.gateway-test-config .card-body { min-height: 0; overflow-y: auto; }
.gateway-test-config .mb-3 { margin-bottom: .6rem !important; }
.gateway-test-config .form-text { margin-top: .2rem; }
.tool-guide-item + .tool-guide-item { border-top: 1px solid var(--border-color); margin-top: 1rem; padding-top: 1rem; }
.tool-guide-item h6 { margin: 0; color: var(--text-main); font-size: .9rem; font-weight: 700; overflow-wrap: anywhere; }
.tool-guide-item p { margin: .4rem 0 0; color: var(--text-muted); font-size: .85rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.tool-input-example { display: flex; align-items: flex-start; gap: .8rem; margin-top: .65rem; padding: .7rem .8rem; background: #f4f8f7; border: 1px solid var(--border-color); border-radius: 6px; }
.tool-input-example-content { flex: 1; min-width: 0; }
.tool-input-example-label { color: var(--text-muted); font-size: .75rem; }
.tool-guide-item .tool-input-example-text { margin-top: .2rem; color: var(--text-main); font-size: .85rem; }
.btn-copy-tool-input { flex-shrink: 0; min-width: 4.5rem; }

@media (min-width: 768px) {
    body { height: 100dvh; overflow: hidden; }
    .main-content { height: calc(100dvh - 56px - var(--site-footer-height)); min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
    .main-content > .card.mb-4 { flex-shrink: 0; margin-bottom: .8rem !important; }
    .main-content > .card:not(.mb-4) { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
    .main-content > .card:not(.mb-4) > .card-body { flex: 1 1 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
    .main-content > .card .table-responsive { flex: 1; min-height: 0; overflow: auto; }
    .main-content > .card .table thead th { position: sticky; top: 0; z-index: 1; }
    .main-content > .card > .card-footer { flex-shrink: 0; padding: .65rem 1rem !important; }
}

@media (min-width: 992px) {
    .gateway-test-main { flex: 1 1 0; min-height: 0; }
    .gateway-test-main > div { height: 100%; min-height: 0; display: flex; flex-direction: column; margin-bottom: 0 !important; }
    .gateway-test-main .card { height: 100%; min-height: 0; display: flex; flex-direction: column; }
    .gateway-test-config .card-body { display: flex; flex: 1 1 0; }
    #form-gateway-llm-test { flex: 1; min-height: min-content; display: flex; flex-direction: column; }
    .gateway-test-message { flex: 1; min-height: 100px; display: flex; flex-direction: column; }
    #test-message { flex: 1 1 0; min-height: 70px; resize: none; }
}

@media (max-width: 767px) {
    .navbar { height: 56px; min-height: 56px; }
    .sidebar { position: static; padding: 0; border-right: 0; }
    .sidebar-sticky { height: auto; padding: .5rem 0; }
    .main-content { margin-top: 0; padding: 1rem !important; }
    .service-status code { flex-basis: 100%; margin-left: 0; }
}

/* 短屏给备案页脚预留空间，同时保持测试按钮完整可见。 */
@media (min-width: 992px) and (max-height: 800px) {
    .gateway-test-main .card-header { min-height: 44px; padding-top: .5rem; padding-bottom: .5rem; }
    .gateway-test-config .card-body { padding-top: .75rem; padding-bottom: .75rem; }
    .gateway-test-config .mb-3 { margin-bottom: .4rem !important; }
    .gateway-test-message { min-height: 88px; }
    #test-message { min-height: 60px; }
}
