/* ==================== 基础变量 ==================== */
:root {
    --primary: #27ae60;
    --primary-dark: #1e8449;
    --secondary: #3498db;
    --accent: #e74c3c;
    --dark: #2c3e50;
    --gray: #7f8c8d;
    --light: #ecf0f1;
    --white: #ffffff;
    --shadow: 0 4px 15px rgba(0,0,0,0.08);
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    color: var(--dark);
}

/* ==================== 布局 ==================== */
.admin-container { display: flex; min-height: 100vh; }

/* ==================== 侧边栏 ==================== */
.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    color: white;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.sidebar-header .admin-logo {
    height: 40px;
    width: auto;
    border-radius: 6px;
}

.sidebar-header .logo i { color: var(--primary); font-size: 24px; }
.sidebar-header p { font-size: 12px; opacity: 0.6; }

.sidebar-nav { flex: 1; padding: 16px 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: rgba(255,255,255,0.7);
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item.active { background: rgba(39,174,96,0.2); color: white; border-left-color: var(--primary); }
.nav-item i { width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.back-home {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    transition: all 0.3s;
}

.back-home:hover { color: white; }

/* ==================== 主内容区 ==================== */
.main-content { flex: 1; margin-left: 240px; }

.top-bar {
    background: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.breadcrumb i { color: var(--primary); }

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--light); color: var(--dark); }
.btn-secondary:hover { background: #dfe6e9; }
.btn-danger { background: var(--accent); color: white; }
.btn-danger:hover { background: #c0392b; }

/* ==================== Tab内容 ==================== */
.tab-content {
    display: none;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== 统计卡片 ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.stat-icon.blue { background: #e8f4fd; color: #3498db; }
.stat-icon.purple { background: #f4ecf7; color: #9b59b6; }
.stat-icon.orange { background: #fef5e7; color: #f39c12; }
.stat-icon.green { background: #e8f8f5; color: #27ae60; }

.stat-info h3 { font-size: 28px; font-weight: 700; }
.stat-info p { font-size: 13px; color: var(--gray); }

/* ==================== 快捷操作 ==================== */
.quick-actions-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.quick-actions-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.quick-actions-card h3 i { color: #f39c12; }

.quick-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.quick-btn.primary { background: #27ae60; color: white; }
.quick-btn.primary:hover { background: #1e8449; }
.quick-btn.purple { background: #9b59b6; color: white; }
.quick-btn.purple:hover { background: #8e44ad; }
.quick-btn.orange { background: #f39c12; color: white; }
.quick-btn.orange:hover { background: #d68910; }
.quick-btn.green { background: #3498db; color: white; }
.quick-btn.green:hover { background: #2980b9; }

/* ==================== 区块标题 ==================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header h2 i { color: var(--primary); }

/* ==================== 筛选栏 ==================== */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-box {
    flex: 1;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

.search-box input {
    width: 100%;
    padding: 12px 12px 12px 42px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.search-box input:focus { border-color: var(--primary); outline: none; }

.filter-bar select {
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

/* ==================== 表格 ==================== */
.table-container {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray);
    text-transform: uppercase;
}

.data-table tbody tr:hover { background: #f8f9fa; }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .thumb {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
}

.data-table .price { color: var(--accent); font-weight: 600; }

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.onSale { background: #d4edda; color: #155724; }
.status-badge.offSale { background: #f8d7da; color: #721c24; }

.action-btns { display: flex; gap: 8px; }

.action-btn {
    padding: 8px 14px;
    font-size: 13px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.action-btn.edit { background: #e8f4fd; color: #3498db; }
.action-btn.edit:hover { background: #3498db; color: white; }
.action-btn.delete { background: #fce4ec; color: #e91e63; }
.action-btn.delete:hover { background: #e91e63; color: white; }

/* ==================== 卡片网格 ==================== */
.categories-admin-grid,
.banners-grid,
.promotions-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.category-admin-card,
.banner-admin-card,
.promotion-admin-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.category-admin-card:hover,
.banner-admin-card:hover,
.promotion-admin-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

.card-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.category-admin-card .card-image { height: 80px; }

.category-admin-card .card-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 12px;
    display: block;
}

.card-body { padding: 16px; }
.card-body h4 { font-size: 15px; margin-bottom: 6px; }
.card-body > p { font-size: 13px; color: var(--gray); margin-bottom: 12px; }

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.card-footer .order { font-size: 12px; color: var(--gray); }

.card-actions { display: flex; gap: 8px; }

.card-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.card-btn.edit { background: #e8f4fd; color: #3498db; }
.card-btn.edit:hover { background: #3498db; color: white; }
.card-btn.delete { background: #fce4ec; color: #e91e63; }
.card-btn.delete:hover { background: #e91e63; color: white; }

/* ==================== 表单 ==================== */
.form-layout {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 24px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-item { margin-bottom: 16px; }

.form-item label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-item .required { color: var(--accent); }

.form-item input[type="text"],
.form-item input[type="number"],
.form-item input[type="url"],
.form-item input[type="datetime-local"],
.form-item select,
.form-item textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.form-item input:focus,
.form-item select:focus,
.form-item textarea:focus {
    border-color: var(--primary);
    outline: none;
}

.radio-group,
.checkbox-group { display: flex; gap: 20px; flex-wrap: wrap; }

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.radio-label input,
.checkbox-label input { accent-color: var(--primary); }

/* ==================== 图片上传 ==================== */
.image-upload-box {
    width: 160px;
    height: 160px;
    border: 2px dashed #ddd;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    overflow: hidden;
    position: relative;
}

.image-upload-box:hover { border-color: var(--primary); background: rgba(39,174,96,0.05); }
.image-upload-box.wide { width: 100%; height: 180px; }

.image-upload-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-placeholder {
    text-align: center;
    color: var(--gray);
}

.upload-placeholder i { font-size: 36px; margin-bottom: 8px; }
.upload-placeholder p { font-size: 13px; margin-bottom: 4px; }
.upload-placeholder span { font-size: 11px; }

.image-upload-single {
    width: 80px;
    height: 80px;
    border: 2px dashed #ddd;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    overflow: hidden;
}

.image-upload-single:hover { border-color: var(--primary); }
.image-upload-single img { width: 100%; height: 100%; object-fit: cover; }
.image-upload-single .upload-placeholder i { font-size: 24px; }

/* ==================== 弹窗 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active { display: flex; }

.modal-dialog {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    animation: modalIn 0.3s ease;
}

.modal-dialog.modal-sm { max-width: 400px; }
.modal-dialog.modal-lg { max-width: 800px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i { color: var(--primary); }

.close-modal {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray);
    cursor: pointer;
}

.close-modal:hover { color: var(--dark); }

.modal-body {
    padding: 24px;
    max-height: calc(90vh - 130px);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #eee;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 16px 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 8px 30px rgba(39, 174, 96, 0.4);
    font-size: 15px;
    font-weight: 500;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast i {
    font-size: 20px;
}

/* ==================== 响应式 ==================== */
@media (max-width: 1024px) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-layout { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .quick-buttons { flex-direction: column; }
    .quick-btn { justify-content: center; }
}
