/* ========== 基础样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
}

/* ========== 按钮 ========== */
.btn {
    padding: 6px 16px;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn:hover {
    opacity: 0.85;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-success {
    background: #28a745;
    color: #fff;
}

.btn-danger {
    background: #dc3545;
    color: #fff;
}

.btn-primary {
    background: #007bff;
    color: #fff;
}

.btn-default {
    background: #4a4a6a;
    color: #e0e0e0;
}

.btn-small {
    padding: 4px 12px;
    font-size: 12px;
    white-space: nowrap;
}

/* ========== 顶部栏 ========== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #16213e;
    border-bottom: 1px solid #2a2a4a;
}

.top-bar-left {
    display: flex;
    gap: 8px;
}

.top-bar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input {
    padding: 6px 12px;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 14px;
    width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
}

/* ========== 状态栏 ========== */
.status-bar {
    padding: 8px 20px;
    background: #1e2a3a;
    font-size: 13px;
    color: #aaa;
    border-bottom: 1px solid #2a2a4a;
}

.status-bar .separator {
    margin: 0 8px;
    color: #3a3a5a;
}

.current-goods {
    margin-left: 12px;
    color: #ffc107;
}

/* ========== 表格 ========== */
.table-container {
    padding: 10px 20px;
    overflow-x: auto;
}

#goods-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

#goods-table thead {
    background: #16213e;
}

#goods-table th {
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    border-bottom: 2px solid #2a2a4a;
    color: #aaa;
    white-space: nowrap;
}

#goods-table td {
    padding: 8px;
    border-bottom: 1px solid #2a2a4a;
    vertical-align: middle;
    text-align: center;
}

/* 价格列表头右对齐，跟右对齐的数据对称 */
#goods-table th:nth-child(3),
#goods-table th:nth-child(4),
#goods-table th:nth-child(5),
#goods-table th:nth-child(6) {
    text-align: right;
    padding-right: 16px;
}

#goods-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

#goods-table .empty-row td {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* 列宽分配 */
#goods-table th:nth-child(1) { width: 56px; }   /* 图片 */
#goods-table th:nth-child(2) { width: 180px; }  /* 商品名（限制宽度） */
#goods-table td:nth-child(2) {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#goods-table th:nth-child(3),
#goods-table th:nth-child(4),
#goods-table th:nth-child(5),
#goods-table th:nth-child(6) { width: 140px; }  /* 4个价格列 */
#goods-table th:nth-child(7),
#goods-table th:nth-child(8) { width: 80px; }   /* 详情/删除按钮 */

.goods-img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    background: #111;
    border-radius: 3px;
}

.price-cell {
    font-variant-numeric: tabular-nums;
    text-align: right !important;
    padding-right: 16px !important;
}

.price-status {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.status-green { background: #28a745; }
.status-yellow { background: #ffc107; }
.status-red { background: #dc3545; }
.status-gray { background: #6c757d; }

.editable-cell {
    cursor: pointer;
    min-width: 80px;
}

.editable-cell:hover {
    background: rgba(0, 123, 255, 0.1);
    border-radius: 3px;
}

.editable-cell input {
    width: 100px;
    padding: 2px 6px;
    border: 2px solid #007bff;
    border-radius: 3px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 14px;
}

.editable-cell input:focus {
    outline: none;
}

/* ========== 弹窗 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: #1e2a3a;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    min-width: 400px;
}

.modal-large {
    width: 700px;
}

.modal-xlarge {
    width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #2a2a4a;
}

.modal-header h3 {
    font-size: 16px;
    color: #e0e0e0;
}

.modal-close {
    background: none;
    border: none;
    color: #aaa;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #2a2a4a;
}

/* ========== 表单 ========== */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: #aaa;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 14px;
}

.form-input:focus {
    outline: none;
    border-color: #007bff;
}

/* ========== 搜索弹窗 ========== */
.search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.search-box .form-input {
    flex: 1;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #2a2a4a;
    gap: 10px;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.search-result-item img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    background: #111;
    border-radius: 3px;
}

.search-result-item .item-info {
    flex: 1;
}

.search-result-item .item-name {
    font-size: 14px;
    color: #e0e0e0;
}

.search-result-item .item-code {
    font-size: 12px;
    color: #888;
}

/* ========== 详情弹窗 ========== */
.detail-header {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.detail-header img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    background: #111;
    border-radius: 4px;
}

.detail-info h4 {
    font-size: 18px;
    color: #e0e0e0;
    margin-bottom: 4px;
}

.detail-info .detail-meta {
    font-size: 13px;
    color: #888;
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section h4 {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #2a2a4a;
}

.detail-section table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.detail-section th {
    padding: 6px 8px;
    text-align: center;
    background: #16213e;
    color: #aaa;
    border-bottom: 1px solid #2a2a4a;
}

.detail-section td {
    padding: 6px 8px;
    text-align: center;
    border-bottom: 1px solid #1a2a3a;
}
