/* @doc 组件层：全站统一 .tk-* 组件（四端共用；新增组件必须先登记到 08-UI与H5规范 §7.5）
   🔴 禁止页面内私造类；样式只允许使用 base.css 中的变量 */

/* ---------- 按钮 ---------- */
.tk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 var(--sp-4);
    border: 1px solid var(--c-line);
    border-radius: var(--r-btn);
    background: var(--c-card);
    color: var(--c-text);
    font-size: var(--fs-base);
    cursor: pointer;
}

.tk-btn:active {
    opacity: .94;
    transform: translateY(2px);
}

.tk-btn--primary {
    background: var(--c-brand);
    border-color: var(--c-brand);
    color: #fff;
    box-shadow: var(--shadow-brand);
}

.tk-btn--danger {
    background: var(--c-danger);
    border-color: var(--c-danger);
    color: #fff;
}

.tk-btn--ghost {
    background: transparent;
    color: var(--c-brand);
    border-color: var(--c-brand);
}

.tk-btn--block {
    display: flex;
    width: 100%;
}

.tk-btn--sm {
    min-height: 32px;
    padding: 0 var(--sp-3);
    font-size: var(--fs-sm);
}

.tk-btn.is-loading {
    opacity: .6;
    pointer-events: none;
}

/* ---------- 卡片 ---------- */
.tk-card {
    background: var(--c-card);
    border-radius: var(--r-card);
    padding: var(--sp-4);
    margin-bottom: var(--sp-3);
    box-shadow: var(--shadow-card);
}

.tk-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-2);
    font-weight: 600;
}

.tk-card__body {
    color: var(--c-text-sub);
    font-size: var(--fs-sm);
}

.tk-card__foot {
    margin-top: var(--sp-3);
    display: flex;
    gap: var(--sp-2);
    justify-content: flex-end;
}

.tk-card--disabled {
    opacity: .6;
}

/* ---------- 列表项 ---------- */
.tk-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--c-line);
}

.tk-item:last-child {
    border-bottom: 0;
}

.tk-item__main {
    flex: 1;
    min-width: 0;
}

.tk-item__sub {
    color: var(--c-text-weak);
    font-size: var(--fs-xs);
}

.tk-item__extra {
    color: var(--c-text-sub);
    font-size: var(--fs-sm);
    white-space: nowrap;
}

/* ---------- 状态标签 ---------- */
.tk-tag {
    display: inline-block;
    padding: 2px var(--sp-2);
    border-radius: var(--r-sm);
    font-size: var(--fs-xs);
    background: var(--c-brand-light);
    color: var(--c-brand-dark);
}

