/* ==================== 全局样式 ==================== */
:root {
    --sidebar-width: 230px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --topbar-height: 56px;
    --primary: #3b82f6;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

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

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}

.logo i {
    font-size: 24px;
    color: var(--primary);
}

.nav-menu {
    list-style: none;
    padding: 12px 0;
    margin: 0;
    flex: 1;
}

.nav-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-menu li a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-menu li a.active {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-left-color: var(--primary);
}

.nav-menu li a i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.version-info {
    font-size: 12px;
    color: #64748b;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-toggle {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text);
    cursor: pointer;
    display: none;
}

.page-title {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-user {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-user:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-user i {
    font-size: 16px;
}

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

/* ==================== 卡片面板 ==================== */
.card-panel {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
    border: 1px solid #edf2f7;
}

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

.panel-header h6 {
    margin: 0;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-body {
    padding: 20px;
}

.panel-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

.btn-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.btn-link:hover {
    color: #2563eb;
}

/* ==================== 统计卡片 ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #edf2f7;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    flex-shrink: 0;
}

.stat-blue .stat-icon { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-green .stat-icon { background: linear-gradient(135deg, #22c55e, #16a34a); }
.stat-purple .stat-icon { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-orange .stat-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-teal .stat-icon { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.stat-cyan .stat-icon { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.stat-indigo .stat-icon { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.stat-pink .stat-icon { background: linear-gradient(135deg, #ec4899, #db2777); }

.stat-body {
    flex: 1;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    color: #1e293b;
}

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

/* ==================== 表格 ==================== */
.table {
    margin-bottom: 0;
    font-size: 14px;
}

.table thead th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    padding: 10px 16px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 10px 16px;
    border-color: #f1f5f9;
    vertical-align: middle;
}

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

/* ==================== 产品缩略图 ==================== */
.product-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.product-thumb-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    font-size: 16px;
}

.product-name-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.product-name-link:hover {
    color: var(--primary);
}

/* ==================== 库存徽章 ==================== */
.stock-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    min-width: 36px;
    text-align: center;
}

.stock-ok {
    background: #dcfce7;
    color: #16a34a;
}

.stock-zero {
    background: #fef2f2;
    color: #dc2626;
}

.stock-transit {
    background: #fef3c7;
    color: #d97706;
}

/* ==================== 搜索栏 ==================== */
.search-bar {
    flex: 1;
}

.search-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-group i {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    font-size: 14px;
    z-index: 1;
}

.search-input-group .form-control {
    padding-left: 32px;
}

/* ==================== 仓库卡片 ==================== */
.warehouse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.warehouse-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #edf2f7;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.warehouse-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.warehouse-card-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.wh-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.wh-info {
    flex: 1;
}

.wh-actions {
    display: flex;
    gap: 4px;
}

.warehouse-card-body {
    padding: 16px 20px;
}

.wh-location {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

.wh-location i {
    margin-right: 4px;
}

.wh-stats {
    display: flex;
    gap: 20px;
}

.wh-stat {
    text-align: center;
}

.wh-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
}

.wh-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.warehouse-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

/* ==================== 产品详情 ==================== */
.product-detail-layout {
    display: flex;
    gap: 24px;
}

.product-image-section {
    flex-shrink: 0;
}

.product-image-large {
    width: 256px;
    height: 256px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.product-image-placeholder-large {
    width: 256px;
    height: 256px;
    border-radius: 10px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    gap: 8px;
}

.product-image-placeholder-large i {
    font-size: 40px;
}

.product-info-section {
    flex: 1;
}

.product-info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px 24px;
    margin-top: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-item-full {
    grid-column: 1 / -1;
}

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

.info-value {
    font-size: 14px;
    font-weight: 500;
    color: #334155;
}

.info-value.price {
    color: var(--danger);
    font-weight: 600;
}

.link-truncate {
    color: var(--primary);
    text-decoration: none;
    word-break: break-all;
    font-size: 13px;
}

.link-truncate:hover {
    text-decoration: underline;
}

/* ==================== 仓库详情信息块 ==================== */
.info-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-block-label {
    font-size: 12px;
    color: var(--text-muted);
}

.info-block-value {
    font-size: 14px;
    font-weight: 500;
    color: #334155;
}

/* ==================== 操作栏 ==================== */
.action-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==================== 操作弹窗 ==================== */
.op-product-info {
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
}

.op-info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.op-value {
    font-size: 14px;
    font-weight: 500;
    color: #334155;
}

.op-transit-info {
    margin-top: 10px;
    padding: 8px 12px;
    background: #eff6ff;
    border-radius: 6px;
    color: #1e40af;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ==================== 仓库条形图 ==================== */
.warehouse-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wh-bar-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wh-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wh-name {
    font-weight: 600;
    font-size: 14px;
}

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

.wh-bar-track {
    height: 8px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.wh-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ==================== 低库存列表 ==================== */
.low-stock-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.low-stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #fef2f2;
    border-radius: 6px;
    border: 1px solid #fecaca;
}

.ls-product {
    flex: 1;
}

.ls-name {
    font-weight: 500;
    font-size: 14px;
}

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

.ls-qty {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ls-current {
    font-size: 18px;
    font-weight: 700;
    color: #dc2626;
}

.ls-divider {
    color: var(--text-muted);
}

.ls-safety {
    font-size: 14px;
    color: var(--text-muted);
}

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

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

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

/* ==================== Flash消息 ==================== */
.flash-container {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-flash {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
}

.alert-flash i {
    font-size: 18px;
}

.btn-close-flash {
    margin-left: auto;
    opacity: 0.5;
}

.btn-close-flash:hover {
    opacity: 1;
}

/* ==================== 分页 ==================== */
.pagination-bar {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 16px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    color: #334155;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.page-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .btn-toggle {
        display: block;
    }

    .product-detail-layout {
        flex-direction: column;
    }

    .product-image-large,
    .product-image-placeholder-large {
        width: 100%;
        height: 256px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

/* 产品图片上传区域 */
.product-image-upload-box {
    width: 256px !important;
    height: 256px !important;
    min-width: 256px !important;
    min-height: 256px !important;
    max-width: 256px !important;
    max-height: 256px !important;
    border: 2px dashed var(--primary);
    border-radius: 10px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    background: #f8fafc;
    overflow: hidden;
    flex-shrink: 0;
    box-sizing: border-box;
}

.product-image-upload-box:hover,
.product-image-upload-box:focus,
.product-image-upload-box.dragover {
    background: #eff6ff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.product-image-upload-box .upload-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.product-image-upload-box .upload-placeholder i {
    font-size: 4rem;
    color: var(--primary);
    opacity: 0.7;
}

.product-image-upload-box .product-image-upload-preview {
    width: 100% !important;
    height: 100% !important;
    max-width: 256px !important;
    max-height: 256px !important;
    object-fit: contain !important;
    position: absolute;
    top: 0;
    left: 0;
    display: block;
}

.upload-hints {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.8;
}

.upload-hints .hint-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.upload-hints .hint-item i {
    font-size: 13px;
}

.upload-hints kbd {
    padding: 1px 5px;
    border-radius: 3px;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    font-size: 11px;
    color: var(--text);
}
