/* ============================================
   商品管理平台 - 主样式表
   ============================================ */

/* ===== CSS 变量 ===== */
:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --bg-body: #f0f2f5;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;

    --border-color: #e2e8f0;
    --border-radius: 8px;
    --border-radius-lg: 12px;

    --sidebar-width: 240px;
    --header-height: 64px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ===== 布局 ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-header .version {
    font-size: 11px;
    color: var(--text-light);
    margin-left: 28px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #cbd5e1;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--bg-sidebar-hover);
    color: #fff;
    border-left-color: var(--primary-light);
}

.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
}

.user-name { font-size: 13px; font-weight: 500; }
.logout-link { font-size: 12px; color: var(--text-light); }
.logout-link:hover { color: var(--danger); }

.user-detail { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-links { display: flex; align-items: center; gap: 6px; }
.link-sep { color: var(--text-light); opacity: 0.4; }

/* ===== 主内容区 ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-primary);
}

.page-title { font-size: 18px; font-weight: 600; flex: 1; }

.header-right { display: flex; align-items: center; gap: 16px; }
.current-date { color: var(--text-secondary); font-size: 13px; }

.content-body { padding: 24px; flex: 1; }

/* ===== 卡片 ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

.card-body { padding-top: 4px; }

/* 账号信息展示 */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px 16px;
}

.info-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.info-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-note {
    background: var(--bg-input);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== 统计卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #d1fae5; }
.stat-icon.orange { background: #fef3c7; }
.stat-icon.red { background: #fee2e2; }
.stat-icon.purple { background: #f3e8ff; }

.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { opacity: 0.9; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-default { background: #e2e8f0; color: var(--text-primary); }
.btn-default:hover { background: #cbd5e1; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group label .required { color: var(--danger); }

.form-control,
input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    background: var(--bg-input);
    transition: all 0.2s;
    font-family: inherit;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-inline {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-inline .form-group { margin-bottom: 0; flex: 1; min-width: 150px; }

/* ===== 表格 ===== */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    font-size: 13px;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr:hover { background: #f8fafc; }

.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }

/* ===== 状态标签 ===== */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-default { background: #f1f5f9; color: #475569; }

.status-active { color: var(--success); font-weight: 600; }
.status-inactive { color: var(--text-secondary); }
.status-stopped { color: var(--danger); }

/* ===== 排名列表 ===== */
.rank-list { list-style: none; }

.rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.rank-item:last-child { border-bottom: none; }

.rank-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    background: #f1f5f9;
    color: var(--text-secondary);
}

.rank-number.top-1 { background: #fef3c7; color: #d97706; }
.rank-number.top-2 { background: #f1f5f9; color: #64748b; }
.rank-number.top-3 { background: #fed7aa; color: #c2410c; }

.rank-info { flex: 1; min-width: 0; }
.rank-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-meta { font-size: 12px; color: var(--text-secondary); }

.rank-value { font-weight: 700; font-size: 16px; flex-shrink: 0; }

/* ===== 预警卡片 ===== */
.alert-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.alert-item.warning { background: #fffbeb; border-color: #fde68a; }
.alert-item.info { background: #eff6ff; border-color: #bfdbfe; }

.alert-icon { font-size: 20px; flex-shrink: 0; }
.alert-content { flex: 1; }
.alert-title { font-weight: 600; font-size: 13px; }
.alert-desc { font-size: 12px; color: var(--text-secondary); }
.alert-value { font-weight: 700; font-size: 18px; flex-shrink: 0; }
.alert-value.down { color: var(--danger); }
.alert-value.up { color: var(--success); }

/* ===== 提示消息 ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.page-info { font-size: 13px; color: var(--text-secondary); }

.page-btns { display: flex; gap: 4px; }

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 13px;
    background: #fff;
    transition: all 0.2s;
    cursor: pointer;
}

.page-btn:hover:not(.active):not([disabled]) {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn[disabled] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ===== 工具栏 ===== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.toolbar-left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 8px; align-items: center; }

/* ===== Grid ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

@media (max-width: 1024px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== 图表容器 ===== */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container.small { height: 200px; }

/* ===== 文本工具 ===== */
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 18px; }

/* ===== 进度条 ===== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-bar-fill.high { background: var(--success); }
.progress-bar-fill.mid { background: var(--warning); }
.progress-bar-fill.low { background: var(--danger); }

/* ===== 登录页 ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container { width: 100%; max-width: 400px; padding: 20px; }

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-header h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.login-header p { color: var(--text-secondary); font-size: 14px; }

.login-form .form-group label { font-size: 13px; }
.login-form .btn { margin-top: 8px; font-size: 15px; padding: 12px; }

.login-hint {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state .empty-text { font-size: 15px; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 20px; }
    .content-body { padding: 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
}

/* ===== 过滤器 ===== */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

.filter-bar select,
.filter-bar input {
    width: auto;
    min-width: 140px;
}

.filter-bar .form-group {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-bar .form-group label { margin-bottom: 0; white-space: nowrap; font-size: 13px; }

/* ===== Tab ===== */
.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-item {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-item:hover:not(.active) { color: var(--text-primary); }

/* ===== 模态框 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
    background: #fff;
    border-radius: var(--border-radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
