/* ===== 珍爱姐AI 管理系统 - 公共样式 ===== */
:root {
    --primary: #1B6AEE; --primary-light: #3D84F5; --primary-dark: #1554C0; --accent: #5BA3F8;
    --bg-card: #ffffff; --bg-card-hover: #F2F6FC; --border: #D4DDE8;
    --text: #101820; --text-secondary: #3A4A5C; --text-muted: #6B7D93;
    --success: #16a34a; --warning: #d97706; --danger: #dc2626;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06); --glass: #ffffff;
}

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

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #F2F5F9;
    min-height: 100vh; color: var(--text); overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-weight: 400;
}

.grid-bg { display: none; }

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 14px; color: var(--text); margin-bottom: 8px; font-weight: 600; }

.form-input {
    width: 100%; padding: 12px 16px; background: #F5F8FC; border: 1px solid var(--border);
    border-radius: 12px; color: var(--text); font-size: 14px;
    transition: all 0.3s ease; outline: none; font-family: inherit;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(38, 126, 240, 0.12); }
.form-input::placeholder { color: var(--text-muted); }
textarea.form-input { resize: vertical; min-height: 80px; }

.form-select {
    width: 100%; padding: 12px 16px; background: #F5F8FC; border: 1px solid var(--border);
    border-radius: 12px; color: var(--text); font-size: 14px;
    transition: all 0.3s ease; outline: none; cursor: pointer;
    appearance: none; font-family: inherit;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234A6078' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 16px center;
}
.form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(38, 126, 240, 0.12); }
.form-select option { background: #ffffff; color: var(--text); }

/* ===== 响应式网格（移动端自动单列） ===== */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ===== Buttons ===== */
.btn {
    padding: 11px 22px; border-radius: 10px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s ease; border: none; font-family: inherit;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary {
    width: 100%; background: var(--primary);
    color: white; box-shadow: 0 2px 8px rgba(27, 106, 238, 0.25);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(27, 106, 238, 0.35); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    padding: 8px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.3s ease; border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--primary); color: var(--primary); }

.btn-sm {
    padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.3s ease; border: 1px solid var(--border);
    background: var(--bg-card); font-family: inherit;
}
.btn-danger {
    background: #ef4444; border: 1px solid #ef4444; color: white;
    padding: 8px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.3s ease; font-family: inherit;
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: white; }
.btn-success {
    background: #22c55e; border: 1px solid #22c55e; color: white;
    padding: 8px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.3s ease; font-family: inherit;
}
.btn-warning {
    background: #f59e0b; border: 1px solid #f59e0b; color: white;
    padding: 8px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.3s ease; font-family: inherit;
}

/* ===== Layout ===== */
.app-container { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px;
    background: #ffffff;
    border-right: 1px solid var(--border); padding: 24px 16px;
    display: flex; flex-direction: column; z-index: 100; overflow-y: auto;
}
.sidebar-logo { padding: 0 8px 20px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.sidebar-logo h2 {
    font-size: 18px; font-weight: 700;
    background: linear-gradient(135deg, #1B5AC8 0%, #5BA3F8 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.nav-menu { flex: 1; }

.nav-item {
    display: flex; align-items: center; padding: 11px 12px; border-radius: 10px;
    color: var(--text); cursor: pointer; transition: all 0.2s ease;
    margin-bottom: 2px; font-size: 14px; text-decoration: none; gap: 10px; font-weight: 500;
}
.nav-item:hover { background: rgba(27, 106, 238, 0.06); color: var(--primary); }
.nav-item.active {
    background: rgba(27, 106, 238, 0.08);
    color: var(--primary); font-weight: 600;
}
.nav-icon { width: 18px; height: 18px; opacity: 0.7; flex-shrink: 0; }
.nav-item.active .nav-icon { opacity: 1; }

.nav-group { margin-bottom: 4px; }
.nav-group-title {
    display: flex; align-items: center; padding: 11px 12px; border-radius: 10px;
    color: var(--text-secondary); font-size: 14px; cursor: pointer; font-weight: 500;
    transition: all 0.2s ease; gap: 10px;
}
.nav-group-title:hover { background: rgba(27, 106, 238, 0.04); color: var(--text); }
.nav-group-text { flex: 1; }
.nav-arrow { width: 14px; height: 14px; transition: transform 0.3s ease; }
.nav-group.expanded .nav-arrow { transform: rotate(180deg); }
.nav-sub-items { overflow: hidden; }
.nav-sub-items.hidden { display: none; }
.nav-sub-item { padding-left: 36px !important; font-size: 13px !important; }

.sidebar-user {
    padding: 12px; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, #267EF0 0%, #5BA3F8 100%);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px; color: white;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout {
    padding: 6px 12px; background: transparent; border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-secondary); font-size: 12px;
    cursor: pointer; transition: all 0.3s ease;
}
.btn-logout:hover { background: var(--danger); border-color: var(--danger); color: white; }

.main-content {
    margin-left: 260px; padding: 32px 40px;
    min-height: 100vh; width: calc(100% - 260px); max-width: 100%;
}

.page-header { margin-bottom: 28px; }
.page-title { font-size: 26px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: 14px; }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; padding: 22px; transition: all 0.2s ease;
    cursor: pointer; position: relative; overflow: hidden;
}
.stat-card:hover {
    background: var(--bg-card-hover); border-color: rgba(27, 106, 238, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.stat-label { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; font-weight: 500; }
.stat-value {
    font-size: 28px; font-weight: 700; color: var(--text);
}
.stat-icon {
    position: absolute; top: 16px; right: 16px;
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary); font-size: 20px;
}

/* ===== Content Cards ===== */
.content-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04); width: 100%;
}
.card-header {
    padding: 20px 28px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: #F8FAFC; flex-wrap: wrap; gap: 12px;
}
.card-header .btn { width: auto; }
.card-title { font-size: 16px; font-weight: 700; color: var(--text); }
.card-body { padding: 20px 28px; }

/* ===== Data Table ===== */
.table-wrap {
    border: 1px solid var(--border); border-radius: 12px;
    overflow-x: auto; overflow-y: hidden; background: white;
    -webkit-overflow-scrolling: touch;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: #F5F7FA; }
.data-table th {
    padding: 11px 14px; text-align: left; font-size: 13px; font-weight: 600;
    color: var(--text); letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td {
    padding: 12px 14px; font-size: 14px; color: var(--text);
    border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap;
}
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: #F7F9FC; }

/* ===== Toolbar ===== */
.list-toolbar {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.toolbar-field { min-width: 180px; }
.toolbar-field .form-input, .toolbar-field .form-select { padding: 9px 12px; font-size: 13px; border-radius: 10px; }
.list-toolbar .btn, .list-toolbar .btn-primary { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 10px; white-space: nowrap; }

/* ===== Pagination ===== */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 28px; border-top: 1px solid var(--border);
    background: #F8FAFC; flex-wrap: wrap; gap: 12px;
}
.pagination-info { color: var(--text-muted); font-size: 13px; }
.pagination-btns { display: flex; gap: 8px; align-items: center; }
.page-btn {
    min-width: 40px; height: 36px; padding: 0 14px; border-radius: 8px;
    border: 1px solid var(--border); background: #ffffff; color: var(--text);
    cursor: pointer; transition: all 0.2s ease; display: flex;
    align-items: center; justify-content: center; font-size: 14px; font-weight: 500;
}
.page-btn:hover:not(:disabled) { background: var(--primary); border-color: var(--primary); color: white; }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.page-input { width: 56px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; text-align: center; }
.page-input:focus { outline: none; border-color: var(--primary); }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #ffffff; border: 1px solid var(--border); border-radius: 16px;
    width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
    animation: modalIn 0.25s ease; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: min(95vw, 1200px); }
.modal-header {
    padding: 16px 24px; background: var(--primary);
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
}
.modal-header h3 { font-size: 16px; font-weight: 700; margin: 0; color: #fff; }
.modal-close {
    width: 30px; height: 30px; border-radius: 8px; border: none;
    background: rgba(255,255,255,0.2); color: #fff; cursor: pointer;
    font-size: 18px; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease;
}
.modal-close:hover { background: rgba(255,255,255,0.35); }
.modal-body { padding: 24px; }
.modal-actions {
    padding: 14px 24px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
}
.modal-actions .btn { width: auto; }

/* ===== Toast ===== */
.toast-container {
    position: fixed; top: 20px; right: 20px; display: flex; flex-direction: column;
    gap: 10px; z-index: 2000; pointer-events: none; max-width: min(360px, calc(100vw - 32px));
}
.toast {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px;
    border-radius: 14px; background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(34, 197, 94, 0.22);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14); color: var(--text);
    transform: translate3d(0, -10px, 0); opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease; pointer-events: auto;
}
.toast-visible { opacity: 1; transform: translate3d(0, 0, 0); }
.toast-leaving { opacity: 0; transform: translate3d(0, -8px, 0); }
.toast-error { border-color: rgba(239, 68, 68, 0.28); }
.toast-icon { width: 26px; height: 26px; flex-shrink: 0; border-radius: 999px; display: flex; align-items: center; justify-content: center; background: rgba(34, 197, 94, 0.12); color: var(--success); }
.toast-error .toast-icon { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.toast-icon svg { width: 14px; height: 14px; display: block; }
.toast-body { flex: 1; font-size: 13px; line-height: 1.4; word-break: break-word; }
.toast-close {
    width: 22px; height: 22px; flex-shrink: 0; border: none; border-radius: 999px;
    background: rgba(148, 163, 184, 0.14); color: var(--text-secondary);
    cursor: pointer; font-size: 14px; line-height: 1;
}
.toast-close:hover { background: rgba(148, 163, 184, 0.22); }

/* ===== Misc ===== */
.hidden { display: none !important; }
.section { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.error-message { color: var(--danger); margin-top: 14px; text-align: center; font-size: 13px; }
.status-success { color: var(--success); font-weight: 600; }
.status-danger { color: var(--danger); font-weight: 600; }
.status-warning { color: var(--warning); font-weight: 600; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge-success { background: rgba(22, 163, 74, 0.1); color: #15803d; }
.badge-danger { background: rgba(220, 38, 38, 0.1); color: #b91c1c; }
.badge-warning { background: rgba(217, 119, 6, 0.1); color: #b45309; }
.badge-info { background: rgba(27, 106, 238, 0.1); color: #1554C0; }
.btn-action {
    padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.15s ease; border: 1px solid var(--border);
    background: #ffffff; color: var(--text-secondary); font-family: inherit; white-space: nowrap;
}
.btn-action:hover { background: var(--primary); border-color: var(--primary); color: white; }
.image-preview { width: 120px; height: 120px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); margin-top: 8px; }
.loading-spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }

/* File upload button */
.file-upload-wrap {
    position: relative; display: inline-flex; align-items: center; gap: 10px;
}
.file-upload-btn {
    padding: 10px 20px; border-radius: 10px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.2s ease;
    border: 1px dashed var(--primary); background: rgba(38,126,240,0.04);
    color: var(--primary); font-family: inherit; display: inline-flex;
    align-items: center; gap: 6px; white-space: nowrap;
}
.file-upload-btn:hover { background: rgba(38,126,240,0.1); border-style: solid; }
.file-upload-btn svg { width: 16px; height: 16px; }
.file-upload-input {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}
.file-upload-name { font-size: 12px; color: var(--text-muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Mobile ===== */
.menu-toggle {
    display: none; position: fixed; top: 14px; left: 14px; z-index: 200;
    width: 42px; height: 42px; border-radius: 10px; background: #ffffff;
    border: 1px solid var(--border); cursor: pointer; align-items: center;
    justify-content: center; box-shadow: 0 4px 12px rgba(38, 126, 240, 0.15);
}
.menu-toggle svg { width: 20px; height: 20px; color: var(--primary); }
.menu-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 99; }

@media (max-width: 768px) {
    .menu-toggle { display: flex; }
    .menu-overlay.active { display: block; }
    .sidebar { transform: translateX(-100%); width: 260px; transition: transform 0.3s ease; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; width: 100%; padding: 66px 16px 20px; }
    .page-header { margin-bottom: 18px; }
    .page-title { font-size: 22px; }
    .page-subtitle { font-size: 13px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .card-header { padding: 14px 16px; }
    .card-body { padding: 14px 16px; }
    .list-toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left { flex-direction: column; align-items: stretch; }
    .toolbar-field { min-width: auto; }
    .list-toolbar .btn, .list-toolbar .btn-primary { width: 100%; }
    .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
    .pagination { padding: 12px 16px; }
    .pagination-btns { flex-wrap: wrap; }
    .modal { width: calc(100% - 24px); max-height: 85vh; }
    .modal-header { padding: 14px 16px; }
    .modal-body { padding: 16px; }
    .modal-actions { padding: 12px 16px; flex-wrap: wrap; }
}
