/* --- 主题色和变量定义 --- */
:root {
    --primary-color: #6597b4;
    --secondary-color: #80b199;
    --background-color: #f0f4f8;
    --card-background-color: #ffffff;
    --text-color: #333333;
    --subtle-text-color: #555555;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.08);
}
body.dark-mode {
    --primary-color: #80b199;
    --secondary-color: #6597b4;
    --background-color: #1a202c;
    --card-background-color: #2d3748;
    --text-color: #e2e8f0;
    --subtle-text-color: #a0aec0;
    --border-color: #4a5568;
    --shadow-color: rgba(0, 0, 0, 0.2);
}

/* --- 全局样式 --- */
body { font-family: 'Noto Sans SC', sans-serif; background-color: var(--background-color); color: var(--text-color); display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; margin: 0; padding: 20px; box-sizing: border-box; transition: background-color 0.3s, color 0.3s; }
#app { width: 100%; max-width: 600px; text-align: center; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
h1 { font-size: 2rem; color: var(--primary-color); transition: color 0.3s; padding-left: 0.2em; }
.hidden { display: none !important; }

/* --- 初始界面 --- */
#initial-view { background: var(--card-background-color); padding: 40px; border-radius: 12px; box-shadow: 0 4px 12px var(--shadow-color); transition: background-color 0.3s; }
#task-form { display: flex; flex-direction: column; gap: 15px; }
#task-input { width: 100%; padding: 15px; border: 2px solid var(--border-color); background-color: var(--background-color); color: var(--text-color); border-radius: 8px; font-size: 1.1rem; box-sizing: border-box; transition: border-color 0.3s, background-color 0.3s; }
#task-input:focus { outline: none; border-color: var(--primary-color); }
button { background-color: var(--primary-color); color: white; border: none; padding: 15px; border-radius: 8px; font-size: 1.2rem; font-weight: 700; cursor: pointer; transition: background-color 0.3s, transform 0.1s; }
button:hover { filter: brightness(1.1); }
button:active { transform: scale(0.98); }

/* --- 加载动画 --- */
#loading { text-align: center; padding: 40px; }
.spinner { border: 6px solid var(--border-color); border-top: 6px solid var(--primary-color); border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 0 auto 20px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- 任务列表界面 --- */
#task-view { width: 100%; }
#task-header { padding-bottom: 20px; text-align: left; }
#task-list-card { background-color: var(--card-background-color); border-radius: 24px; padding: 10px 35px; box-shadow: 0 8px 30px var(--shadow-color); text-align: left; box-sizing: border-box; }
.title-wrapper { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
#task-header h2 { margin: 0 0 10px 0; font-size: 1.8rem; color: var(--text-color); transition: color 0.3s; }
.progress-wrapper { display: flex; align-items: center; gap: 15px; }
.progress-container { flex-grow: 1; height: 8px; background-color: var(--background-color); border-radius: 4px; overflow: hidden; transition: background-color 0.3s; }
#progress-bar { width: 0%; height: 100%; background-color: var(--primary-color); border-radius: 4px; transition: width 0.4s ease-in-out, background-color 0.3s; }
#progress-percentage { font-size: 0.9rem; color: var(--subtle-text-color); font-weight: 700; transition: color 0.3s; }

/* --- 任务清单项 --- */
#task-cards-container { display: flex; flex-direction: column; gap: 0; }
.task-card { background-color: transparent; padding: 18px 5px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; gap: 15px; transition: border-color 0.3s; }
.task-card:last-child { border-bottom: none; }
.task-left-side { display: flex; align-items: center; gap: 15px; cursor: pointer; flex-grow: 1; min-width: 0; }
.checkmark-box { width: 22px; height: 22px; border: 2px solid var(--subtle-text-color); border-radius: 6px; display: flex; justify-content: center; align-items: center; flex-shrink: 0; transition: background-color 0.3s, border-color 0.3s; }
.checkmark-box svg { width: 30px; height: 30px; stroke: var(--text-color); stroke-width: 3; visibility: hidden; }
.task-card .task-text { color: var(--text-color); transition: color 0.3s, opacity 0.3s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-card.completed .checkmark-box { background-color: var(--secondary-color); border-color: var(--secondary-color); }
.task-card.completed .checkmark-box svg { visibility: visible; }
.task-card.completed .task-text { text-decoration: line-through; color: var(--secondary-color); opacity: 0.7; }

/* 详情按钮 */
.details-button { cursor: pointer; color: var(--subtle-text-color); font-size: 1.5rem; padding: 5px; transition: color 0.3s; flex-shrink: 0; }
.details-button:hover { color: var(--primary-color); }

/* --- 子任务弹窗 --- */
#subtask-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 2000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease-in-out; }
#subtask-modal-overlay.visible { opacity: 1; visibility: visible; }
#subtask-modal-content { background: var(--card-background-color); padding: 25px 30px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); width: 90%; max-width: 500px; transform: scale(0.95); transition: transform 0.3s ease-in-out; }
#subtask-modal-overlay.visible #subtask-modal-content { transform: scale(1); }
#subtask-modal-title { margin: 0 0 15px 0; font-size: 1.5rem; color: var(--primary-color); }
#subtask-modal-list .subtask { padding: 10px 0; border-bottom: 1px solid var(--border-color); color: var(--text-color); }
#subtask-modal-list .subtask:last-child { border-bottom: none; }
#subtask-modal-list .spinner { margin: 20px auto; }

/* --- 鼓励弹窗 --- */
#encouragement-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center; z-index: 1000; padding: 0 20px; box-sizing: border-box; }
.modal-content { background: var(--card-background-color); padding: 40px 50px; border-radius: 12px; text-align: center; box-shadow: 0 5px 15px rgba(0,0,0,0.3); animation: fadeIn 0.3s ease-in-out; width: 100%; max-width: 400px; }
.modal-content p { font-size: 1.8rem; font-weight: 700; margin: 0 0 25px 0; color: var(--primary-color); }
#reset-button { font-size: 1.1rem; padding: 12px 25px; background-color: var(--secondary-color); }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

/* --- 夜间模式切换开关 --- */
.theme-switch-wrapper { position: absolute; top: 20px; right: 20px; display: flex; align-items: center; z-index: 100; }
.theme-switch { display: inline-block; height: 34px; position: relative; width: 60px; }
.theme-switch input { display:none; }
.slider { background-color: #ccc; bottom: 0; cursor: pointer; left: 0; position: absolute; right: 0; top: 0; transition: .4s; }
.slider:before { background-color: #fff; bottom: 4px; content: ""; height: 26px; left: 4px; position: absolute; transition: .4s; width: 26px; }
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(26px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* --- 底部信息 --- */
.app-footer { width: 100%; text-align: center; padding: 20px 0; color: var(--subtle-text-color); font-size: 0.9rem; transition: color 0.3s; }
.app-footer a { color: inherit; text-decoration: none; font-weight: 700; transition: color 0.3s; }
.app-footer a:hover { color: var(--primary-color); text-decoration: underline; }
