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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
}

.header h1 {
    font-size: 24px;
    margin-bottom: 10px;
}

.points-display {
    background: rgba(255,255,255,0.2);
    padding: 10px 20px;
    border-radius: 25px;
    display: inline-block;
    font-size: 18px;
    font-weight: bold;
}

.points-value {
    color: #FFD700;
    margin-left: 5px;
}

/* 导航样式 */
.nav {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.nav-btn {
    flex: 1;
    padding: 15px 10px;
    border: none;
    background: transparent;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.nav-btn.active {
    background: white;
    border-bottom-color: #4CAF50;
    color: #4CAF50;
    font-weight: bold;
}

.nav-btn:hover {
    background: #e9ecef;
}

/* 主要内容区域 */
.main {
    padding: 20px;
    min-height: calc(100vh - 140px);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

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

.page-header h2 {
    font-size: 20px;
    color: #333;
}

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

.action-btn-small {
    padding: 8px 12px;
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn-small:hover {
    background: #e9ecef;
    border-color: #4CAF50;
    color: #4CAF50;
}

.add-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #4CAF50;
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.add-btn:hover {
    background: #45a049;
    transform: scale(1.1);
}

/* 今日任务区域 */
.today-section {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.today-section h2 {
    margin-bottom: 15px;
    color: #333;
}

.task-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
}

.stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: bold;
    color: #4CAF50;
}

.stat-label {
    font-size: 12px;
    color: #666;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    width: 0%;
    transition: width 0.3s ease;
}

/* 快速操作按钮 */
.quick-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.action-btn {
    flex: 1;
    padding: 15px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 5px;
}

.action-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.action-btn.primary {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    font-size: 18px;
    padding: 18px;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

/* 任务列表 */
.task-list {
    margin-top: 15px;
}

.task-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* 仅阴影过渡，避免布局属性动画导致抖动 */
    transition: box-shadow 0.2s ease;
    cursor: move;
}

.task-item:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.task-item.completed {
    background: #f8f9fa;
    opacity: 0.7;
}

.task-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.task-drag-handle {
    color: #ccc;
    font-size: 16px;
    margin-right: 10px;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.task-drag-handle:active {
    cursor: grabbing;
}

.task-info {
    flex: 1;
}

.task-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.task-meta {
    font-size: 12px;
    color: #666;
}

.task-points {
    background: #FFD700;
    color: #333;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
}

.task-actions {
    display: flex;
    gap: 10px;
}

.sort-actions {
    display: none;
    gap: 8px;
}

.sort-mode .sort-actions {
    display: flex;
}

.sort-mode .task-actions {
    display: none;
}

.sort-btn {
    padding: 6px 10px;
    border: 1px solid #e9ecef;
    background: #fff;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sort-btn:hover {
    background: #f8f9fa;
    border-color: #4CAF50;
}

.sort-btn:disabled {
    background: #f8f9fa;
    color: #ccc;
    cursor: not-allowed;
    border-color: #e9ecef;
}

.sort-btn:disabled:hover {
    background: #f8f9fa;
    border-color: #e9ecef;
}

.sort-btn.danger {
    color: #f44336;
    border-color: #f44336;
}

.sort-btn.danger:hover {
    background: #ffebee;
}

.task-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.complete-btn {
    background: #4CAF50;
    color: white;
}

.complete-btn:hover {
    background: #45a049;
}

.delete-btn {
    background: #f44336;
    color: white;
}

.delete-btn:hover {
    background: #d32f2f;
}

/* 过滤器 */
.task-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid #e9ecef;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.filter-btn.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.filter-btn:hover {
    background: #e9ecef;
}

.filter-btn.active:hover {
    background: #45a049;
}

/* 奖励网格 */
.rewards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

/* 奖励标签切换 */
.reward-tabs {
    display: flex;
    margin-bottom: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 5px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: white;
    color: #4CAF50;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tab-btn:hover {
    background: #e9ecef;
}

.tab-btn.active:hover {
    background: white;
}

/* 奖励区域 */
.reward-section {
    display: none;
}

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

/* 兑换历史 */
.history-list {
    margin-top: 15px;
}

.history-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.history-item:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.history-info {
    flex: 1;
}

.history-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.history-meta {
    font-size: 12px;
    color: #666;
}

.history-cost {
    color: #f44336;
    font-weight: bold;
    font-size: 14px;
}

.empty-state {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    font-size: 14px;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.6;
}

.empty-text {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

.empty-hint {
    font-size: 12px;
    color: #999;
}

/* 任务信息提示 */
.task-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.info-text {
    color: #666;
    font-size: 14px;
    margin: 0;
    text-align: center;
}

/* 模板列表 */
.template-list {
    margin-top: 15px;
}

.template-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.template-item:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.template-info {
    flex: 1;
}

.template-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.template-meta {
    font-size: 12px;
    color: #666;
}

.template-actions {
    display: flex;
    gap: 10px;
}

.template-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.use-btn {
    background: #4CAF50;
    color: white;
}

.use-btn:hover {
    background: #45a049;
}

.templates-info {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.info-text {
    color: #1976d2;
    font-size: 14px;
    margin: 0;
}

.reward-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    /* 仅阴影过渡，避免布局属性动画导致抖动 */
    transition: box-shadow 0.2s ease;
    cursor: move;
}

.reward-item:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.reward-item.affordable {
    border-color: #4CAF50;
}

.reward-item.affordable:hover {
    background: #f8f9fa;
}

.reward-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.reward-drag-handle {
    color: #ccc;
    font-size: 14px;
    margin-bottom: 5px;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.reward-drag-handle:active {
    cursor: grabbing;
}

.reward-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.reward-cost {
    color: #FFD700;
    font-weight: bold;
    margin-bottom: 10px;
}

.reward-description {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

.redeem-btn {
    width: 100%;
    padding: 8px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.redeem-btn:hover {
    background: #45a049;
}

.redeem-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 设置页面 */
.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.settings-btn {
    width: 100%;
    padding: 15px;
    margin-bottom: 10px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    background: #f8f9fa;
}

.settings-btn.danger {
    color: #f44336;
    border-color: #f44336;
}

.settings-btn.danger:hover {
    background: #ffebee;
}

.about-text {
    color: #666;
    margin-bottom: 5px;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 20px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

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

.modal-header h3 {
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.close-btn:hover {
    color: #333;
}

/* 表单样式 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    font-size: 16px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4CAF50;
}

/* 模板快速选择 */
.template-section {
    margin-bottom: 20px;
}

.template-section h4 {
    margin-bottom: 10px;
    color: #333;
    font-size: 16px;
}

.template-quick-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 5px;
}

/* 自定义滚动条 */
.template-quick-list::-webkit-scrollbar {
    width: 6px;
}

.template-quick-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.template-quick-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.template-quick-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.template-quick-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.template-quick-item:hover {
    background: #e3f2fd;
    border-color: #4CAF50;
    transform: translateY(-2px);
}

.template-quick-name {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 3px;
}

.template-quick-meta {
    font-size: 11px;
    color: #666;
}

.no-templates {
    text-align: center;
    color: #666;
    padding: 20px;
    font-size: 14px;
    background: #f8f9fa;
    border-radius: 8px;
}

.divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e9ecef;
}

.divider span {
    background: white;
    padding: 0 15px;
    color: #666;
    font-size: 14px;
}

.submit-btn {
    width: 100%;
    padding: 15px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    background: #45a049;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .app {
        box-shadow: none;
    }
    
    .header {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .main {
        padding: 15px;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .task-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .rewards-grid {
        grid-template-columns: 1fr;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.page.active {
    animation: fadeIn 0.3s ease;
}

.task-item {
    animation: fadeIn 0.3s ease;
}

.reward-item {
    animation: fadeIn 0.3s ease;
}

/* 排序模式下禁用动画与过渡，避免重排造成的抖动 */
.sorting-mode .page.active {
    animation: none !important;
}
.sorting-mode .task-item,
.sorting-mode .reward-item {
    animation: none !important;
    transition: none !important;
}
