/* ============================================================
   LED工厂仓库管理系统 - Bootstrap 5 极简主题
   ============================================================ */

/* --- CSS Variables --- */
:root {
    --app-primary: #4361ee;
    --app-primary-rgb: 67,97,238;
    --app-success: #10b981;
    --app-warning: #f59e0b;
    --app-danger: #ef4444;
    --app-info: #06b6d4;
    --sidebar-w: 240px;
    --header-h: 56px;
    --radius: .5rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: #f0f2f5;
    color: #1e293b;
    overflow-x: hidden;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar-canvas {
    width: var(--sidebar-w) !important;
    border-right: none !important;
}
.sidebar-canvas .offcanvas-body {
    display: flex;
    flex-direction: column;
}

/* Desktop: 固定侧边栏 */
@media (min-width: 992px) {
    .sidebar-canvas {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 1030;
        visibility: visible !important;
        transform: none !important;
        background: #0f172a !important;
    }
    .main-content {
        margin-left: var(--sidebar-w);
    }
}

.sidebar-brand {
    border-bottom: 1px solid rgba(255,255,255,.08);
    padding-bottom: 16px !important;
}
.brand-icon {
    width: 36px; height: 36px;
    background: var(--app-primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff;
    margin-right: 10px; flex-shrink: 0;
}
.brand-title { color: #fff; font-size: 14px; font-weight: 600; line-height: 1.2; }
.brand-sub { color: rgba(255,255,255,.4); font-size: 11px; }

.sidebar-nav {
    flex: 1;
    padding: 8px 10px;
    overflow-y: auto;
}
.sidebar-heading {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,.3);
    font-weight: 700;
    padding: 14px 12px 4px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    color: rgba(255,255,255,.55);
    font-size: 13.5px; font-weight: 500;
    text-decoration: none;
    border-radius: 8px;
    transition: all .15s;
    margin-bottom: 1px;
}
.sidebar-link i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar-link.active {
    color: #fff;
    background: var(--app-primary);
    box-shadow: 0 2px 8px rgba(var(--app-primary-rgb), .35);
}

/* 分组折叠 */
.sidebar-group { margin-bottom: 2px; }
.sidebar-toggle { cursor: pointer; }
.sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar-arrow { font-size: 10px !important; width: auto !important; transition: transform .2s; margin-left: auto; }
.sidebar-toggle[aria-expanded="true"] .sidebar-arrow { transform: rotate(180deg); }
.sidebar-submenu { padding-left: 8px; }
.sidebar-submenu .sidebar-link { font-size: 13px; padding: 6px 12px 6px 16px; }
.sidebar-submenu .sidebar-link i { font-size: 14px; width: 18px; }

/* 收起状态 */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar-canvas {
        width: 60px !important;
    }
    body.sidebar-collapsed .main-content {
        margin-left: 60px;
    }
    body.sidebar-collapsed .sidebar-text,
    body.sidebar-collapsed .brand-title,
    body.sidebar-collapsed .brand-sub,
    body.sidebar-collapsed .sidebar-arrow,
    body.sidebar-collapsed .sidebar-submenu {
        display: none !important;
    }
    body.sidebar-collapsed .sidebar-brand {
        justify-content: center;
        padding: 12px 0 !important;
    }
    body.sidebar-collapsed .brand-icon {
        margin-right: 0;
    }
    body.sidebar-collapsed .sidebar-link {
        justify-content: center;
        padding: 10px 0;
    }
    body.sidebar-collapsed .sidebar-link i {
        width: auto; margin: 0;
    }
    body.sidebar-collapsed .sidebar-footer {
        justify-content: center;
        padding: 10px 8px;
    }
    body.sidebar-collapsed .sidebar-footer .avatar-sm {
        margin: 0;
    }
    body.sidebar-collapsed .sidebar-toggle {
        justify-content: center;
    }
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.avatar-sm {
    width: 32px; height: 32px;
    background: var(--app-primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; font-weight: 700;
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
    min-height: 100vh;
    transition: margin-left .3s;
}

/* 移动端给顶部导航栏留空间 */
@media (max-width: 991.98px) {
    .main-content { padding-top: var(--header-h); }
}

.page-header {
    background: #fff;
    padding: 0 24px;
    height: 52px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #e5e7eb;
    position: sticky; top: 0; z-index: 100;
}
@media (max-width: 991.98px) {
    .page-header { position: static; }
}

.page-body { padding: 20px 24px; }
@media (max-width: 576px) { .page-body { padding: 16px; } }

/* ============================================================
   Cards
   ============================================================ */
.card {
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
    padding: 14px 20px;
    font-weight: 600; font-size: 14px;
}

/* ============================================================
   Tables
   ============================================================ */
.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(var(--app-primary-rgb), .04);
    --bs-table-striped-bg: #fafbfc;
    font-size: 13.5px;
    margin-bottom: 0;
}
.table thead th {
    background: #f8f9fb;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #6b7280;
    border-bottom-width: 1px;
    padding: 10px 16px;
    white-space: nowrap;
}
.table tbody td {
    padding: 11px 16px;
    vertical-align: middle;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: rgba(var(--app-primary-rgb), .04) !important; }

/* 表格数字 */
.td-num { font-variant-numeric: tabular-nums; font-weight: 600; color: #1e293b; }
.td-muted { color: #9ca3af !important; font-weight: 400 !important; font-size: 12px; }
.td-code { font-family: "SF Mono", "Cascadia Code", Consolas, monospace; font-size: 12.5px; color: var(--app-primary); font-weight: 600; }

/* 表格行点击 */
tr[style*="cursor:pointer"]:hover { background: rgba(var(--app-primary-rgb), .06) !important; }

/* 预警行 */
.table .table-warning { --bs-table-bg: #fffbeb; }

/* 空状态 */
.table-empty { text-align: center; padding: 48px 20px !important; color: #9ca3af; }
.table-empty i { font-size: 36px; display: block; margin-bottom: 8px; opacity: .4; }

/* ============================================================
   Stat Cards
   ============================================================ */
.stat-card {
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; color: #1e293b; }
.stat-card .stat-label { font-size: 12px; color: #6b7280; font-weight: 500; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
    font-weight: 600; font-size: 11px;
    padding: 3px 10px; border-radius: 20px;
    letter-spacing: .3px;
}
.badge.bg-success-subtle { background: #ecfdf5 !important; color: #059669; }
.badge.bg-warning-subtle { background: #fffbeb !important; color: #d97706; }
.badge.bg-danger-subtle  { background: #fef2f2 !important; color: #dc2626; }
.badge.bg-primary-subtle { background: #eef2ff !important; color: #4338ca; }
.badge.bg-info-subtle    { background: #ecfeff !important; color: #0891b2; }
.badge.bg-secondary-subtle { background: #f3f4f6 !important; color: #6b7280; }

/* ============================================================
   Buttons
   ============================================================ */
.btn { border-radius: 8px; font-weight: 500; font-size: 13.5px; transition: all .15s; }
.btn-primary { --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary); --bs-btn-hover-bg: #3651d4; --bs-btn-hover-border-color: #3651d4; --bs-btn-active-bg: #2d44b8; }
.btn-success { --bs-btn-bg: var(--app-success); --bs-btn-border-color: var(--app-success); --bs-btn-hover-bg: #0ea271; --bs-btn-hover-border-color: #0ea271; }
.btn-danger  { --bs-btn-bg: var(--app-danger); --bs-btn-border-color: var(--app-danger); }
.btn-sm { font-size: 12.5px; padding: 4px 12px; border-radius: 6px; }
.btn-xs { font-size: 11px; padding: 2px 8px; border-radius: 4px; }

/* 按钮点击反馈 */
.btn:active { transform: scale(.96); }

/* ============================================================
   Forms
   ============================================================ */
.form-label { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 4px; }
.form-control, .form-select {
    border-radius: 8px;
    border-color: #d1d5db;
    font-size: 13.5px;
    padding: 8px 12px;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(var(--app-primary-rgb), .1);
}

/* ============================================================
   Toolbar
   ============================================================ */
.page-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.page-toolbar .filter-group {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
@media (max-width: 576px) {
    .page-toolbar { flex-direction: column; align-items: stretch; }
    .page-toolbar .filter-group { flex-direction: column; }
    .page-toolbar .filter-group .form-control,
    .page-toolbar .filter-group .form-select { width: 100%; }
}

/* ============================================================
   Detail View
   ============================================================ */
.detail-card .card-body { padding: 20px 24px; }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.detail-item .detail-label { font-size: 11px; color: #9ca3af; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; margin-bottom: 2px; }
.detail-item .detail-value { font-size: 14px; color: #1e293b; font-weight: 500; }

/* ============================================================
   Login
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
    width: 100%; max-width: 400px;
    border: none; border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-card .card-body { padding: 36px; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination .page-link {
    border-radius: 6px;
    margin: 0 2px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    border-color: #e5e7eb;
    padding: 5px 12px;
}
.pagination .page-item.active .page-link {
    background: var(--app-primary);
    border-color: var(--app-primary);
}

/* ============================================================
   Toast
   ============================================================ */
.toast { border: none; box-shadow: 0 4px 20px rgba(0,0,0,.12); border-radius: 10px; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp .3s ease; }

/* ============================================================
   Responsive helpers
   ============================================================ */
@media (max-width: 768px) {
    .stat-card .stat-value { font-size: 22px; }
    .detail-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 576px) {
    .detail-grid { grid-template-columns: 1fr; }
}
