/* =============================================
   心理测评后台管理 - 样式表
   现代简洁风格，白色为主色调
   ============================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #4f46e5;
    --page-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--page-bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
}

/* ============ 整体布局 ============ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============ 侧边栏 ============ */
.sidebar {
    width: 200px;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 22px 20px;
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    letter-spacing: 1px;
}

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 12px 22px;
    color: #cbd5e1;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: #818cf8;
}

.sidebar-nav a .nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-nav a .nav-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.sidebar-footer {
    padding: 14px 20px;
    font-size: 12px;
    color: #64748b;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

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

.page-header {
    background: var(--card-bg);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.page-header .header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.content-body {
    padding: 20px;
    flex: 1;
}

/* ============ 卡片 ============ */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.stat-card .stat-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.stat-icon.bg-blue { background: var(--info); }
.stat-icon.bg-green { background: var(--success); }
.stat-icon.bg-orange { background: var(--warning); }
.stat-icon.bg-purple { background: var(--primary); }
.stat-icon.bg-red { background: var(--danger); }
.stat-icon.bg-cyan { background: #06b6d4; }

.stat-card .stat-info .stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-card .stat-info .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============ 表格 ============ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    font-size: 13px;
}

table.data-table th {
    background: #f8fafc;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

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

table.data-table tbody tr:last-child td {
    border-bottom: none;
}

table.data-table .thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

table.data-table .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 8px;
}

.text-muted {
    color: var(--text-muted);
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

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

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover {
    border-color: var(--text-muted);
    background: #f8fafc;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #059669;
    border-color: #059669;
    color: #fff;
}

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

.btn-block {
    width: 100%;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text);
    font-size: 13px;
}

.form-group label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text);
    background: var(--card-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

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

select.form-control {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ============ 开关 ============ */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #cbd5e1;
    border-radius: 24px;
    transition: 0.3s;
}

.switch .slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.switch input:checked + .slider {
    background: var(--success);
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* ============ 搜索栏 ============ */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.search-bar .form-control {
    width: auto;
    min-width: 220px;
}

.search-bar .spacer {
    flex: 1;
}

/* ============ 分页 ============ */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}

.pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination .current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination .disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

.pagination .page-info {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: default;
}

/* ============ 模态框 ============ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal {
    background: var(--card-bg);
    border-radius: 10px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

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

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

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

/* ============ 图片上传预览 ============ */
.upload-preview {
    width: 100px;
    height: 100px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    margin-top: 8px;
    position: relative;
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-preview .placeholder {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    padding: 8px;
}

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

.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 380px;
    padding: 36px 32px;
}

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

.login-logo .logo-icon {
    width: 60px;
    height: 60px;
    background: var(--primary);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.login-logo .logo-icon svg {
    width: 32px;
    height: 32px;
    fill: #fff;
}

.login-logo h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

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

.login-form .form-group {
    margin-bottom: 18px;
}

.login-form .btn {
    width: 100%;
    padding: 10px;
    font-size: 15px;
}

.login-alert {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 18px;
}

.login-tip {
    text-align: center;
    margin-top: 18px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ============ 提示消息 ============ */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: var(--text);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    font-size: 14px;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 360px;
}

.toast.show {
    transform: translateX(0);
}

.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }

/* ============ 工具类 ============ */
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 8px; }
.mt-2 { margin-top: 8px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.nowrap { white-space: nowrap; }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    fill: #cbd5e1;
    margin-bottom: 12px;
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-logo {
        font-size: 0;
        padding: 18px 0;
    }

    .sidebar-logo::first-letter {
        font-size: 17px;
    }

    .sidebar-nav a {
        padding: 14px 0;
        justify-content: center;
        border-left: none;
        border-right: 3px solid transparent;
    }

    .sidebar-nav a.active {
        border-right-color: #818cf8;
    }

    .sidebar-nav a span:not(.nav-icon) {
        display: none;
    }

    .main-content {
        margin-left: 60px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .content-body {
        padding: 14px;
    }

    .page-header {
        padding: 12px 16px;
    }

    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
    }

    .stat-card .stat-info .stat-value {
        font-size: 18px;
    }

    .search-bar .form-control {
        min-width: 150px;
    }
}

@media (max-width: 480px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }
}
