/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
    margin: 0;
}

.hidden {
    display: none !important;
}

/* ==================== 页面容器 ==================== */
.page-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ==================== Loading ==================== */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* ==================== 动画 ==================== */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 640px) {
    .header-content {
        padding: 0 16px;
    }

    .app-title {
        font-size: 20px;
    }

    .main-content {
        padding: 16px;
    }
}/* ==================== 认证页面样式 ==================== */
.auth-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.5s ease;
}

.auth-title {
    font-size: 28px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s;
    outline: none;
}

.form-input:focus {
    border-color: #333;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #333;
    color: white;
}

.btn-primary:hover {
    background: #000;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.auth-link a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
}

.auth-link a:hover {
    text-decoration: underline;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.success-message {
    background: #efe;
    color: #3c3;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}/* ==================== Todo页面样式 ==================== */
.todo-container {
    background: #f8f9fa;
    min-height: 100vh;
    width: 100%;
}

.app-header {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
    flex-shrink: 0;
}

.main-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* ==================== Todo列表 ==================== */
.todo-list {
    background: white;
    border-radius: 12px;
    padding: 8px;
    min-height: 200px;
}

.todo-item {
    background: white;
    border: 2px solid #f0f0f0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: move;
    transition: all 0.2s;
}

.todo-item:hover {
    border-color: #e0e0e0;
    transform: translateX(2px);
}

.todo-item.dragging {
    opacity: 0.5;
}


.todo-item.editing {
    border-color: #333;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.todo-item.selected {
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}


.todo-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.todo-details {
    flex: 1;
    cursor: pointer;
}

.todo-title {
    font-size: 16px;
    color: #333;
    margin-bottom: 4px;
}

.todo-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.todo-actions {
    display: flex;
    gap: 8px;
}

/* ==================== 已完成任务 ==================== */
.completed-section {
    margin-top: 40px;
}

.section-title {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.section-title:hover {
    background: #f8f8f8;
}

.toggle-icon {
    transition: transform 0.2s;
}

.completed-list {
    background: white;
    border-radius: 12px;
    padding: 8px;
}

.completed-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
}

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

.completed-content {
    flex: 1;
}

.completed-title {
    color: #999;
    text-decoration: line-through;
    cursor: pointer;
}

.completed-title:hover {
    color: #666;
}

.completed-tags {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.completed-time {
    font-size: 12px;
    color: #bbb;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p {
    font-size: 16px;
}/* ==================== 按钮组件 ==================== */
.icon-button {
    width: 40px;
    height: 40px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-button:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
}

.icon-button img {
    width: 20px;
    height: 20px;
}

.complete-button {
    width: 24px;
    height: 24px;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.complete-button:hover {
    border-color: #4caf50;
}

.complete-button.completed {
    background: #4caf50;
    border-color: #4caf50;
}

.complete-button img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}






.completed-icon {
    width: 24px;
    height: 24px;
    background: #4caf50;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.completed-icon:hover {
    background: #45a049;
}

.delete-completed-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #ccc;
    cursor: pointer;
    font-size: 18px;
}

.delete-completed-btn:hover {
    color: #f44336;
}

/* ==================== 添加任务输入框 ==================== */
.add-todo-container {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.new-todo-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s;
}

.new-todo-input:focus {
    border-color: #333;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.add-button {
    width: 40px;
    height: 40px;
    border: none;
    background: #333;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.add-button:hover {
    background: #000;
    transform: scale(1.05);
}

.add-button img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}

/* ==================== 标签 ==================== */
.tag {
    background: #f0f0f0;
    color: #666;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
}

.tag:hover {
    background: #e0e0e0;
}

.completed-tag {
    background: #f8f8f8;
    color: #999;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    cursor: pointer;
}

.completed-tag:hover {
    background: #f0f0f0;
    color: #666;
}

/* ==================== 标签筛选 ==================== */
.tag-filter {
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-label {
    color: #666;
    font-size: 14px;
}

.selected-tag {
    background: #333;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
}

.clear-filter {
    background: #e0e0e0;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #666;
}

.clear-filter:hover {
    background: #d0d0d0;
}

/* ==================== 保存指示器 ==================== */
.save-indicator {
    background: white;
    border-radius: 8px;
    padding: 8px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.save-indicator.saving {
    color: #333;
}

.save-indicator.success {
    color: #4caf50;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==================== 编辑模式 ==================== */
.todo-edit-form {
    flex: 1;
    display: flex;
    gap: 12px;
    align-items: center;
}

.edit-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #333;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
}

.edit-actions {
    display: flex;
    gap: 8px;
}

.save-button, .cancel-button, .delete-button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.save-button {
    background: #4caf50;
}

.cancel-button {
    background: #ff9800;
}

.delete-button {
    background: #f44336;
}

.save-button:hover {
    background: #45a049;
}

.cancel-button:hover {
    background: #fb8c00;
}

.delete-button:hover {
    background: #da190b;
}

.save-button img, .cancel-button img, .delete-button img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

/* ==================== 分页 ==================== */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
    padding: 16px;
    background: white;
    border-radius: 8px;
}

.pagination-btn {
    padding: 8px 16px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: #f5f5f5;
}

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

.pagination-info {
    font-size: 14px;
    color: #666;
}/* ==================== 移动端响应式样式 ==================== */

/* 移动端菜单按钮 */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #333;
    margin: 4px 0;
    transition: all 0.3s;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* 移动端侧边栏遮罩 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ==================== 响应式断点 ==================== */

/* 平板和移动设备 (768px 及以下) */
@media (max-width: 768px) {
    /* 显示移动端菜单按钮 */
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
    }

    .sidebar-overlay {
        display: block;
    }

    /* 调整顶部栏 */
    .header {
        padding: 60px 20px 20px;
    }

    .header h1 {
        font-size: 24px;
        margin-left: 40px; /* 为菜单按钮留出空间 */
    }

    /* 用户信息移动端优化 */
    .user-info {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 10px 20px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .user-info.active {
        transform: translateX(0);
    }

    /* 主容器调整 */
    .main-container {
        width: 100%;
        max-width: 100%;
        padding: 10px;
        margin-top: 60px;
    }

    /* 输入框优化 */
    .add-todo {
        padding: 15px;
    }

    #newTodoInput {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 12px;
    }

    #addTodoBtn {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    /* 待办事项列表优化 */
    .todo-item {
        padding: 12px 10px;
        margin-bottom: 10px;
    }

    .todo-content {
        padding-right: 10px;
    }

    .todo-actions {
        gap: 8px;
    }

    .todo-actions button {
        padding: 8px;
        min-width: 36px;
        height: 36px;
    }

    /* 完成项目按钮 */
    .complete-btn {
        min-width: 44px;
        height: 44px;
    }

    /* 历史记录按钮已删除 */

    /* 历史记录面板 */
    .completed-section {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60vh;
        background: white;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 200;
        overflow-y: auto;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
    }

    .completed-section.show {
        transform: translateY(0);
    }

    /* 分页控件 */
    .pagination {
        padding: 15px;
        gap: 10px;
    }

    .page-btn {
        min-width: 44px;
        height: 44px;
        padding: 0 15px;
    }

    /* 登录/注册表单 */
    .auth-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 20px;
        box-shadow: none;
        border-radius: 0;
    }

    .form-group input {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 12px;
    }

    .form-actions button {
        padding: 12px;
        font-size: 16px;
    }

    /* 防止横向滚动 */
    body {
        overflow-x: hidden;
    }

    /* 触摸优化 */
    button, .todo-item, input, textarea {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}

/* 小屏手机优化 (375px 及以下) */
@media (max-width: 375px) {
    .header h1 {
        font-size: 20px;
    }

    .main-container {
        padding: 5px;
    }

    .todo-actions {
        flex-direction: column;
        gap: 5px;
    }

    .todo-actions button {
        width: 100%;
    }

    .page-btn {
        min-width: 36px;
        padding: 0 10px;
        font-size: 14px;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 40px 20px 15px;
    }

    .main-container {
        margin-top: 40px;
    }

    .completed-section {
        height: 80vh;
    }
}

/* 大屏平板优化 (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-container {
        max-width: 700px;
    }

    .header h1 {
        font-size: 28px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大可点击区域 */
    .todo-actions button {
        min-width: 44px;
        min-height: 44px;
    }

    .complete-btn {
        width: 44px;
        height: 44px;
    }

    /* 确保所有按钮可点击 */
    button, .todo-item, .complete-btn {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        user-select: none;
    }

    /* 移除悬停效果，改用点击效果 */
    .todo-item:hover {
        background: transparent;
    }

    .todo-item:active {
        background: #f9f9f9;
    }

    button:hover {
        opacity: 1;
    }

    button:active {
        opacity: 0.8;
        transform: scale(0.95);
    }
}

/* 滚动条优化 */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
    }

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

    ::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 2px;
    }
}

/* 安全区域适配 (iPhone X 及以上) */
@supports (padding: env(safe-area-inset-bottom)) {
    .main-container {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .completed-section {
        padding-bottom: env(safe-area-inset-bottom);
    }
}