/**
 * 仓库管理工作台 - 全局样式
 * 主题色: 深蓝 #1e3a5f
 */

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

:root {
    --primary: #1e3a5f;
    --primary-light: #2a5298;
    --primary-dark: #162d4b;
    --success: #28a745;
    --success-light: #d4edda;
    --warning: #fd7e14;
    --warning-light: #fff3cd;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --info: #17a2b8;
    --info-light: #d1ecf1;
    --bg-light: #f4f6f9;
    --bg-white: #ffffff;
    --border: #e0e6ed;
    --border-light: #eef1f5;
    --text-primary: #1a2332;
    --text-secondary: #5c6b7a;
    --text-muted: #96a2af;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --sidebar-width: 220px;
    --header-height: 56px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* ============ 布局 ============ */
.layout {
    display: flex;
    height: 100vh;
}

/* ============ 侧边栏 ============ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
}

.sidebar-header p {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 4px;
}

.sidebar-menu {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-size: 14px;
}

.menu-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.menu-item.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-left-color: var(--warning);
}

.menu-item .icon {
    width: 24px;
    margin-right: 10px;
    font-size: 16px;
    text-align: center;
}

.menu-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
    opacity: 0.6;
}

/* ============ 主内容区 ============ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page-header {
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

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

.page-header .date-info {
    font-size: 13px;
    color: var(--text-secondary);
}

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

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

.kpi-card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary);
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-card.success { border-left-color: var(--success); }
.kpi-card.warning { border-left-color: var(--warning); }
.kpi-card.danger  { border-left-color: var(--danger); }
.kpi-card.info    { border-left-color: var(--info); }

.kpi-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.kpi-value .unit {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 4px;
}

.kpi-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============ 卡片容器 ============ */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-light); }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #218838; }

.btn-warning {
    background: var(--warning);
    color: #fff;
}
.btn-warning:hover { background: #e6700d; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #c82333; }

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 14px;
    color: var(--text-muted);
}
.btn-icon:hover { color: var(--primary); }

/* ============ 标签 / 徽章 ============ */
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.tag-success { background: var(--success-light); color: #155724; }
.tag-warning { background: var(--warning-light); color: #856404; }
.tag-danger  { background: var(--danger-light); color: #721c24; }
.tag-info    { background: var(--info-light); color: #0c5460; }
.tag-primary { background: #d1dcf0; color: var(--primary); }
.tag-muted   { background: #eef1f5; color: var(--text-secondary); }

/* ============ 表格 ============ */
.table-wrapper {
    overflow-x: auto;
}

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

table.data-table th {
    background: var(--bg-light);
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

table.data-table tbody tr:hover {
    background: #fafbfc;
}

table.data-table tr.overdue td {
    color: var(--danger);
    font-weight: 500;
}

table.data-table tr.new-row {
    animation: highlight 1.5s ease;
}

@keyframes highlight {
    0% { background: #fff3cd; }
    100% { background: transparent; }
}

/* ============ 筛选栏 ============ */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.filter-bar input,
.filter-bar select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
}

.filter-bar input:focus,
.filter-bar select:focus {
    border-color: var(--primary);
}

/* ============ 进度条 ============ */
.progress-bar {
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-fill.success { background: linear-gradient(90deg, var(--success), #3dd598); }
.progress-fill.warning { background: linear-gradient(90deg, var(--warning), #ff9a3c); }
.progress-fill.danger  { background: linear-gradient(90deg, var(--danger), #ff6b6b); }

/* ============ 待办清单 ============ */
.todo-list {
    list-style: none;
}

.todo-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}

.todo-item:hover { background: #fafbfc; }

.todo-item:last-child { border-bottom: none; }

.todo-checkbox {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--primary);
}

.todo-content {
    flex: 1;
}

.todo-title {
    font-weight: 500;
    color: var(--text-primary);
}

.todo-item.completed .todo-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.todo-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.todo-actions {
    display: flex;
    gap: 6px;
}

/* ============ 时间线 ============ */
.timeline {
    list-style: none;
    padding-left: 20px;
}

.timeline-item {
    position: relative;
    padding-bottom: 16px;
    padding-left: 16px;
    border-left: 2px solid var(--border);
}

.timeline-item:last-child { border-left-color: transparent; }

.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
}

.timeline-item.success::before { background: var(--success); }
.timeline-item.warning::before { background: var(--warning); }
.timeline-item.danger  ::before { background: var(--danger); }

.timeline-time {
    font-size: 12px;
    color: var(--text-muted);
}

.timeline-content {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-primary);
}

/* ============ Tabs ============ */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 12px 24px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

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

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

/* ============ SOP 手风琴 ============ */
.sop-section {
    margin-bottom: 16px;
}

.sop-header {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    user-select: none;
}

.sop-header:hover {
    background: #e8ecf2;
}

.sop-header .arrow {
    margin-left: auto;
    transition: transform 0.2s;
    color: var(--text-muted);
}

.sop-header.open .arrow {
    transform: rotate(90deg);
}

.sop-body {
    padding: 16px 18px;
    border: 1px solid var(--border-light);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    display: none;
}

.sop-body.open { display: block; }

.sop-body ol, .sop-body ul {
    padding-left: 20px;
}

.sop-body li {
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ============ 模态框 ============ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.modal {
    background: #fff;
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

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

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============ 搜索栏 ============ */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-bar input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
}

.search-bar input:focus {
    border-color: var(--primary);
}

/* ============ 图表容器 ============ */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 16px;
}

.chart-box {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.chart-box h4 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

.chart-container {
    width: 100%;
    height: 300px;
}

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

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* ============ 动画提醒 ============ */
.warning-pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(253, 126, 20, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(253, 126, 20, 0); }
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h1, .sidebar-header p, .menu-item span:not(.icon) { display: none; }
    .menu-item { padding: 14px; justify-content: center; }
    .form-row { grid-template-columns: 1fr; }
    .chart-grid { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============ 滚动条美化 ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
