/* 商户门户（MVC + Ant Design v4 CSS）布局与自定义样式 */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: rgba(0, 0, 0, .85);
}

/* ---------- 整体布局 ---------- */
.portal-layout { min-height: 100vh; }

.portal-sider {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    background: #001529;
    overflow-y: auto;
    z-index: 20;
    transition: transform .25s ease;
}

.portal-logo {
    height: 56px;
    line-height: 56px;
    padding: 0 16px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
}

.portal-menu.ant-menu-dark { background: transparent; border-inline-end: none !important; }
.portal-menu .ant-menu-item { padding: 0 20px !important; }
.portal-menu .ant-menu-item a { display: inline-flex; align-items: center; gap: 10px; }

.portal-main {
    margin-left: 220px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.portal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}

.portal-header-title { font-weight: 600; }

.portal-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
}

/* ---------- 语言下拉 ---------- */
.portal-lang-dropdown { position: relative; }
.portal-lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 8px;
    color: #666;
}
.portal-lang-btn:hover { color: #1890ff; background: #f5f5f5; }
.portal-lang-caret { font-size: 12px; }
.portal-lang-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 140px;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 3px 6px -4px rgba(0, 0, 0, .12), 0 6px 16px 0 rgba(0, 0, 0, .08), 0 9px 28px 8px rgba(0, 0, 0, .05);
    z-index: 30;
}
.portal-lang-option {
    padding: 6px 12px;
    font-size: 14px;
    color: rgba(0, 0, 0, .85);
    cursor: pointer;
    white-space: nowrap;
}
.portal-lang-option:hover { background: #f5f5f5; }
.portal-lang-option.is-selected { color: #1890ff; font-weight: 600; background: #e6f7ff; }

.portal-account { color: #666; }

.portal-burger {
    display: none;
    border: none;
    background: transparent;
    font-size: 16px;
    cursor: pointer;
    color: rgba(0, 0, 0, .85);
}

.portal-content { padding: 16px; flex: 1; }

/* ---------- 列表页：内容区内部滚动（横向 + 纵向），不使用页面滚动条 ---------- */
body.portal-fixed-body { overflow: hidden; }
body.portal-fixed-body .portal-layout { height: 100vh; overflow: hidden; }
body.portal-fixed-body .portal-main { height: 100vh; min-height: 0; overflow: hidden; }
body.portal-fixed-body .portal-content {
    height: calc(100vh - 56px);
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
body.portal-fixed-body .portal-content > .ant-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.portal-fixed-body .portal-content > .ant-card > .ant-card-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.portal-fixed-body .portal-filter { flex: none; }
body.portal-fixed-body .portal-pager { flex: none; }

.portal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 15;
    display: none;
}

/* ---------- 卡片与表格 ---------- */
.ant-card { background: #fff; border-radius: 4px; }
.ant-card-head { border-bottom: 1px solid #f0f0f0; padding: 0 16px; min-height: 48px; display: flex; align-items: center; }
.ant-card-head-title { font-weight: 600; }
.ant-card-body { padding: 16px; }

.portal-section-title { margin: 20px 0 8px; font-size: 15px; font-weight: 600; }

.portal-table,
.portal-kv { width: 100%; border-collapse: collapse; font-size: 13px; }

.portal-table th,
.portal-table td,
.portal-kv td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    vertical-align: top;
}

.portal-table thead th { background: #fafafa; font-weight: 600; white-space: nowrap; }
.portal-table tbody tr:hover { background: #fafafa; }
.portal-kv .portal-kv-key { width: 220px; background: #fafafa; }

/* 表格容器：横向 + 纵向滚动，表头固定 */
.portal-table-wrap {
    overflow: auto;
    max-height: 70vh;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
}
.portal-table-wrap .portal-table { min-width: 1000px; }
.portal-table-wrap .portal-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
}
body.portal-fixed-body .portal-table-wrap { flex: 1; min-height: 0; max-height: none; }

.portal-empty { text-align: center; color: #999; padding: 24px !important; }
.portal-break { word-break: break-all; }
.portal-actions { white-space: nowrap; }

/* ---------- 筛选区 ---------- */
.portal-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.portal-filter-item { display: flex; flex-direction: column; gap: 4px; }
.portal-filter-item > label { font-size: 12px; color: #666; }
.portal-filter-item .ant-input,
.portal-filter-item select.ant-select { min-width: 170px; }
.portal-filter-actions { display: flex; gap: 8px; align-items: flex-end; margin-left: auto; flex-wrap: wrap; }

/* ---------- 日期范围选择器 ---------- */
.portal-daterange { position: relative; display: inline-flex; align-items: center; }
.portal-daterange .portal-range-input {
    min-width: 260px;
    padding-right: 30px;
    cursor: pointer;
    background: #fff;
}
.portal-daterange .portal-range-icon {
    position: absolute;
    right: 10px;
    color: #bfbfbf;
    pointer-events: none;
}
.flatpickr-calendar { z-index: 2000; }
.flatpickr-calendar.open { font-size: 13px; }

/* ---------- 原生表单控件（Ant 风格） ---------- */
input.ant-input,
select.ant-select,
textarea.ant-input {
    height: 32px;
    padding: 4px 11px;
    font-size: 14px;
    line-height: 1.5715;
    color: rgba(0, 0, 0, .85);
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    outline: none;
    transition: border-color .3s;
}

input.ant-input:focus,
select.ant-select:focus { border-color: #40a9ff; box-shadow: 0 0 0 2px rgba(24, 144, 255, .2); }
input.ant-input:disabled,
input.ant-input.portal-input-readonly { background: #f5f5f5; color: rgba(0, 0, 0, .45); }

select.ant-select { min-width: 120px; }

.portal-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.portal-field > label { font-size: 13px; color: #333; }
.portal-btn-block { width: 100%; }

.portal-hint { font-size: 12px; color: #999; margin-top: 4px; }
.portal-muted { color: #999; }
.portal-alert { margin-bottom: 12px; }
.portal-hidden { display: none !important; }
.portal-checkbox { display: inline-flex; align-items: center; gap: 6px; font-weight: 400 !important; }

/* ---------- 分页 ---------- */
.portal-pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.portal-pager-controls { display: flex; align-items: center; gap: 8px; }
.portal-pager-info { color: #666; }
.portal-page-size { min-width: 70px !important; height: 28px !important; }

/* ---------- 登录页 ---------- */
.portal-login-body { background: #f0f2f5; }
.portal-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.portal-login-card { width: 380px; max-width: 100%; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }

/* ---------- 弹窗 / 抽屉 ---------- */
.portal-modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.portal-modal {
    width: 480px;
    max-width: 96vw;
    max-height: 90vh;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
    display: flex;
    flex-direction: column;
}

.portal-modal-head,
.portal-drawer-head {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.portal-modal-body { padding: 16px; overflow-y: auto; }

.portal-modal-foot {
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.portal-modal-close {
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #999;
}

.portal-drawer-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
}

.portal-drawer {
    width: 720px;
    max-width: 96vw;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.portal-drawer-body { padding: 16px; overflow-y: auto; }
.portal-drawer-body pre {
    background: #f5f5f5;
    padding: 8px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 320px;
    overflow: auto;
}
.portal-drawer-body pre.portal-error-block { background: #fff2f0; }

/* ---------- API 文档 ---------- */
.portal-docs { display: flex; gap: 16px; align-items: flex-start; }
.portal-docs-nav {
    width: 250px;
    flex: none;
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 88px);
    overflow: auto;
}
.portal-docs-nav .ant-card-body { padding: 8px; }
.portal-docs-menu { list-style: none; margin: 0; padding: 0; }
.portal-docs-group { margin: 12px 0 4px; padding: 0 12px; font-size: 12px; color: #999; }
.portal-docs-link {
    display: block;
    padding: 7px 12px;
    border-radius: 4px;
    font-size: 13px;
    color: rgba(0, 0, 0, .75);
    cursor: pointer;
}
.portal-docs-link:hover { background: #f5f5f5; color: #1890ff; }
.portal-docs-link.is-active { background: #e6f7ff; color: #1890ff; font-weight: 600; }
.portal-docs-body { flex: 1; min-width: 0; }
.portal-first-title { margin-top: 0; }

.portal-endpoint-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.portal-endpoint-desc { margin: 0 0 12px; color: #666; line-height: 1.7; }
.portal-endpoint-label { font-weight: 600; margin: 12px 0 6px; }
.portal-code {
    background: #f5f5f5;
    padding: 8px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}
.portal-rules { line-height: 1.9; padding-left: 20px; }

/* ---------- 多标签页（Tab）外壳 ---------- */
body.portal-tabs-body { overflow: hidden; }
body.portal-tabs-body .portal-layout { height: 100vh; overflow: hidden; }
body.portal-tabs-body .portal-main { height: 100vh; min-height: 0; overflow: hidden; }
body.portal-tabs-body .portal-header { position: static; flex: none; }

.portal-tabbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px 0;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    overflow-x: auto;
    overflow-y: hidden;
}

.portal-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    font-size: 13px;
    color: rgba(0, 0, 0, .65);
    background: #f5f5f5;
    border: 1px solid #f0f0f0;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.portal-tab:hover { color: #1890ff; }
.portal-tab.is-active { color: #1890ff; background: #fff; border-color: #d9d9d9; font-weight: 600; }

.portal-tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 10px;
    color: rgba(0, 0, 0, .45);
    border-radius: 50%;
}
.portal-tab-close:hover { background: #ff7875; color: #fff; }

.portal-tabcontent { position: relative; flex: 1; min-height: 0; background: #f0f2f5; }
.portal-tab-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: none; }
.portal-tab-frame.is-active { display: block; }
.portal-tab-fallback { display: none !important; }

/* ---------- iframe 内嵌模式（标签页内容） ---------- */
body.portal-embed-body.portal-fixed-body .portal-content { height: 100vh; }
body.portal-embed-body .portal-content { min-height: 100vh; }
body.portal-embed-body .portal-docs-nav { top: 16px; max-height: calc(100vh - 32px); }

/* ---------- 响应式：窄屏折叠侧栏 ---------- */
@media (max-width: 992px) {
    .portal-sider { transform: translateX(-100%); }
    .portal-sider.is-open { transform: translateX(0); }
    .portal-main { margin-left: 0; }
    .portal-burger { display: inline-flex; }
    .portal-mask.is-open { display: block; }
    .portal-header-right { gap: 10px; }
    .portal-account { display: none; }
    .portal-filter-actions { margin-left: 0; width: 100%; }
    .portal-daterange,
    .portal-daterange .portal-range-input { width: 100%; min-width: 0; }
    .portal-docs { flex-direction: column; }
    .portal-docs-nav { position: static; width: 100%; max-height: none; }
}
