/* ==================================================
   全局样式 - 纯浅色主题（融合前后台所有样式）
   设计：现代、清晰、响应式
   ================================================== */

/* CSS 变量定义 */
:root {
    --bg-white: #ffffff;
    --bg-gray-50: #f8f9fa;
    --bg-gray-100: #f1f3f5;
    --bg-gray-200: #e9ecef;
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent-blue: #0066ff;
    --accent-blue-dark: #0044cc;
    --accent-blue-light: #3388ff;
    --accent-green: #00b67a;
    --accent-red: #ff4d4f;
    --accent-orange: #ff8c00;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.2s ease;
}

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

body {
    background: var(--bg-gray-50);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== 顶部导航栏（固定） ===== */
.top-nav {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-blue-dark) 100%);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
}

.top-nav::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(circle at 20% 40%, rgba(255,255,255,0.12) 1.5px, transparent 1.5px);
    background-size: 28px 28px;
    pointer-events: none;
}

.nav-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    position: relative;
    z-index: 2;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    text-decoration: none;
}

.logo i {
    font-size: 1.8rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.nav-links a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

.nav-links a:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

.search-form {
    display: flex;
    background: rgba(255,255,255,0.2);
    border-radius: 40px;
    padding: 4px 8px 4px 16px;
    backdrop-filter: blur(4px);
}

.search-form input {
    background: transparent;
    border: none;
    color: white;
    padding: 8px 8px;
    outline: none;
    width: 200px;
}

.search-form input::placeholder {
    color: rgba(255,255,255,0.7);
}

.search-form button {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 40px;
    transition: var(--transition);
}

.search-form button:hover {
    background: rgba(255,255,255,0.2);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    padding: 6px 12px 6px 16px;
    border-radius: 40px;
    cursor: pointer;
    transition: var(--transition);
}

.user-menu:hover {
    background: rgba(255,255,255,0.25);
}

.user-menu span {
    color: white;
    font-weight: 500;
}

.user-menu i {
    color: white;
}

/* 前台容器（避开固定顶栏） */
body:not(.admin-layout) .container {
    max-width: 1280px;
    margin: 112px auto 40px;
    padding: 0 24px;
    flex: 1;
}

/* ===== 页脚 ===== */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-light);
    padding: 40px 24px;
    margin-top: auto;
}

.footer-content {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--accent-blue);
}

/* ===== 卡片通用 ===== */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 28px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--accent-blue-light);
    box-shadow: var(--shadow-md);
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 40px;
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-blue-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,102,255,0.25);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-gray-50);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.btn-danger {
    background: var(--accent-red);
    color: white;
}

.btn-danger:hover {
    background: #ff7875;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

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

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    background: var(--bg-white);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0,102,255,0.1);
}

/* ===== 表格（统一美化） ===== */
.table-responsive {
    overflow-x: auto;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 800px;
}

th {
    text-align: left;
    padding: 14px 16px;
    background: var(--bg-gray-50);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-gray-50);
}

/* 操作列按钮组 */
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
}

/* 难度标签 */
.badge-difficulty {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    min-width: 56px;
}
.badge-difficulty-easy {
    background: #e6f7ec;
    color: #0a5c2e;
}
.badge-difficulty-medium {
    background: #fffbeb;
    color: #b45309;
}
.badge-difficulty-hard {
    background: #fee2e2;
    color: #b91c1c;
}

