/* 基础重置和变量 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 柔和天空蓝色调色板 */
    --primary-blue: #7DD3FC;
    --light-blue: #BAE6FD;
    --dark-blue: #38BDF8;
    --hover-blue: #0EA5E9;
    --active-blue: #0284C7;

    /* 中性色 */
    --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;
    --gray-900: #111827;

    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* 圆角 */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #EDE9FE 0%, #D1FAE5 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

/* 容器 */
.container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--white);
    box-shadow: var(--shadow-xl);
}

/* 头部 */
.header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
    color: #0C4A6E;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: #0C4A6E;
}

.title-icon {
    font-size: 1.75rem;
}

.subtitle {
    font-size: 0.9375rem;
    opacity: 0.75;
    margin-top: 0.5rem;
    font-weight: 400;
    color: #0369A1;
}

/* 主内容区 */
.main-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* 任务输入区 */
.input-section {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.task-input {
    width: 100%;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    outline: none;
    transition: all 0.2s ease;
    background: var(--white);
}

.task-input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

/* 优先级选择器 */
.priority-selector {
    display: flex;
    gap: 0.5rem;
}

.priority-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-500);
    background: var(--white);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.priority-btn:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.priority-btn.active {
    font-weight: 600;
}

.priority-btn.active.low {
    color: #10B981;
    border-color: #10B981;
    background: #ECFDF5;
}

.priority-btn.active.medium {
    color: #F59E0B;
    border-color: #F59E0B;
    background: #FFFBEB;
}

.priority-btn.active.high {
    color: #EF4444;
    border-color: #EF4444;
    background: #FEF2F2;
}

.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    align-self: flex-start;
    margin-top: 0;
}

.add-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--light-blue) 0%, var(--primary-blue) 100%);
}

.add-btn:active {
    transform: translateY(0);
}

/* 任务列表区 */
.tasks-section {
    background: var(--gray-50);
    border-radius: var(--radius-xl);
    padding: 1rem;
    min-height: 200px;
}

.task-actions-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.clear-completed-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-500);
    background: transparent;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-completed-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.clear-completed-btn:active {
    transform: scale(0.98);
}

.clear-all-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #DC2626;
    background: transparent;
    border: 1px solid #FECACA;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-all-btn:hover {
    background: #FEF2F2;
    border-color: #EF4444;
}

.task-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* 任务项 */
.task-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    animation: slideIn 0.3s ease;
}

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

.task-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.task-item.completed .task-text {
    text-decoration: line-through;
    color: var(--gray-400);
}

/* 优先级标签 */
.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.priority-badge.low {
    color: #059669;
    background: #D1FAE5;
}

.priority-badge.medium {
    color: #D97706;
    background: #FEF3C7;
}

.priority-badge.high {
    color: #DC2626;
    background: #FEE2E2;
}

.priority-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* 编辑按钮 */
.edit-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.edit-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--gray-400);
    transition: stroke 0.2s ease;
}

.edit-btn:hover {
    background: var(--gray-100);
}

.edit-btn:hover svg {
    stroke: var(--primary-blue);
}

/* 编辑输入框 */
.task-edit-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    color: var(--gray-700);
    border: 2px solid var(--primary-blue);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--white);
}

.save-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.cancel-edit-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-edit-btn:hover {
    background: var(--gray-200);
}

/* 复选框 */
.checkbox-wrapper {
    position: relative;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.checkbox-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.custom-checkbox {
    position: absolute;
    top: 0;
    left: 0;
    width: 24px;
    height: 24px;
    background: var(--white);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-wrapper input[type="checkbox"]:hover + .custom-checkbox {
    border-color: var(--primary-blue);
}

.checkbox-wrapper input[type="checkbox"]:checked + .custom-checkbox {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
}

.custom-checkbox svg {
    width: 14px;
    height: 14px;
    stroke: var(--white);
    stroke-width: 3;
    fill: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.checkbox-wrapper input[type="checkbox"]:checked + .custom-checkbox svg {
    opacity: 1;
}

/* 任务文本 */
.task-text {
    flex: 1;
    font-size: 1rem;
    color: var(--gray-700);
    word-break: break-word;
    transition: all 0.2s ease;
}

/* 删除按钮 */
.delete-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.delete-btn svg {
    width: 18px;
    height: 18px;
    stroke: var(--gray-400);
    transition: stroke 0.2s ease;
}

.delete-btn:hover {
    background: var(--gray-100);
}

.delete-btn:hover svg {
    stroke: #EF4444;
}

.delete-btn:active {
    transform: scale(0.95);
}

/* 空状态 */
.empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--gray-400);
}

.empty-state.show {
    display: flex;
}

.empty-state svg {
    stroke: var(--gray-300);
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.empty-state .hint {
    font-size: 0.875rem;
    color: var(--gray-400);
}

.empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}

/* 确认弹窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

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

.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.modal-message {
    font-size: 0.9375rem;
    color: var(--gray-500);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.modal-btn {
    padding: 0.625rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    flex: 1;
}

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

.modal-btn.cancel:hover {
    background: var(--gray-200);
}

.modal-btn.confirm {
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
}

.modal-btn.confirm:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* 统计信息区 */
.stats-footer {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
    color: #0C4A6E;
    padding: 1rem 1.5rem;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

.stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 0.9375rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    opacity: 0.9;
}

.stat-number {
    font-weight: 700;
    font-size: 1.125rem;
    min-width: 1.5rem;
    text-align: center;
    color: #0284C7;
}

#completedCount {
    color: #0EA5E9;
}

.stat-divider {
    opacity: 0.4;
}

/* 响应式设计 - 移动端 */
@media (max-width: 767px) {
    .container {
        max-width: 100%;
    }

    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .main-content {
        padding: 1rem;
    }

    .input-section {
        flex-direction: column;
    }

    .add-btn {
        width: 100%;
        justify-content: center;
    }

    .task-input {
        font-size: 1rem;
    }

    .tasks-section {
        padding: 0.75rem;
    }

    .task-item {
        padding: 0.875rem;
        flex-wrap: wrap;
    }

    .priority-selector {
        justify-content: center;
    }

    .add-btn {
        width: 100%;
        margin-top: 0;
    }

    .input-section {
        flex-direction: column;
    }

    .input-group {
        width: 100%;
    }

    .task-actions-bar {
        flex-direction: column;
    }

    .modal-actions {
        flex-direction: column;
    }

    .stat-label {
        font-size: 0.875rem;
    }

    .stat-number {
        font-size: 1rem;
    }
}

/* 淡出动画 */
.task-item.fadeOut {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* 滚动条样式 */
.task-list::-webkit-scrollbar {
    width: 6px;
}

.task-list::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 3px;
}

.task-list::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

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