/* 现代化 iOS 26 风格管理后台主题 */
:root {
    /* 主色调 - 苹果蓝 */
    --primary-color: #007AFF;      /* iOS Blue */
    --primary-light: #47a3ff;
    --primary-dark: #005ecb;
    
    /* 辅助色 */
    --secondary-color: #5856D6;   /* iOS Purple */
    --accent-color: #FF2D55;      /* iOS Pink */
    --warning-color: #FF9500;     /* iOS Orange */
    --danger-color: #FF3B30;      /* iOS Red */
    --success-color: #34C759;     /* iOS Green */
    --teal-color: #5AC8FA;        /* iOS Teal */
    --indigo-color: #5856D6;      /* iOS Indigo */
    
    /* 中性色 */
    --gray-50: #F2F2F7;           /* iOS System Gray 6 */
    --gray-100: #E5E5EA;          /* iOS System Gray 5 */
    --gray-200: #D1D1D6;          /* iOS System Gray 4 */
    --gray-300: #C7C7CC;          /* iOS System Gray 3 */
    --gray-400: #AEAEB2;          /* iOS System Gray 2 */
    --gray-500: #8E8E93;          /* iOS System Gray */
    --gray-600: #636366;
    --gray-700: #48484A;
    --gray-800: #3A3A3C;
    --gray-900: #1C1C1E;
    
    /* 背景色 */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F2F2F7;      /* iOS System Grouped Background */
    --bg-tertiary: #FFFFFF;
    --bg-glass: rgba(255, 255, 255, 0.8); /* 玻璃拟态背景 */
    
    /* 文字色 */
    --text-primary: #000000;
    --text-secondary: #8E8E93;    /* iOS Label Secondary */
    --text-tertiary: #C7C7CC;     /* iOS Label Tertiary */
    
    /* 边框色 */
    --border-light: rgba(60, 60, 67, 0.12); /* iOS Separator - Opaque */
    --border-medium: rgba(60, 60, 67, 0.36);
    
    /* 阴影 - 更柔和 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.12);
    
    /* 圆角 - 更圆润 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* 间距 */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* 字体 */
    --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 15px;
}