/* 通用徽章 */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 500;
}
.badge-primary {
    background: rgba(0,102,255,0.1);
    color: var(--accent-blue);
}
.badge-success {
    background: rgba(0,182,122,0.1);
    color: var(--accent-green);
}
.badge-warning {
    background: rgba(255,140,0,0.1);
    color: var(--accent-orange);
}
.badge-danger {
    background: rgba(255,77,79,0.1);
    color: var(--accent-red);
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}
.pagination a:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}
.pagination .active span {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* ===== 后台专用布局 ===== */
.admin-layout {
    display: flex;
    min-height: calc(100vh - 72px);
    background: #f3f4f6;
}
.admin-sidebar {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 72px;
    height: calc(100vh - 72px);
    overflow-y: auto;
}
.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #2563eb;
    background: #ffffff;
}
.admin-menu {
    list-style: none;
    padding: 16px 12px;
    margin: 0;
    flex: 1;
}
.admin-menu li {
    margin: 2px 0;
    border-radius: 12px;
}
.admin-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #1f2937;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.95rem;
}
.admin-menu li a i:first-child {
    width: 22px;
    text-align: center;
    color: #6b7280;
}
.admin-menu li.active > a,
.admin-menu li a:hover {
    background: #eff6ff;
    color: #2563eb;
}
.admin-menu li.active > a i:first-child,
.admin-menu li a:hover i:first-child {
    color: #2563eb;
}
.admin-menu li a .submenu-arrow {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.2s;
}
.admin-menu li a .submenu-arrow.rotated {
    transform: rotate(180deg);
}
.submenu {
    list-style: none;
    padding-left: 34px;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.admin-menu li.submenu-open .submenu {
    max-height: 500px;
}
.submenu li a {
    padding: 8px 16px;
    font-size: 0.85rem;
}
.submenu li a i {
    font-size: 0.5rem;
    width: 16px;
    color: #9ca3af;
}
.sidebar-footer {
    border-top: 1px solid #e5e7eb;
    padding: 16px 20px;
    margin-top: auto;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.user-info i {
    font-size: 2rem;
    color: #2563eb;
}
.username {
    font-weight: 600;
    color: #1f2937;
}
.user-role {
    font-size: 0.8rem;
    color: #6b7280;
}
.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #f3f4f6;
    color: #ef4444;
    padding: 8px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}
.logout-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

.admin-content {
    flex: 1;
    padding: 24px 28px;
    overflow-x: auto;
    background: #f3f4f6;
}
.admin-content .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}
.admin-content .page-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.admin-content .page-header h1 i {
    color: #2563eb;
    font-size: 1.6rem;
}
.admin-content .card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 20px 24px;
    margin-bottom: 28px;
}
.admin-content .filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}
.admin-content .filter-item {
    flex: 1 1 200px;
    min-width: 160px;
}
.admin-content .filter-item label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 6px;
    display: block;
}
.admin-content .filter-item select,
.admin-content .filter-item input {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.9rem;
    width: 100%;
}
.admin-content .filter-item select:focus,
.admin-content .filter-item input:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.admin-content .empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}
.admin-content .empty-state i {
    font-size: 3rem;
    color: #d1d5db;
    margin-bottom: 16px;
}
.admin-content .alert-success {
    background: #e6f7ec;
    border-left: 4px solid #10b981;
    padding: 12px 16px;
    border-radius: 16px;
    margin-bottom: 24px;
    color: #065f46;
}
.admin-content .alert-error {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    padding: 12px 16px;
    border-radius: 16px;
    margin-bottom: 24px;
    color: #991b1b;
}

/* 响应式 */
@media (max-width: 768px) {
    .admin-content {
        padding: 16px;
    }
    .admin-sidebar {
        width: 100%;
        position: static;
        height: auto;
    }
    .admin-content .page-header h1 {
        font-size: 1.4rem;
    }
    .action-buttons {
        flex-wrap: wrap;
        gap: 4px;
    }
    .btn-sm {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
    .table-responsive table {
        min-width: 700px;
    }
}

/* ===== 试题表单专用样式 ===== */
.type-toggle {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}
.type-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 40px;
    background: #f3f4f6;
    transition: all 0.2s;
}
.type-option.selected {
    background: #2563eb;
    color: white;
}
.type-option.selected label {
    color: white;
}
.latex-symbols {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.latex-symbol {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px 4px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}
.latex-symbol:hover {
    background: #e5e7eb;
    border-color: #2563eb;
}
.knowledge-tag {
    display: inline-flex;
    align-items: center;
    background: #e6f7ec;
    border: 1px solid #d1fae5;
    border-radius: 30px;
    padding: 4px 12px;
    margin: 4px;
    font-size: 0.85rem;
}
.knowledge-tag .remove {
    margin-left: 8px;
    color: #ef4444;
    cursor: pointer;
    font-weight: bold;
}
.image-preview-container {
    margin-top: 10px;
}
.image-preview {
    position: relative;
    display: inline-block;
}
.image-preview img {
    max-width: 200px;
    max-height: 150px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}
.image-preview .remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
}
.dimensions-table {
    background: #f9fafb;
    border-radius: 16px;
    padding: 16px;
    margin-top: 10px;
}
.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}
.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
#add-knowledge-panel {
    background: #f9fafb;
    padding: 16px;
    border-radius: 16px;
    margin-top: 12px;
}
.template-preview {
    background: #f9fafb;
    border-radius: 16px;
    padding: 16px;
    margin-top: 20px;
    font-family: monospace;
    font-size: 0.85rem;
}