/* ========================================
   超市收银系统 - 全局样式
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1890ff;
    --primary-hover: #40a9ff;
    --success: #52c41a;
    --warning: #faad14;
    --danger: #ff4d4f;
    --bg: #f0f2f5;
    --white: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --border: #e8e8e8;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

/* ========== 登录页 ========== */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
}

.login-box {
    width: 400px;
    background: var(--white);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.login-logo h1 {
    text-align: center;
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text);
}

.login-logo p {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 30px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.1);
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-light);
    font-size: 12px;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 18px;
}

/* ========== 提示信息 ========== */
.msg {
    text-align: center;
    margin-top: 12px;
    font-size: 14px;
    min-height: 20px;
}

.msg-error {
    color: var(--danger);
}

.msg-success {
    color: var(--success);
}

/* ========== 布局 ========== */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 200px;
    background: #001529;
    color: var(--white);
    flex-shrink: 0;
}

.sidebar-logo {
    padding: 20px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-menu {
    list-style: none;
    padding: 10px 0;
}

.sidebar-menu li a {
    display: block;
    padding: 14px 24px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.3s;
    font-size: 14px;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: var(--primary);
    color: var(--white);
}

.sidebar-menu li a .icon {
    margin-right: 8px;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========== 顶部栏 ========== */
.header {
    background: var(--white);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    z-index: 10;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user span {
    color: var(--text-light);
}

/* ========== 内容区 ========== */
.content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* ========== 收银台专用 ========== */
.cashier-wrap {
    display: flex;
    gap: 20px;
    height: calc(100vh - 96px);
}

.cashier-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cashier-right {
    width: 460px;
    background: var(--white);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

/* 搜索/扫码区 */
.scan-bar {
    display: flex;
    gap: 12px;
}

.scan-bar input {
    flex: 1;
    padding: 14px 20px;
    font-size: 18px;
    border: 2px solid var(--primary);
    border-radius: 12px;
    outline: none;
}

.scan-bar input:focus {
    box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.15);
}

/* 商品分类（单行平铺，标签等宽撞满一排） */
.category-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.category-tab {
    flex: 1;
    min-width: 0;
    text-align: center;
    white-space: nowrap;
    padding: 14px 6px;
    border-radius: 12px;
    background: var(--white);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
}

.category-tab:hover,
.category-tab.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* 小类标签：更小更轻，区别于大类 */
.sub-tabs .category-tab {
    padding: 10px 24px;
    font-size: 24px;
    background: var(--bg, #f5f5f5);
}
.sub-tabs:empty {
    display: none;
}

/* 商品网格 */
.product-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    overflow-y: auto;
    padding: 4px;
    scrollbar-width: none; /* 隐藏滚动条（仍可滚动）Firefox */
    -ms-overflow-style: none; /* IE/旧Edge */
}
.product-grid::-webkit-scrollbar {
    display: none; /* Chrome/Edge/Safari */
}

.product-card {
    background: var(--white);
    border-radius: 10px;
    padding: 16px;
    height: 120px; /* 卡片高度固定，行高整齐 */
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    text-align: center;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.product-card:active {
    transform: scale(0.97);
}

/* 选中的商品卡片（点击后高亮，便于识别当前选的哪个） */
.product-card.selected {
    background: #e6f7ff;
    box-shadow: 0 0 0 2px var(--primary) inset, var(--shadow);
}

.product-card .name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card .price {
    color: var(--danger);
    font-size: 18px;
    font-weight: 700;
}

.product-card .price::before {
    content: '¥';
    font-size: 12px;
}

.product-card .stock {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

/* 购物车区域 */
.cart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.cart-item .item-name {
    flex: 1;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item .item-price {
    min-width: 60px;
    text-align: right;
    font-size: 13px;
    color: #999;
}

.cart-item .item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-item .item-qty button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item .item-qty button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cart-item .item-qty span {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
}

/* 购物车数量可点击修改 */
.cart-item .item-qty .qty-num {
    cursor: pointer;
    border-bottom: 1px dashed #bbb;
}

/* 加号后的单位：覆盖 span 全局加粗/居中规则，gap 提供约一个空格的间距 */
.cart-item .item-qty .qty-unit {
    min-width: 0;
    font-weight: 400;
    color: #666;
}

/* 修改数量弹窗：数字键盘 */
.qty-display {
    height: 64px;
    line-height: 64px;
    text-align: right;
    padding: 0 16px;
    margin-bottom: 14px;
    font-size: 32px;
    font-weight: 700;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fafafa;
    overflow: hidden;
}

.num-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.num-key {
    height: 64px;
    font-size: 24px;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    cursor: pointer;
}

.num-key:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.num-key:active {
    background: #f0f5ff;
}

.cart-item .item-subtotal {
    min-width: 70px;
    text-align: right;
    font-weight: 700;
    color: var(--danger);
}

.cart-item .item-del {
    color: var(--danger);
    cursor: pointer;
    font-size: 18px;
    opacity: 0.5;
}

.cart-item .item-del:hover {
    opacity: 1;
}

/* 结算区 */
.cart-footer {
    border-top: 2px solid var(--border);
    padding: 16px 20px;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.cart-total .total-label {
    font-size: 14px;
    color: var(--text-light);
}

.cart-total .total-amount {
    font-size: 32px;
    font-weight: 700;
    color: var(--danger);
}

.cart-total .total-amount::before {
    content: '¥';
    font-size: 18px;
}

.pay-type {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.pay-type-btn {
    flex: 1;
    padding: 8px;
    border: 2px solid var(--border);
    background: var(--white);
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-size: 13px;
    transition: all 0.2s;
}

.pay-type-btn:hover,
.pay-type-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: #e6f7ff;
}

.btn-checkout {
    width: 100%;
    padding: 16px;
    font-size: 20px;
    font-weight: 700;
    border-radius: 12px;
}

/* ========== 数据表格 ========== */
.table-wrap {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.table-toolbar input,
.table-toolbar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.table-toolbar input:focus,
.table-toolbar select:focus {
    border-color: var(--primary);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    background: #fafafa;
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

table td {
    font-size: 14px;
    color: var(--text);
}

table tr:hover td {
    background: #f5f5f5;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.pagination a {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
}

.pagination a.active,
.pagination a:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ========== 统计卡片 ========== */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.stat-card .label {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
}

.stat-card .value.money::before {
    content: '¥';
    font-size: 18px;
    margin-right: 2px;
}

/* ========== 弹窗 ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: 12px;
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 18px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header .close {
    cursor: pointer;
    font-size: 32px;
    color: var(--text-light);
    width: 44px;
    height: 44px;
    line-height: 44px;
    text-align: center;
    border-radius: 8px;
    flex-shrink: 0;
}

.modal-header .close:hover {
    background: #f5f5f5;
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    text-align: right;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ========== 表单 ========== */
.form-row {
    margin-bottom: 16px;
}

.form-row label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
}

.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.form-row input:focus,
.form-row select:focus {
    border-color: var(--primary);
}

/* ========== 打印小票 ========== */
@media print {
    body * { visibility: hidden; }
    #receipt, #receipt * { visibility: visible; }
    #receipt { position: absolute; left: 0; top: 0; width: 80mm; }
}

#receipt {
    display: none;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    padding: 10px;
    width: 80mm;
}

#receipt .receipt-title {
    text-align: center;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 8px;
}

#receipt .receipt-line {
    border-top: 1px dashed #000;
    margin: 6px 0;
}

#receipt table {
    width: 100%;
}

#receipt table td {
    padding: 2px 0;
    border: none;
    font-size: 14px;
}

/* 小票商品表格：表头下划线、名称自动折行、数字列右对齐 */
#receipt .receipt-table {
    width: 100%;
    border-collapse: collapse;
}
#receipt .receipt-table thead th {
    font-weight: 700;
    font-size: 13px;
    padding: 4px 2px 6px;
    border-bottom: 1px dashed #000;
    white-space: nowrap; /* 表头强制单行，防止中文折成竖排 */
}
#receipt .receipt-table tbody td {
    padding: 6px 2px;
    font-size: 13px;
    vertical-align: top;
    word-break: break-all;
}
#receipt .receipt-table .c-name { text-align: left; }
#receipt .receipt-table .c-num { text-align: right; white-space: nowrap; }
#receipt .receipt-table tbody tr + tr td { border-top: 1px dotted #ccc; }

/* 小票商品项：名称一行靠左，数量×单价=小计一行靠右；项间距加大、下边框分隔 */
#receipt .receipt-item {
    padding: 6px 0;
    border-bottom: 1px dashed #000;
}

#receipt .receipt-item-name {
    text-align: left;
}

#receipt .receipt-item-detail {
    text-align: right;
    margin-top: 2px; /* 名称行与数量行间距小 */
}

/* ========== Toast提示 ========== */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--text);
    color: var(--white);
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }
