/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90d9;
    --primary-dark: #357abd;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #666666;
    --border-color: #e0e0e0;
    --sidebar-width: 250px;
    --header-height: 60px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

/* 通用样式 */
.hidden {
    display: none !important;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

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

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
}

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

.login-container {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
    margin: 20px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 10px;
}

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

.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

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

/* 主页面布局 */
#main-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 顶部导航 */
.header {
    height: var(--header-height);
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-color);
    padding: 5px;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

#user-info {
    color: var(--text-muted);
    font-size: 14px;
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 99;
    overflow-y: auto;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    font-size: 16px;
    color: var(--text-muted);
}

.menu-list {
    list-style: none;
    padding: 10px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-color);
}

.menu-item:hover {
    background-color: rgba(74, 144, 217, 0.1);
    color: var(--primary-color);
}

.menu-item.active {
    background-color: rgba(74, 144, 217, 0.15);
    color: var(--primary-color);
    border-right: 3px solid var(--primary-color);
}

.menu-item i {
    width: 20px;
    text-align: center;
}

/* 遮罩层 */
.overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 98;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 内容区域 */
.main-content {
    margin-top: var(--header-height);
    margin-left: 0;
    padding: 20px;
    min-height: calc(100vh - var(--header-height));
    transition: margin-left 0.3s;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.section-header h2 {
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 14px;
    min-width: 200px;
}

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

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-card i {
    font-size: 40px;
    color: var(--primary-color);
    opacity: 0.8;
}

.stat-info h3 {
    font-size: 28px;
    color: var(--text-color);
}

.stat-info p {
    color: var(--text-muted);
    font-size: 14px;
}

/* 最近更新 */
.recent-updates {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.recent-updates h3 {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recent-item {
    padding: 12px;
    background: var(--bg-color);
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 表格 */
.table-container {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow-x: auto;
}

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

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--bg-color);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
}

.data-table tr:hover {
    background-color: rgba(74, 144, 217, 0.05);
}

.data-table .avatar-cell img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.data-table .actions {
    display: flex;
    gap: 5px;
}

/* 树形图容器 */
.tree-container,
.baota-container {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    height: calc(100vh - 200px);
    overflow: auto;
    position: relative;
}

#tree-canvas,
#baota-canvas {
    min-width: 100%;
    min-height: 100%;
    padding: 20px;
}

/* 卡片 */
.card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.card h3 {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card p {
    color: var(--text-muted);
    margin-bottom: 15px;
}

/* 导入导出 */
.import-export-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* 照片网格 */
.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.photo-item:hover img {
    transform: scale(1.05);
}

.photo-item .photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 10px;
    color: white;
    font-size: 12px;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
}

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

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

.avatar-upload {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar-upload img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 5px;
    z-index: 2000;
    animation: toastSlideUp 0.3s ease;
}

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* PC端样式 */
@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: var(--sidebar-width);
    }
    
    .menu-btn {
        display: none;
    }
    
    .overlay {
        display: none;
    }
}

/* 平板适配 */
@media (max-width: 1023px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* 手机适配 */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .header-title {
        font-size: 16px;
    }
    
    #user-info {
        display: none;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .section-actions {
        width: 100%;
    }
    
    .search-input {
        flex: 1;
        min-width: 0;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
    
    .login-container {
        padding: 30px 20px;
        margin: 15px;
    }
    
    .login-header h1 {
        font-size: 24px;
    }
    
    .modal-content {
        max-height: 95vh;
        margin: 10px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .photos-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .import-export-container {
        grid-template-columns: 1fr;
    }
}

/* 小屏幕手机 */
@media (max-width: 480px) {
    .header {
        padding: 0 10px;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-card i {
        font-size: 30px;
    }
    
    .stat-info h3 {
        font-size: 22px;
    }
    
    .photos-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .btn {
        padding: 8px 15px;
        font-size: 13px;
    }
}