.tk-tag--success { background: #e8f7ee; color: var(--c-success); }
.tk-tag--warn { background: #fff6e6; color: var(--c-warn); }
.tk-tag--danger { background: #fdecec; color: var(--c-danger); }
.tk-tag--info { background: #eaf1ff; color: var(--c-info); }
.tk-tag--muted { background: #f1f2f4; color: var(--c-text-weak); }

/* ---------- 全站页头（四端共用，见 08-UI与H5规范 §7.5 / §11） ---------- */
.tk-header {
    padding: var(--sp-4);
    background: var(--c-card);
    border-bottom: 1px solid var(--c-line);
}

.tk-header__name {
    font-size: var(--fs-lg, 17px);
    font-weight: 700;
    color: var(--c-text);
    line-height: 1.3;
}

.tk-header__domain {
    margin-top: 2px;
    font-size: var(--fs-xs);
    color: var(--c-text-weak);
}

/* 紧凑变体：用于后台顶栏（56px）内，去掉内边距与底边，可换行显示两行 */
.tk-header--compact {
    padding: 0;
    background: none;
    border-bottom: none;
    white-space: normal;
}

.tk-header--compact .tk-header__name {
    font-size: var(--fs-sm);
    font-weight: 600;
}

.tk-header--compact .tk-header__domain {
    margin-top: 0;
    font-size: 11px;
}

/* ---------- 表单 ---------- */
.tk-field {
    margin-bottom: var(--sp-4);
}

.tk-field__label {
    display: block;
    margin-bottom: var(--sp-2);
    font-size: var(--fs-sm);
    color: var(--c-text-sub);
}

.tk-field__input {
    width: 100%;
    min-height: 52px;
    padding: 0 var(--sp-4);
    border: 1px solid var(--c-line);
    border-radius: var(--r-btn);
    background: var(--c-card);
    transition: border-color .24s ease, box-shadow .24s ease;
}

.tk-field__input:focus {
    outline: none;
    border-color: var(--c-brand);
    box-shadow: 0 0 0 4px var(--c-brand-ring);
}

/* 输入框下方的小字提示（如「卡片上的卡号」） */
.tk-field__tip {
    margin-top: var(--sp-1);
    font-size: var(--fs-xs);
    color: var(--c-text-weak);
}

.tk-field__error {
    margin-top: var(--sp-1);
    color: var(--c-danger);
    font-size: var(--fs-xs);
}

/* 复选框行：复选框 + 说明文字水平对齐
   替代此前「裸 <input type=checkbox> 包在 .tk-field__label 里」的写法
   （那种写法会产生 44px 输入框样式与勾选框混排、对不齐的问题） */
.tk-check {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 44px;
    font-size: var(--fs-sm);
    color: var(--c-text-sub);
    cursor: pointer;
}

.tk-check input[type="checkbox"] {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    accent-color: var(--c-brand);
    cursor: pointer;
}

/* ---------- 空状态 ---------- */
.tk-empty {
    padding: var(--sp-6) var(--sp-4);
    text-align: center;
    color: var(--c-text-weak);
}

.tk-empty__text {
    margin-bottom: var(--sp-4);
}

/* ---------- 统计数字卡 ---------- */
.tk-stat {
    background: var(--c-card);
    border-radius: var(--r-card);
    padding: var(--sp-4);
    text-align: center;
}

.tk-stat__num {
    font-size: 22px;
    font-weight: 700;
    color: var(--c-brand);
}

.tk-stat__label {
    font-size: var(--fs-xs);
    color: var(--c-text-weak);
}

/* ---------- 弹层 / Toast ---------- */
.tk-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: var(--z-mask);
}

.tk-sheet,
.tk-dialog {
    position: fixed;
    z-index: var(--z-sheet);
    background: var(--c-card);
    border-radius: var(--r-card);
}

.tk-dialog {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 320px;
    padding: var(--sp-5);
    text-align: center;
}

.tk-toast {
    position: fixed;
    left: 50%;
    top: 20%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, .8);
    color: #fff;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-btn);
    font-size: var(--fs-sm);
    z-index: var(--z-toast);
}

/* ---------- 通用工具类 ---------- */
.is-hidden {
    display: none !important;
}

/* ---------- 底部 Tab（四端共用；利用 .tk-page 的 flex 列布局自然贴底） ---------- */
.tk-tabbar {
    display: flex;
    margin-top: auto;
    background: var(--c-card);
    border-top: 1px solid var(--c-line);
    padding-bottom: env(safe-area-inset-bottom);
}

.tk-tabbar__item {
    flex: 1;
    text-align: center;
    padding: var(--sp-3) var(--sp-1);
    min-height: 44px;
    color: var(--c-text-sub);
    font-size: var(--fs-xs);
}

.tk-tabbar__item.is-active {
    color: var(--c-brand);
    font-weight: 600;
}

/* ---------- 左侧/右侧抽屉（筛选） ---------- */
.tk-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 78%;
    max-width: 320px;
    background: var(--c-card);
    z-index: var(--z-sheet);
    overflow-y: auto;
    padding: var(--sp-4);
}

.tk-drawer__body {
    padding-bottom: var(--sp-4);
}

.tk-drawer__foot {
    display: flex;
    gap: var(--sp-2);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--c-line);
}

/* ---------- 官网区块组件（见 08 §10.4） ---------- */
.tk-banner {
    position: relative;
    border-radius: var(--r-card);
    overflow: hidden;
    margin-bottom: var(--sp-4);
    background: var(--c-brand-light);
}

.tk-banner__img {
    display: block;
    width: 100%;
}

.tk-banner__title {
    padding: var(--sp-4);
    font-size: var(--fs-xl);
    font-weight: 700;
}

.tk-banner__subtitle {
    padding: 0 var(--sp-4) var(--sp-4);
    color: var(--c-text-sub);
}

.tk-block {
    background: var(--c-card);
    border-radius: var(--r-card);
    padding: var(--sp-4);
    margin-bottom: var(--sp-3);
}

.tk-block__title {
    font-weight: 600;
    margin-bottom: var(--sp-2);
}

.tk-block__body {
    color: var(--c-text-sub);
    font-size: var(--fs-sm);
}

.tk-products {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-3);
}

