/* ============================================================
   采购管理系统 - 全局样式
   ============================================================ */

:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --header-height: 60px;
    --content-bg: #f1f5f9;
    --primary: #3b82f6;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
    background: var(--content-bg);
    color: var(--text-dark);
    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;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar .sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid #334155;
}

.sidebar .sidebar-header h5 {
    color: #fff;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.sidebar .sidebar-header .subtitle {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}

.sidebar .nav-section {
    padding: 10px 0;
}

.sidebar .nav-section-title {
    padding: 8px 20px;
    font-size: 11px;
    text-transform: uppercase;
    color: #475569;
    letter-spacing: 1px;
    font-weight: 600;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 14px;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.sidebar .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: #60a5fa;
}

.sidebar .nav-link i {
    width: 20px;
    margin-right: 10px;
    text-align: center;
}

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

.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ==================== 顶部栏 ==================== */
.topbar {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar .toggle-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-dark);
    padding: 5px 10px;
    display: none;
}

.topbar .breadcrumb {
    margin: 0;
    background: none;
    padding: 0;
    font-size: 14px;
}

.topbar .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar .user-dropdown {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* ==================== 内容区 ==================== */
.content-wrapper {
    padding: 20px;
    flex: 1;
}

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

.page-header h4 {
    margin: 0;
    font-weight: 600;
    color: var(--text-dark);
}

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

/* ==================== 卡片 ==================== */
.card {
    border: none;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 15px 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

/* ==================== 统计卡片 ==================== */
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s;
}

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

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    flex-shrink: 0;
}

.stat-card .stat-icon.bg-primary { background: var(--primary); }
.stat-card .stat-icon.bg-success { background: var(--success); }
.stat-card .stat-icon.bg-warning { background: var(--warning); }
.stat-card .stat-icon.bg-danger { background: var(--danger); }
.stat-card .stat-icon.bg-info { background: var(--info); }
.stat-card .stat-icon.bg-purple { background: #8b5cf6; }

.stat-card .stat-info { flex: 1; min-width: 0; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-card .stat-label { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

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

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

table.data-table thead th {
    background: #f8fafc;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

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

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

table.data-table .product-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
}

table.data-table .action-btns {
    white-space: nowrap;
}

table.data-table .action-btns .btn {
    padding: 3px 8px;
    font-size: 12px;
}

/* ==================== 表单 ==================== */
.form-label { font-weight: 500; margin-bottom: 5px; font-size: 13px; }
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(59,130,246,0.15);
}

/* ==================== 徽章 ==================== */
.badge {
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
}

/* ==================== 分页 ==================== */
.pagination { justify-content: center; margin-top: 20px; }
.pagination .page-link { color: var(--primary); border: 1px solid var(--border); }
.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ==================== 登录页 ==================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #3b82f6 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 100%;
    padding: 40px;
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-card .login-logo h3 {
    margin: 0;
    font-weight: 700;
    color: var(--text-dark);
}

.login-card .login-logo p {
    color: var(--text-muted);
    margin-top: 5px;
    font-size: 13px;
}

.login-card .form-control { height: 45px; }
.login-card .btn-primary { height: 45px; font-weight: 600; }

/* ==================== Toast 通知 ==================== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    max-width: 350px;
}

.toast-item {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 15px 20px;
    margin-bottom: 10px;
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    cursor: pointer;
}

.toast-item.success { border-left-color: var(--success); }
.toast-item.error { border-left-color: var(--danger); }
.toast-item.warning { border-left-color: var(--warning); }
.toast-item.info { border-left-color: var(--info); }

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

/* ==================== 模态框 ==================== */
.modal-dialog { max-width: 700px; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 600; }

/* ==================== 加载遮罩 ==================== */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

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

.empty-state i { font-size: 48px; margin-bottom: 15px; opacity: 0.3; }
.empty-state h5 { color: var(--text-muted); }

/* ==================== 工具类 ==================== */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }

.cursor-pointer { cursor: pointer; }
.no-wrap { white-space: nowrap; }
.text-sm { font-size: 12px; }
.text-md { font-size: 14px; }
.text-lg { font-size: 16px; }

.bg-light-blue { background: #eff6ff; }
.bg-light-green { background: #f0fdf4; }
.bg-light-red { background: #fef2f2; }
.bg-light-yellow { background: #fffbeb; }

.border-radius-8 { border-radius: 8px; }

/* ==================== 响应式 ==================== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .topbar .toggle-btn {
        display: block;
    }
}

@media (max-width: 768px) {
    .content-wrapper { padding: 15px; }
    .stat-card .stat-value { font-size: 20px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .modal-dialog { margin: 10px; }
}

/* ==================== 打印样式 ==================== */
@media print {
    .sidebar, .topbar, .page-actions, .btn { display: none !important; }
    .main-wrapper { margin-left: 0; }
    .content-wrapper { padding: 0; }
}