/* 玻璃拟态效果 */
.glass-effect {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* 顶部导航栏 - 沉浸式 */
.header {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
    padding: 0 var(--spacing-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    z-index: 1000;
}

.logo {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    letter-spacing: -0.5px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--gray-200);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    font-weight: 500;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 侧边栏 - iOS 侧边栏风格 */
.sidebar {
    position: fixed;
    left: 0;
    top: 64px;
    width: 260px;
    height: calc(100vh - 64px);
    background: rgba(242, 242, 247, 0.8); /* iOS Sidebar Background */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 10px;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.nav-item.active {
    background-color: var(--bg-primary); /* iOS Selected Item - White */
    color: var(--primary-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.nav-item i {
    width: 24px;
    margin-right: 10px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.nav-item.active i {
    color: var(--primary-color);
}

.nav-badge {
    background: var(--danger-color);
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: auto;
    min-width: 20px;
    text-align: center;
    font-weight: 600;
}

/* 主内容区 */
.main-content {
    margin-left: 260px;
    margin-top: 64px;
    padding: var(--spacing-xl);
    min-height: calc(100vh - 64px);
    max-width: none;
    width: calc(100vw - 260px);
    background-color: var(--bg-secondary);
}

/* 内容头部 */
.content-header {
    margin-bottom: var(--spacing-lg);
    display: flex;
    flex-direction: column;
}

.content-title {
    font-size: 2rem; /* iOS Large Title */
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    letter-spacing: -0.5px;
}

.content-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* 操作栏 */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    gap: var(--spacing-md);
    background: transparent;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
    max-width: 400px;
}

.action-buttons {
    display: flex;
    gap: var(--spacing-md);
}

/* 统计卡片 - iOS Widget 风格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    width: 100%;
}

.stat-card {
    background: var(--bg-primary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    border: none;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

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

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px; /* Squircle */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
    z-index: 1;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 2px;
    letter-spacing: -1px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* 表单控件 - iOS 输入框风格 */
.form-input, .form-select, .search-input {
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: rgba(118, 118, 128, 0.12); /* iOS Search Field Background */
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus, .search-input:focus {
    outline: none;
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

.search-input {
    width: 100%;
}

/* 按钮样式 - iOS 按钮风格 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 20px; /* Capsule shape */
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: scale(1.02);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-secondary {
    background: rgba(118, 118, 128, 0.12);
    color: var(--primary-color);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(118, 118, 128, 0.2);
}

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

.btn-danger:hover:not(:disabled) {
    background: #D70015;
    transform: scale(1.02);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 16px;
}

/* 卡片样式 - iOS 分组列表风格 */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: none;
    margin-bottom: var(--spacing-lg);
    width: 100%;
    overflow: hidden;
}

.card-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-light);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 0; /* 分组列表风格通常不需要内边距，由单元格提供 */
}

/* 表格样式 - iOS 列表风格 */
.table-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: none;
}

table {
    width: 100%;
    border-collapse: separate; /* Allows border-radius */
    border-spacing: 0;
}

#studyTrendChart {
    width: 100% !important;
    height: 100% !important;
    max-height: 360px;
}

th {
    background: var(--gray-50);
    padding: 14px var(--spacing-lg);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 16px var(--spacing-lg);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 15px;
    vertical-align: middle;
}

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

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

/* 状态标签 - iOS 胶囊风格 */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

.status-active {
    background: rgba(52, 199, 89, 0.15);
    color: #248A3D; /* Darker green for text */
}

.status-inactive {
    background: rgba(142, 142, 147, 0.15);
    color: var(--gray-600);
}

.status-warning {
    background: rgba(255, 149, 0, 0.15);
    color: #C47300; /* Darker orange */
}

.status-danger {
    background: rgba(255, 59, 48, 0.15);
    color: #D70015; /* Darker red */
}

/* 模态框样式 - iOS Sheet 风格 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 24px;
    padding: var(--spacing-xl);
    width: 90%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.close-btn {
    background: rgba(118, 118, 128, 0.12);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(118, 118, 128, 0.2);
    color: var(--text-primary);
}

/* 加载和错误状态 */
.loading, .error-state {
    padding: 60px;
    text-align: center;
    color: var(--text-secondary);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(0, 122, 255, 0.1);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-md);
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* 动画类 */
.animate-fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-slide-up {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    to { opacity: 1; transform: translateY(0); }
}

/* 列表项优化 */
tbody tr {
    transition: background-color 0.2s ease;
}
tbody tr:hover td {
    background-color: rgba(0, 122, 255, 0.03); /* Subtle blue tint on hover */
}

/* 按钮光效 */
.btn-primary {
    background: var(--primary-color);
    color: white;
    position: relative;
    overflow: hidden;
}
.btn-primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}
.btn-primary:hover::after {
    opacity: 1;
}

/* 响应式适配 */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        padding: 0;
        overflow: hidden;
        transform: translateX(-100%);
        transition: width 0.3s ease, padding 0.3s ease, transform 0.3s ease;
    }

    .sidebar.active {
        width: 260px;
        padding: var(--spacing-lg) var(--spacing-md);
        transform: translateX(0);
        z-index: 2000;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: var(--spacing-md);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .header {
        padding: 0 var(--spacing-md);
    }
}

/* 工具类 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }

/* 用户搜索下拉框样式 */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.search-item {
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.2s ease;
}

.search-item:hover {
    background-color: var(--bg-secondary);
}

.search-item:last-child {
    border-bottom: none;
}

.search-item-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.search-item-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.search-item-empty {
    padding: var(--spacing-md);
    text-align: center;
    color: var(--text-tertiary);
    font-style: italic;
}

/* 选中用户信息卡片 */
.selected-user-info {
    margin-top: var(--spacing-sm);
}

.selected-user-card {
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-primary);
}