.tk-product {
    background: var(--c-card);
    border-radius: var(--r-card);
    overflow: hidden;
}

.tk-product__img {
    width: 100%;
}

.tk-product__name {
    padding: var(--sp-2) var(--sp-3) 0;
    font-weight: 600;
}

.tk-product__desc {
    padding: 0 var(--sp-3) var(--sp-3);
    color: var(--c-text-weak);
    font-size: var(--fs-xs);
}

.tk-contact__item {
    padding: var(--sp-2) 0;
    color: var(--c-text-sub);
    font-size: var(--fs-sm);
}

/* ============================================================
   后台侧栏菜单（配合 layout/admin.php）
   依据：约定/布局与前端结构规范.md §1.2 后台骨架
   🔴 仅用既有设计令牌，不引入新色值
   ============================================================ */

.tk-menu {
    display: block;
}

/* 菜单分组标题（「批次制卡 / 卡管理 / 核销记录」等按业务流程分组的视觉分层） */
.tk-menu__group {
    margin: var(--sp-4) var(--sp-3) var(--sp-2);
    font-size: 11px;
    color: var(--c-text-weak);
    letter-spacing: .08em;
}

.tk-menu__group:first-child {
    margin-top: var(--sp-2);
}

.tk-menu__item {
    display: block;
    padding: var(--sp-3);
    margin-bottom: var(--sp-1);
    border-radius: var(--r-btn);
    color: var(--c-text-sub);
    font-size: var(--fs-sm);
    line-height: 1.4;
    transition: background .15s ease, color .15s ease;
}

.tk-menu__item:hover {
    background: var(--c-brand-light);
    color: var(--c-brand);
}

.tk-menu__item.is-active {
    background: var(--c-brand-light);
    color: var(--c-brand);
    font-weight: 600;
}

/* ============================================================
   后台列表表格（配合 layout/admin.php 的内容区）
   依据：约定/css样式文档.md §九「列表/表格撑满」+ §9.6 紧凑档
   🔴 窄屏用外层 .tk-table-wrap 横向滚动，避免撑破布局
   ============================================================ */

.tk-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--r-card);
}

.tk-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--c-card);
    border: 1px solid var(--c-line);
}

.tk-table th,
.tk-table td {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-size: var(--fs-sm);
    border-bottom: 1px solid var(--c-line);
    white-space: nowrap;                  /* 单元格不折行，窄屏靠横向滚动 */
}

.tk-table th {
    background: #fafafa;
    color: var(--c-text-sub);
    font-weight: 600;
}

.tk-table tbody tr:hover {
    background: var(--c-brand-light);
}

.tk-table tbody tr:last-child td {
    border-bottom: 0;
}

.tk-table__num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tk-table__actions {
    text-align: right;
}

/* ============================================================
   🔴 后台视觉：复刻主站「哎呀好网」管理后台（framework/public/static/admin/admin.css）
   全部限定在 .tk-admin 作用域；前台/操作员/业务员移动端视觉完全不变。
   ============================================================ */

