/* ========== 全局重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body.admin-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
}

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

/* 侧边栏 */
.admin-sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon svg { width: 24px; height: 24px; color: #fff; }
.logo-text { font-size: 18px; font-weight: 600; }

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

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.3s;
    position: relative;
}

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

.nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    flex-shrink: 0;
}

.nav-text { flex: 1; }

.badge {
    background: #ff4757;
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

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

.admin-header {
    background: #fff;
    padding: 16px 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left .page-title {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a2e;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header-stats {
    display: flex;
    gap: 24px;
    padding-right: 24px;
    border-right: 1px solid #eee;
}

.stat-item {
    text-align: center;
    padding: 0 12px;
}

.stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.stat-item.warning .stat-value { color: #f39c12; }
.stat-item.danger .stat-value { color: #e74c3c; }

.stat-label {
    font-size: 12px;
    color: #888;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info { text-align: right; }
.user-name { display: block; font-weight: 500; color: #333; }
.user-role { display: block; font-size: 12px; color: #888; }

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.logout-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #888;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: #f0f2f5;
    color: #e74c3c;
}

.logout-btn svg { width: 18px; height: 18px; }

.admin-content {
    flex: 1;
    padding: 30px;
}

/* ========== 页面卡片 ========== */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
}

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

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 28px; height: 28px; color: #fff; }

.stat-icon.blue { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.stat-icon.green { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.stat-icon.orange { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.stat-icon.purple { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }

.stat-content h3 {
    font-size: 14px;
    color: #888;
    margin-bottom: 4px;
}

.stat-content .stat-number {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a2e;
}

.stat-content .stat-trend {
    font-size: 12px;
    color: #27ae60;
}

/* ========== 表格样式 ========== */
.table-container {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #f8f9fa;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e8e8e8;
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}

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

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

/* 状态标签 */
.status-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-normal { background: #e8f5e9; color: #2e7d32; }
.status-warning { background: #fff3e0; color: #e65100; }
.status-danger { background: #ffebee; color: #c62828; }
.status-disabled { background: #eceff1; color: #546e7a; }

/* 操作按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: #fff;
}

.btn-default {
    background: #f5f5f5;
    color: #555;
}

.btn-default:hover { background: #e8e8e8; }

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

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    background: #f5f5f5;
    color: #666;
    transition: all 0.2s;
}

.btn-icon:hover { background: #e8e8e8; color: #333; }
.btn-icon.danger:hover { background: #ffebee; color: #e74c3c; }
.btn-icon svg { width: 16px; height: 16px; }

/* ========== 表单样式 ========== */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group label .required {
    color: #e74c3c;
    margin-left: 4px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102,126,234,0.1);
}

.form-control[readonly] {
    background: #f8f9fa;
    color: #888;
}

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ========== 弹窗 ========== */
.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: 9999;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    transition: all 0.2s;
}

.modal-close:hover { background: #f0f0f0; color: #333; }

.modal-close svg { width: 20px; height: 20px; }

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ========== 扫码区域 ========== */
.scan-area {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
}

.scan-input-wrapper {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.scan-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
}

.scan-input:focus {
    outline: none;
    border-color: #667eea;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px 0;
}

.page-info {
    color: #888;
    font-size: 14px;
    margin-right: 16px;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    color: #555;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.page-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
}

.page-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ========== 条码二维码预览 ========== */
.barcode-preview {
    text-align: center;
    padding: 16px;
    background: #fff;
    border-radius: 8px;
}

.barcode-preview img {
    max-width: 100%;
    height: auto;
}

.barcode-text {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    margin-top: 8px;
    color: #333;
}

/* ========== 搜索/筛选区 ========== */
.filter-bar {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-bar .form-control {
    min-width: 200px;
}

/* ========== 打印样式 ========== */
@media print {
    body * { visibility: hidden; }
    .print-area, .print-area * { visibility: visible; }
    .print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    .no-print { display: none !important; }
}

/* ========== 响应式 ========== */
/* 汉堡按钮（默认隐藏，仅小屏幕显示） */
.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: 12px;
    border: none;
    background: #f5f5f5;
    border-radius: 8px;
    color: #1a1a2e;
    cursor: pointer;
    transition: all 0.2s;
}
.menu-toggle:hover { background: #e8e8e8; }
.menu-toggle:active { transform: scale(0.95); }

/* 侧边栏遮罩 */
.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 90; /* 低于 sidebar(100) 但高于内容 */
}
.sidebar-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* --- 平板/手机断点 --- */
@media (max-width: 900px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 20px rgba(0,0,0,0.25);
    }
    .admin-sidebar.is-open {
        transform: translateX(0);
    }
    .admin-main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .header-stats { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { gap: 10px; }
    .filter-bar .form-control { min-width: 0; flex: 1; }
    .admin-content { padding: 16px; }
    .card { padding: 16px; border-radius: 10px; }
    .page-title { font-size: 16px; }
    .user-info { display: none; }
    .header-right { gap: 12px; }
    .data-table th, .data-table td { padding: 10px 8px; font-size: 13px; }
    .btn { padding: 7px 12px; font-size: 13px; }
    .btn-sm { padding: 3px 8px; font-size: 12px; }
    .form-row { grid-template-columns: 1fr; gap: 12px; }
    .search-input {
        width: 100%;
        padding: 10px 12px;
        font-size: 14px;
    }
    .search-wrapper .btn {
        padding: 10px 16px;
    }
}

@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 16px; }
    .stat-icon { width: 46px; height: 46px; border-radius: 10px; }
    .stat-content .stat-number { font-size: 22px; }
    .table-container { -webkit-overflow-scrolling: touch; }
    .user-area { gap: 8px; }
    .user-avatar { width: 34px; height: 34px; font-size: 14px; }
    .admin-header { padding: 12px 16px; }
    .sidebar-header { padding: 16px; }
    .sidebar-nav { padding: 12px 8px; }
    .nav-item { padding: 11px 14px; }
    .logo-text { display: inline !important; } /* 抽屉状态下强制显示菜单文字 */
    .nav-text { display: inline !important; }
    .admin-sidebar { width: 260px; }
}

/* ========== 提示消息 ========== */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    z-index: 9999;
    animation: slideIn 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.toast.success { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.toast.error { background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%); }
.toast.warning { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.toast.info { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
