/* ===== CSS 变量 ===== */
:root {
    --primary: #1890ff;
    --primary-dark: #096dd9;
    --success: #52c41a;
    --warning: #faad14;
    --danger: #ff4d4f;
    --gray-100: #f5f5f5;
    --gray-200: #e8e8e8;
    --gray-300: #d9d9d9;
    --gray-400: #bfbfbf;
    --gray-500: #8c8c8c;
    --gray-600: #595959;
    --gray-700: #434343;
    --gray-800: #262626;
    --white: #ffffff;
    --bg: #f0f2f5;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --radius-lg: 12px;
    --header-height: 48px;
    --tab-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== Reset ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

/* ===== 应用容器 ===== */
#app {
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 768px;
    margin: 0 auto;
    position: relative;
}

/* ===== 顶部导航 ===== */
.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
    z-index: 100;
}

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

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

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

/* ===== 搜索栏 ===== */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    background: var(--gray-100);
    border: none;
    border-radius: 18px;
    font-size: 14px;
    outline: none;
}

.search-bar input::placeholder {
    color: var(--gray-400);
}

/* ===== 主内容区 ===== */
.main-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
}

/* ===== 底部标签栏 ===== */
.tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--tab-height);
    padding-bottom: var(--safe-bottom);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
    z-index: 100;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-500);
    font-size: 10px;
    min-width: 56px;
    transition: color 0.2s;
}

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

.tab-item.tab-create {
    color: var(--primary);
}

.tab-item.tab-create svg {
    stroke: var(--primary);
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
}

.btn-secondary:active {
    background: var(--gray-200);
}

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

.btn-small {
    height: 30px;
    padding: 0 12px;
    font-size: 12px;
    border-radius: 6px;
}

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

.btn-outline:active {
    background: rgba(24, 144, 255, 0.05);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    color: var(--gray-600);
    font-size: 20px;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
}

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

.status-backlog {
    background: #e6f7ff;
    color: #1890ff;
}

.status-todo {
    background: #fff7e6;
    color: #fa8c16;
}

.status-tbc {
    background: #f6ffed;
    color: #52c41a;
}

.status-done {
    background: #f0f0f0;
    color: var(--gray-600);
}

.status-cancelled {
    background: #fff1f0;
    color: #ff4d4f;
}

.status-overdue {
    border: 1px solid var(--danger);
}

/* ===== 任务卡片列表 ===== */
.task-list {
    padding: 0 12px;
}

.task-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-top: 10px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.1s;
}

.task-card:active {
    transform: scale(0.98);
}

.task-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.task-card-title {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

.task-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--gray-500);
}

.task-card-meta .overdue {
    color: var(--danger);
    font-weight: 500;
}

.task-card-desc {
    font-size: 13px;
    color: var(--gray-600);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 8px;
    line-height: 1.5;
}

/* ===== 看板视图 ===== */
.kanban-container {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 10px 12px;
    -webkit-overflow-scrolling: touch;
    min-height: calc(100vh - var(--header-height) - var(--tab-height) - 80px);
}

.kanban-column {
    min-width: 260px;
    max-width: 300px;
    flex-shrink: 0;
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 0 4px;
}

.kanban-column-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.kanban-column-count {
    background: var(--gray-300);
    color: var(--gray-700);
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.kanban-cards {
    flex: 1;
    overflow-y: auto;
}

.kanban-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: transform 0.1s;
}

.kanban-card:active {
    transform: scale(0.97);
}

.kanban-card-title {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kanban-card-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--gray-500);
}

/* ===== 任务详情页 ===== */
.task-detail {
    padding: 16px;
}

.task-detail .title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.task-detail .info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

.task-detail .info-label {
    color: var(--gray-500);
}

.task-detail .info-value {
    color: var(--gray-800);
    font-weight: 500;
}

.task-detail .description {
    margin-top: 16px;
    padding: 14px;
    background: var(--gray-100);
    border-radius: var(--radius);
    line-height: 1.7;
    font-size: 14px;
    white-space: pre-wrap;
}

.task-detail .actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-detail .actions .btn {
    width: 100%;
}

/* ===== 评论区 ===== */
.comments-section {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.comments-section h3 {
    font-size: 15px;
    margin-bottom: 12px;
}

.comment-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}

.comment-author {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
}

.comment-time {
    font-size: 11px;
    color: var(--gray-400);
    margin-left: 8px;
}

.comment-content {
    font-size: 14px;
    margin-top: 4px;
    line-height: 1.5;
}

.comment-input {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.comment-input textarea {
    flex: 1;
    height: 64px;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    resize: none;
    outline: none;
}

.comment-input textarea:focus {
    border-color: var(--primary);
}

/* ===== 统计面板 ===== */
.stats-panel {
    padding: 16px 12px;
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stats-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stats-card .number {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stats-card .label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.stats-user-table {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.stats-user-row {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--gray-100);
}

.stats-user-row:last-child {
    border-bottom: none;
}

.stats-user-name {
    flex: 1;
    font-weight: 500;
}

.stats-user-counts {
    display: flex;
    gap: 8px;
}

.stats-count-item {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ===== 个人中心 ===== */
.profile-page {
    padding: 16px 12px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 16px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.profile-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
}

.profile-name {
    font-size: 17px;
    font-weight: 600;
}

.profile-id {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.profile-menu {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.2s;
}

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

.profile-menu-item:active {
    background: var(--gray-100);
}

/* ===== 弹窗 ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-width: 768px;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    padding: 20px;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.modal-header h2 {
    font-size: 17px;
}

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

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

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--white);
}

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

.char-count {
    position: absolute;
    right: 8px;
    bottom: 8px;
    font-size: 11px;
    color: var(--gray-400);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions .btn {
    flex: 1;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    background: var(--gray-800);
    color: var(--white);
    border-radius: 20px;
    font-size: 14px;
    z-index: 300;
    animation: fadeInOut 2.5s ease;
    white-space: nowrap;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ===== Loading ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 空状态 ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    stroke: var(--gray-300);
}

.empty-state p {
    font-size: 14px;
}

/* ===== 筛选切换 ===== */
.filter-tabs {
    display: flex;
    padding: 10px 12px 0;
    gap: 0;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.filter-tab {
    padding: 8px 14px;
    font-size: 13px;
    border: none;
    background: none;
    color: var(--gray-500);
    cursor: pointer;
    position: relative;
    font-weight: 500;
}

.filter-tab.active {
    color: var(--primary);
}

.filter-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
}

/* ===== 管理员列表 ===== */
.admin-list {
    padding: 12px;
}

.admin-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--white);
    border-radius: var(--radius);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}

/* ===== 视图切换 ===== */
.view-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
}

.view-toggle button {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-toggle button.active {
    background: var(--gray-100);
    color: var(--primary);
}

/* ===== 响应式 ===== */
@media (max-width: 375px) {
    .kanban-column {
        min-width: 230px;
    }
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
}