/* ---------- 后台整体背景 ---------- */
.tk-admin {
    background: var(--c-gray-50);
    color: var(--c-gray-900);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---------- 顶栏（与主站一致：白底 + 灰下边框 + h-14/56px） ---------- */
.tk-admin__topbar {
    height: 56px;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid var(--c-gray-200);
    box-shadow: none;
}

@media (min-width: 1024px) {
    .tk-admin__topbar {
        padding: 0 32px;
    }
}

.tk-admin__topbar,
.tk-admin__topbar-left,
.tk-admin__topbar-right {
    display: flex;
    align-items: center;
}

.tk-admin__topbar-left {
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.tk-admin__topbar-right {
    gap: 12px;
    margin-left: auto;
}

.tk-admin__brand {
    display: inline-flex;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--c-gray-900);
    white-space: nowrap;
}

.tk-admin__brand-divider {
    color: var(--c-gray-400);
    font-size: 13px;
    display: none;
}

@media (min-width: 640px) {
    .tk-admin__brand-divider {
        display: inline;
    }
}

.tk-admin__brand-sub {
    font-size: 13px;
    font-weight: 500;
    color: var(--c-gray-700);
    display: none;
}

@media (min-width: 640px) {
    .tk-admin__brand-sub {
        display: inline;
    }
}

.tk-admin__user-name {
    font-size: 12px;
    color: var(--c-gray-400);
    white-space: nowrap;
}

.tk-admin__user-link {
    font-size: 12px;
    color: var(--c-gray-500);
    text-decoration: none;
    white-space: nowrap;
}

.tk-admin__user-link:hover {
    color: var(--c-danger);
}

.tk-admin__user-link--primary {
    color: var(--c-brand);
}

.tk-admin__user-link--primary:hover {
    color: var(--c-brand-dark);
}

/* ---------- 页面大标题（主站内容区标题块） ---------- */
.tk-admin__page-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--c-gray-200);
    margin-bottom: 20px;
}

.tk-admin__page-head-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--c-brand-light);
    color: var(--c-brand);
    flex-shrink: 0;
}

.tk-admin__page-head-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--c-gray-900);
    line-height: 1.35;
}

@media (min-width: 1024px) {
    .tk-admin__page-head-title {
        font-size: 24px;
    }
}

/* ---------- 侧边栏（w-52=208px，白底，灰右边框） ---------- */
.tk-admin__side {
    flex: 0 0 208px;
    width: 208px;
    padding: 16px 8px;
    background: #fff;
    border-right: 1px solid var(--c-gray-100);
}

.tk-admin .tk-menu__group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px;
    margin: 4px 0 2px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-gray-700);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.tk-admin .tk-menu__group:hover {
    background: rgba(249, 250, 251, .8);
    color: var(--c-gray-900);
}

.tk-admin .tk-menu__group.is-active {
    color: var(--c-brand);
}

.tk-admin .tk-menu__group-label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tk-admin .tk-menu__group-chevron {
    color: var(--c-gray-400);
    transition: transform .2s ease;
}

.tk-admin .tk-menu__group.is-expanded .tk-menu__group-chevron {
    transform: rotate(180deg);
}

.tk-admin .tk-menu__sub {
    display: none;
    padding-left: 8px;
}

.tk-admin .tk-menu__group.is-expanded + .tk-menu__sub {
    display: block;
}

.tk-admin .tk-menu__sub .tk-menu__item {
    padding-left: 32px;
}

.tk-admin .tk-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    margin-bottom: 2px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--c-gray-600);
    transition: background .15s ease, color .15s ease;
}

.tk-admin .tk-menu__item:hover {
    background: rgba(249, 250, 251, .8);
    color: var(--c-gray-900);
}

.tk-admin .tk-menu__item.is-active {
    background: var(--c-gray-100);
    color: var(--c-gray-800);
    font-weight: 500;
}

/* ---------- 主内容区内边距（与主站 <main> 一致） ---------- */
.tk-admin__main {
    padding: 20px 16px 80px;
}

@media (min-width: 1024px) {
    .tk-admin__main {
        padding: 20px 32px 32px;
    }
}

/* ---------- 卡片（bg-white rounded-xl shadow-sm border p-5） ---------- */
.tk-admin .tk-card {
    background: #fff;
    border: 1px solid var(--c-gray-200);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(17, 24, 39, .05);
    padding: 20px;
    margin-bottom: 20px;
}

.tk-admin .tk-card__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--c-gray-200);
    font-size: 15px;
    font-weight: 600;
    color: var(--c-gray-800);
}

.tk-admin .tk-card__body {
    color: var(--c-gray-500);
    font-size: 13px;
}

.tk-admin .tk-card__foot {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-start;       /* 主站操作栏默认居左 */
    flex-wrap: wrap;
}

