/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-lighter: #dbeafe;
    --primary-bg: #eff6ff;

    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-dark: #7c3aed;
    --accent-lighter: #ede9fe;

    --gold: #f59e0b;
    --gold-light: #fef3c7;

    --bg: #f0f4ff;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;

    --easy: #10b981;
    --medium: #f59e0b;
    --hard: #ef4444;
    --legendary: #8b5cf6;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.15);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.3);

    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

.app {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== 头部 ===== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, var(--accent) 100%);
    border-radius: var(--radius-xl);
    padding: 2rem 2rem 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(139,92,246,0.2) 0%, transparent 70%);
    border-radius: 50%;
}

.header-content {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 1.5rem;
}

.logo {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.logo-icon {
    font-size: 2.5rem;
}

.subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 1rem;
}

/* ===== 统计栏 ===== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.stat-item {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.2);
    transition: transform 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.25);
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--white);
}

.stat-label {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
}

/* ===== 导航 ===== */
.nav {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    background: var(--white);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 20px;
    z-index: 100;
}

.nav-btn {
    flex: 1;
    padding: 0.9rem;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.nav-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.nav-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

/* ===== 内容区域 ===== */
.tab-content {
    display: none;
    animation: fadeSlideIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    font-size: 1.4rem;
    color: var(--gray-800);
}

/* ===== 徽章过滤 ===== */
.badge-filter {
    display: flex;
    gap: 0.5rem;
}

.filter-chip {
    padding: 0.4rem 1rem;
    border: 2px solid var(--gray-200);
    background: var(--white);
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-chip.active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

/* ===== 徽章网格 ===== */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.2rem;
}

.badge-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 2px solid var(--gray-200);
    overflow: hidden;
}

.badge-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-md);
}

.badge-card.unlocked {
    border-color: var(--gold);
    background: linear-gradient(135deg, var(--white) 0%, var(--gold-light) 100%);
}

.badge-card.unlocked:hover {
    box-shadow: var(--shadow-glow);
    border-color: var(--accent);
}

.badge-card.locked {
    opacity: 0.6;
}

.badge-card.locked:hover {
    opacity: 0.8;
}

.badge-card .badge-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.8rem;
    transition: transform 0.3s ease;
}

.badge-card.unlocked .badge-icon {
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.badge-card .badge-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.3rem;
}

.badge-card .badge-category {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.badge-card .badge-difficulty {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.difficulty-easy { background: #d1fae5; color: var(--easy); }
.difficulty-medium { background: #fef3c7; color: var(--medium); }
.difficulty-hard { background: #fee2e2; color: var(--hard); }
.difficulty-legendary { background: #ede9fe; color: var(--legendary); }

.badge-card .lock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    opacity: 0.4;
}

.badge-card.unlocked .lock-overlay {
    display: none;
}

.badge-card .unlock-date {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.3rem;
}

/* ===== 卡片 ===== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 1.3rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 1.5rem;
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: var(--gray-50);
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px var(--primary-lighter);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ===== 图标选择器 ===== */
.icon-picker {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.icon-option {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--white);
}

.icon-option:hover {
    border-color: var(--accent);
    transform: scale(1.1);
}

.icon-option.selected {
    border-color: var(--accent);
    background: var(--accent-lighter);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* ===== 按钮 ===== */
.btn {
    padding: 0.7rem 1.4rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: var(--white);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-success {
    background: var(--easy);
    color: var(--white);
}

.btn-danger {
    background: var(--hard);
    color: var(--white);
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

/* ===== 筛选栏 ===== */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.45rem 1rem;
    border: 2px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.goal-stats, .task-stats {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* ===== 目标列表 ===== */
.goals-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.goal-item {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.2rem;
    transition: all 0.3s ease;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-15px); }
    to { opacity: 1; transform: translateX(0); }
}

.goal-item:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow);
}

.goal-item.completed {
    opacity: 0.7;
    background: var(--gray-50);
    border-color: var(--easy);
}

.goal-item.completed .goal-name {
    text-decoration: line-through;
    color: var(--gray-500);
}

.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.goal-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.goal-icon {
    font-size: 1.5rem;
}

.goal-name {
    font-size: 1.05rem;
    font-weight: 600;
}

.goal-desc {
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
}

.goal-meta {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.goal-category-tag {
    padding: 0.25rem 0.7rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--primary-lighter);
    color: var(--primary);
}

.goal-difficulty-tag {
    font-size: 0.8rem;
}

.goal-actions {
    display: flex;
    gap: 0.5rem;
}

.goal-actions .btn {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

/* ===== 时间线 ===== */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.6rem;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--primary), var(--accent));
    border-radius: 2px;
}

.timeline-item {
    position: relative;
    padding: 1rem 1.5rem;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.timeline-item:hover {
    border-color: var(--accent-light);
    box-shadow: var(--shadow);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -2.35rem;
    top: 1.5rem;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    border: 3px solid var(--white);
    box-shadow: 0 0 0 3px var(--accent-lighter);
}

.timeline-item .tl-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.timeline-item .tl-title {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.3rem;
}

.timeline-item .tl-date {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.timeline-item .tl-badge-name {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    background: var(--accent-lighter);
    color: var(--accent-dark);
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.3rem;
}

/* ===== 弹窗 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    animation: modalOverlayIn 0.3s ease;
}

@keyframes modalOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from { transform: translateY(-40px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--gray-800);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
}

/* ===== 领取徽章弹窗 ===== */
.claim-body {
    text-align: center;
    position: relative;
    overflow: hidden;
}

.claim-badge-preview {
    width: 100px;
    height: 100px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, var(--gold-light), #fef9e7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid var(--gold);
    animation: claimBadgeBounce 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes claimBadgeBounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.badge-icon-large {
    font-size: 3rem;
}

.claim-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.claim-desc {
    color: var(--gray-600);
    font-size: 0.95rem;
}

/* ===== 徽章详情弹窗 ===== */
.badge-detail-body {
    text-align: center;
}

.badge-detail-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.badge-detail-body h4 {
    font-size: 1.3rem;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.badge-detail-body p {
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.badge-detail-meta {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.meta-tag {
    padding: 0.3rem 0.8rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--primary-lighter);
    color: var(--primary);
}

.badge-detail-date {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}

.empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-state p {
    font-size: 1rem;
}

.empty-hint {
    font-size: 0.85rem !important;
    color: var(--gray-400);
    margin-top: 0.3rem;
}

/* ===== 页脚 ===== */
.footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--gray-500);
    font-size: 0.9rem;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .app {
        padding: 12px;
    }

    .header {
        padding: 1.5rem 1rem;
        border-radius: var(--radius-lg);
    }

    .logo {
        font-size: 1.6rem;
    }

    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .nav {
        flex-direction: column;
        gap: 0.4rem;
    }

    .nav-btn {
        padding: 0.7rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .badges-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-header {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .goal-actions {
        flex-wrap: wrap;
    }

    .modal-content {
        max-width: 95%;
    }

    .icon-picker {
        gap: 0.3rem;
    }

    .icon-option {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }
}

@media (max-width: 400px) {
    .badges-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }

    .badge-card {
        padding: 1rem 0.6rem;
    }

    .badge-card .badge-icon {
        font-size: 2.5rem;
    }

    .badge-card .badge-name {
        font-size: 0.85rem;
    }
}
