/* ============================================
   数据分析站 - 全局样式
   ============================================ */
:root {
    --primary: #4ecdc4;
    --primary-dark: #3db8b0;
    --primary-light: rgba(78,205,196,0.1);
    --danger: #ff6b6b;
    --danger-light: rgba(255,107,107,0.1);
    --warning: #ffa726;
    --success: #66bb6a;
    --info: #42a5f5;
    --bg: #0a0e17;
    --bg-card: #111827;
    --bg-card-hover: #1a2332;
    --bg-sidebar: #0d1117;
    --bg-input: #1a2332;
    --border: #1e293b;
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #475569;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === 侧边栏 === */
.sidebar {
    width: 240px;
    min-height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover {
    color: var(--text);
    background: var(--primary-light);
}

.nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
}

.nav-item i { width: 20px; text-align: center; font-size: 16px; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

.user-info i { font-size: 18px; color: var(--primary); }

.sidebar-actions {
    display: flex;
    gap: 8px;
}

.sidebar-actions button {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.sidebar-actions button:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* === 主内容 === */
.main-content {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 64px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 600;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.last-update {
    margin-left: auto;
    color: var(--text-dim);
    font-size: 12px;
}

.page-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* === 卡片 === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.card:hover { border-color: rgba(78,205,196,0.3); }

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--primary); }

/* === 统计卡片 === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 8px 30px rgba(78,205,196,0.1);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

.stat-card.cyan .stat-icon { background: rgba(78,205,196,0.15); color: #4ecdc4; }
.stat-card.cyan .stat-value { color: #4ecdc4; }
.stat-card.orange .stat-icon { background: rgba(255,167,38,0.15); color: #ffa726; }
.stat-card.orange .stat-value { color: #ffa726; }
.stat-card.purple .stat-icon { background: rgba(171,71,188,0.15); color: #ab47bc; }
.stat-card.purple .stat-value { color: #ab47bc; }
.stat-card.blue .stat-icon { background: rgba(66,165,245,0.15); color: #42a5f5; }
.stat-card.blue .stat-value { color: #42a5f5; }
.stat-card.red .stat-icon { background: rgba(255,107,107,0.15); color: #ff6b6b; }
.stat-card.red .stat-value { color: #ff6b6b; }
.stat-card.green .stat-icon { background: rgba(102,187,106,0.15); color: #66bb6a; }
.stat-card.green .stat-value { color: #66bb6a; }

/* === 表格 === */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

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

table thead th {
    background: rgba(78,205,196,0.08);
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table tbody tr:hover { background: var(--bg-card-hover); }
table tbody tr:last-child td { border-bottom: none; }

.text-right { text-align: right; }
.text-center { text-align: center; }

.text-sales { color: var(--danger); font-weight: 600; }
.text-restock { color: var(--success); font-weight: 600; }
.text-brand { color: var(--primary); font-weight: 500; }
.text-stock { color: var(--warning); }

/* === 按钮 === */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #000;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); }

.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(255,107,107,0.2);
}
.btn-danger:hover { background: rgba(255,107,107,0.2); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* === 表单 === */
.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(78,205,196,0.1);
}

.form-group input { min-width: 160px; }
.form-group select { min-width: 140px; }

/* === 弹窗 === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 i { color: var(--primary); }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal .form-group {
    margin-bottom: 14px;
}

.modal .form-group input {
    width: 100%;
    min-width: auto;
}

/* === Toast === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    animation: toastIn 0.3s;
    min-width: 240px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.toast.success { background: #1b5e20; color: #a5d6a7; border-left: 3px solid #66bb6a; }
.toast.error { background: #b71c1c; color: #ef9a9a; border-left: 3px solid #ff6b6b; }
.toast.info { background: #0d47a1; color: #90caf9; border-left: 3px solid #42a5f5; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* === 分页 === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    font-size: 13px;
    color: var(--text-muted);
}

.pagination .page-btns {
    display: flex;
    gap: 4px;
}

.pagination .page-btns button {
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.pagination .page-btns button:hover,
.pagination .page-btns button.active {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination .page-btns button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* === 简单柱状图 === */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
    padding: 10px 0;
}

.bar-chart .bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    max-width: 80px;
}

.bar-chart .bar {
    width: 100%;
    background: linear-gradient(to top, var(--primary), var(--primary-dark));
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.5s ease;
    position: relative;
}

.bar-chart .bar:hover { opacity: 0.85; }

.bar-chart .bar-value {
    font-size: 11px;
    color: var(--text);
    font-weight: 600;
}

.bar-chart .bar-label {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    word-break: break-all;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === 标签 === */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.tag-cyan { background: rgba(78,205,196,0.15); color: #4ecdc4; }
.tag-orange { background: rgba(255,167,38,0.15); color: #ffa726; }
.tag-red { background: rgba(255,107,107,0.15); color: #ff6b6b; }
.tag-blue { background: rgba(66,165,245,0.15); color: #42a5f5; }

/* === 空状态 === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; }
.empty-state p { font-size: 14px; }

/* === 搜索高亮 === */
.highlight { background: rgba(78,205,196,0.3); border-radius: 2px; }

/* === 标签页 === */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* === 响应式 === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .page-content { padding: 16px; }
    .form-row { flex-direction: column; }
    .form-group input, .form-group select { min-width: auto; width: 100%; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* === 滚动条 === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