/* ---------- 按钮（主站 exact 组合） ---------- */
.tk-admin .tk-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--c-gray-200);
    border-radius: 8px;
    background: #fff;
    color: var(--c-gray-600);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
    box-shadow: none;
}

.tk-admin .tk-btn:hover {
    background: var(--c-gray-50);
    color: var(--c-gray-700);
}

.tk-admin .tk-btn--primary {
    background: var(--c-brand);
    border-color: var(--c-brand);
    color: #fff;
}

.tk-admin .tk-btn--primary:hover {
    background: var(--c-brand-dark);
    border-color: var(--c-brand-dark);
}

.tk-admin .tk-btn--ghost {
    background: transparent;
    color: var(--c-brand);
    border-color: var(--c-brand);
}

.tk-admin .tk-btn--danger {
    background: var(--c-danger);
    border-color: var(--c-danger);
    color: #fff;
}

.tk-admin .tk-btn--sm {
    min-height: 28px;
    padding: 0 12px;
    font-size: 12px;
}

/* ---------- 表单控件 ---------- */
.tk-admin .tk-field__label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-gray-700);
}

.tk-admin .tk-field__input {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--c-gray-200);
    border-radius: 8px;
    background: #fff;
    color: var(--c-gray-900);
    font-size: 13px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.tk-admin .tk-field__input:focus {
    outline: none;
    border-color: #fb923c;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .1);
}

.tk-admin textarea.tk-field__input {
    min-height: 80px;
    padding: 8px 12px;
    line-height: 1.6;
}

.tk-admin .tk-field__tip {
    margin-top: 8px;
    font-size: 12px;
    color: var(--c-gray-400);
}

/* ---------- 统计卡 ---------- */
.tk-admin .tk-stat {
    background: #fff;
    border: 1px solid var(--c-gray-200);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(17, 24, 39, .05);
    padding: 16px;
    text-align: left;
}

.tk-admin .tk-stat__num {
    font-size: 20px;
    font-weight: 700;
    color: var(--c-brand);
    margin-bottom: 4px;
}

.tk-admin .tk-stat__label {
    font-size: 12px;
    color: var(--c-gray-500);
}

/* ---------- 表格 ---------- */
.tk-admin .tk-table-wrap {
    border: 1px solid var(--c-gray-200);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(17, 24, 39, .05);
    overflow: hidden;
}

.tk-admin .tk-table {
    border: 0;
}

.tk-admin .tk-table th,
.tk-admin .tk-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--c-gray-100);
    font-size: 13px;
}

.tk-admin .tk-table th {
    background: var(--c-gray-50);
    color: var(--c-gray-500);
    font-weight: 600;
}

.tk-admin .tk-table tbody tr:hover {
    background: var(--c-brand-light);
}

/* ---------- 状态标签 ---------- */
.tk-admin .tk-tag {
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
}

/* ---------- 空状态/提示文字色 ---------- */
.tk-admin .tk-empty__text,
.tk-admin .tk-empty__sub {
    color: var(--c-gray-400);
}

/* ---------- 列表项 ---------- */
.tk-admin .tk-item {
    padding: 10px 0;
    border-bottom-color: var(--c-gray-100);
}

.tk-admin .tk-item__main {
    color: var(--c-gray-700);
    font-size: 13px;
}

.tk-admin .tk-item__extra {
    color: var(--c-gray-600);
    font-size: 13px;
}

.tk-admin .tk-item__sub {
    color: var(--c-gray-400);
}

/* ---------- 页脚 ---------- */
.tk-admin .site-footer {
    padding-top: 32px;
}

/* ---------- 移动端汉堡菜单按钮 ---------- */
.tk-admin__burger {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--c-gray-200);
    border-radius: 8px;
    background: #fff;
    color: var(--c-gray-500);
    cursor: pointer;
}

@media (min-width: 1024px) {
    .tk-admin__burger {
        display: none;
    }
}

/* ---------- 内容栅格（原 layout.css，component.css 同步提供，保证 admin 布局可用） ---------- */
.tk-grid { display: grid; gap: 24px; }
.tk-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tk-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 768px) {
    .tk-grid--2,
    .tk-grid--3 { grid-template-columns: 1fr; }
}
