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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: #333;
    background: #f5f6fa;
    line-height: 1.6;
}

/* ========== 登录页 ========== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    width: 380px;
}

.login-box h1 {
    text-align: center;
    font-size: 24px;
    color: #333;
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    color: #999;
    margin-bottom: 24px;
}

/* ========== 布局（所有页共用） ========== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 200px;
    background: #1e1e2d;
    color: #a2a3b7;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 20px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #2b2b40;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: #a2a3b7;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
}

.nav-item:hover {
    background: #2b2b40;
    color: #fff;
}

.nav-item.active {
    background: #3699ff;
    color: #fff;
}

.nav-icon { font-size: 16px; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #2b2b40;
    font-size: 13px;
}

.user-badge { color: #a2a3b7; }

/* 主区域 */
.main-area {
    margin-left: 200px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 顶部栏 */
.topbar {
    background: #fff;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* 内容区 */
.content {
    padding: 24px;
    flex: 1;
    background: #e8f5e9;
}

/* ========== 公共组件 ========== */

/* 卡片 */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.dashboard-welcome {
    background: #fff;
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.dashboard-welcome h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #333;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    text-decoration: none;
    transition: all 0.2s;
}

.btn:hover { background: #f5f5f5; }

.btn-primary {
    background: #3699ff;
    border-color: #3699ff;
    color: #fff;
}
.btn-primary:hover { background: #1d8cf8; }

.btn-block { display: block; width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #3699ff;
    box-shadow: 0 0 0 3px rgba(54,153,255,0.15);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* 表格 */
.table {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-collapse: collapse;
}

.table th {
    background: #f8f9fc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e2e8f0;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.table tr:hover td { background: #f8f9fc; }

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

/* 徽章 */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #e6f7e6; color: #2e7d32; }
.badge-danger { background: #ffe6e6; color: #c62828; }

/* 提示 */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error { background: #ffe6e6; color: #c62828; border: 1px solid #ffcdd2; }
.alert-success { background: #e6f7e6; color: #2e7d32; border: 1px solid #c8e6c9; }

/* 工具栏 */
.toolbar {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

/* ========== 通用 Toast 提示 ========== */
.toast {
    display: none;
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 3000;
    max-width: 80vw;
}

.toast.success { background: #2e7d32; }
.toast.error { background: #c62828; }

/* ========== 通用图片大图预览 ========== */
.img-viewer {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.img-viewer.show { display: flex; }

.img-viewer img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 6px;
}

.img-viewer .close-viewer {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
}

.img-viewer .close-viewer:hover { color: #ccc; }

/* ========== 通用页面级弹窗 ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px;
}

.modal-overlay.show { display: flex; }

.modal {
    background: #fff;
    border-radius: 10px;
    width: 560px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

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

.modal-header h3 { font-size: 17px; font-weight: 500; }

.modal-body { padding: 20px; }

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

.pagination button {
    padding: 6px 14px;
    border: 1px solid #d0d0d0;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.pagination button:hover:not(:disabled) { border-color: #3699ff; color: #3699ff; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button.active { background: #3699ff; color: #fff; border-color: #3699ff; }

/* ========== 通用搜索栏 ========== */
.search-bar {
    background: #fff;
    padding: 16px 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.search-bar input {
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    width: 200px;
}

.search-bar input:focus {
    outline: none;
    border-color: #3699ff;
    box-shadow: 0 0 0 2px rgba(54,153,255,0.15);
}

.search-bar input::placeholder { color: #aaa; }

/* ========== 通用信息栏 ========== */
.info-bar {
    padding: 8px 0;
    color: #888;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

/* ========== 通用表格包装 ========== */
.table-wrap {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

.data-table th {
    background: #fafafa;
    text-align: center;
    padding: 10px 8px;
    font-weight: 500;
    font-size: 13px;
    color: #555;
    border-bottom: 2px solid #e8e8e8;
    white-space: nowrap;
}

.data-table td {
    padding: 6px 8px;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f0;
    text-align: center;
    vertical-align: middle;
}

.data-table tr:hover td { background: #f8faff; }

.data-table td.img-cell img {
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #e0e0e0;
    transition: transform 0.15s;
}

.data-table td.img-cell img:hover { transform: scale(1.05); }

.data-table td.img-cell .no-img {
    display: inline-block;
    color: #ccc;
    font-size: 12px;
    background: #fafafa;
    border-radius: 4px;
    border: 1px solid #eee;
}

/* 操作按钮链接 */
.action-links a {
    color: #3699ff;
    cursor: pointer;
    margin-right: 10px;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}

.action-links a.del { color: #e53935; }
.action-links a:hover { text-decoration: underline; }

/* 加载中 */
.loading { text-align: center; padding: 40px; color: #999; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-brand { font-size: 0; padding: 20px 10px; }
    .nav-item span:not(.nav-icon) { display: none; }
    .nav-icon { font-size: 20px; }
    .sidebar-footer { display: none; }
    .main-area { margin-left: 60px; }
}
