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

html, body {
    height: 100%;
}

body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    box-sizing: border-box;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    z-index: -2;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.dt-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.dt-modal.open { display: flex; }
.dt-modal-content {
    width: 90vw;
    max-width: 520px;
    max-height: 85vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.usage-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.dt-row { display: flex; gap: 10px; margin-bottom: 12px; }
.dt-row select {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
}
.dt-actions { display: flex; gap: 10px; justify-content: flex-end; }
.dt-actions button {
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
}
.dt-actions #dtConfirm {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: #fff;
    border: none;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

.usage-btn {
    margin-top: 12px;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-weight: 600;
    backdrop-filter: blur(4px);
}
.usage-btn:active {
    transform: translateY(1px);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 300;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 输入区域样式 */
.input-section {
    padding: 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.task-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.time-input {
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s ease;
    min-width: 180px;
    box-sizing: border-box;
}

.task-input:focus {
    border-color: #4facfe;
}

.time-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s ease;
    min-width: 180px;
}

.time-input:focus {
    border-color: #4facfe;
}

input[type="date"],
input[type="time"],
input[type="datetime-local"] {
    color: #333;
    background-color: #fff;
    text-align: left;
    -webkit-text-fill-color: #333;
}
input[type="date"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit-fields-wrapper,
input[type="date"]::-webkit-datetime-edit-text,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field,
input[type="time"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit-fields-wrapper,
input[type="time"]::-webkit-datetime-edit-text,
input[type="time"]::-webkit-datetime-edit-hour-field,
input[type="time"]::-webkit-datetime-edit-minute-field {
    color: #333;
}

#taskDateTimeText {
    font-family: inherit;
    cursor: pointer;
    background-color: #f8f9fa;
}

#taskDateTimeText:focus {
    background-color: #fff;
    border-color: #4facfe;
}

.priority-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.priority-btn {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    min-width: 44px;
}

.priority-btn:hover {
    transform: scale(1.1);
}

.priority-btn.low.active {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

.priority-btn.medium.active {
    background: #ffc107;
    border-color: #ffc107;
    color: white;
}

.priority-btn.high.active {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
}

.add-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    flex-shrink: 0;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.4);
}

/* 筛选区域样式 */
.filter-section {
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.filter-btn {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.filter-btn:hover,
.filter-btn.active {
    background: #4facfe;
    border-color: #4facfe;
    color: white;
}
.sort-select {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    min-width: 120px;
    flex-shrink: 0;
    outline: none;
    transition: border-color 0.3s ease;
}

.sort-select:focus {
    border-color: #4facfe;
}

/* 任务列表样式 */
.task-list {
    list-style: none;
    flex: 1; /* 允许任务列表填充可用空间 */
    overflow-y: auto; /* 允许垂直滚动 */
    padding: 8px 12px;
    -webkit-overflow-scrolling: touch;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
}

.empty-state p {
    font-size: 18px;
    margin-bottom: 10px;
}

.empty-state small {
    font-size: 14px;
    opacity: 0.7;
}

.task-item {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f3f5;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    flex-wrap: nowrap;
    border-radius: 12px;
    margin: 6px 0;
}

.task-item:hover {
    background: #f8f9fa;
    transform: translateX(5px);
}

.task-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.task-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.task-text {
    flex: 1;
    font-size: 16px;
    word-break: break-word;
}

.task-text.completed {
    text-decoration: line-through;
    color: #6c757d;
}

.task-text.overdue {
    color: #dc3545;
    font-weight: bold;
}

.overdue-badge {
    margin-left: 8px;
    font-size: 12px;
    color: #dc3545;
}

.task-time {
    font-size: 12px;
    color: #6c757d;
    margin-left: 10px;
    font-style: italic;
    white-space: nowrap;
}

.task-time.overdue {
    color: #dc3545;
    font-weight: bold;
}

.task-time.today {
    color: #28a745;
    font-weight: bold;
}

.priority-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    font-size: 10px;
    line-height: 12px;
    text-align: center;
}

.priority-low {
    background: #28a745;
    color: white;
}

.priority-medium {
    background: #ffc107;
    color: white;
}

.priority-high {
    background: #dc3545;
    color: white;
}

.reminder-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-left: 4px solid #dc3545;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.reminder-toast.warning {
    border-left-color: #ffc107;
}

.reminder-toast.info {
    border-left-color: #4facfe;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.delete-btn {
    background: #fff0f0;
    color: #fa5252;
    border: 1px solid #ffc9c9;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    font-weight: 600;
}

.delete-btn:hover {
    background: #fa5252;
    color: white;
    border-color: #fa5252;
    box-shadow: 0 4px 12px rgba(250, 82, 82, 0.2);
}

/* 移除长按样式，统一点击确认 */

/* 统计区域样式 */
.stats-section {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid #f1f3f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

#taskCount {
    font-size: 14px;
    color: #868e96;
    font-weight: 500;
}

.clear-btn {
    padding: 8px 20px;
    background: white;
    color: #868e96;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: #f1f3f5;
    color: #495057;
    border-color: #adb5bd;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .container {
        margin: 10px;
        border-radius: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .input-section {
        flex-direction: column;
    }
    
    .filter-section {
        flex-wrap: wrap;
    }
    
    .stats-section {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

.mobile-action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: env(safe-area-inset-bottom);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    display: none;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(6px);
    border-top: 1px solid #eee;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
}

.mobile-action {
    padding: 12px 16px;
    border-radius: 20px;
    border: 1px solid #dee2e6;
    background: white;
    font-size: 14px;
}

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

.mobile-only { display: none; }
.desktop-only { display: block; }

@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    .container {
        margin: 0;
        border-radius: 12px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
    }
    
    .input-section {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        align-items: center; /* 居中对齐 */
    }
    
    .task-input,
    .time-input,
    .priority-buttons,
    .add-btn {
        width: 100%;
        min-width: unset;
        margin-bottom: 8px; /* 增加间距 */
    }

    .add-btn { display: none; }
    
    #taskDateTimeText.mobile-only {
        display: block !important;
    }
    
    #taskDate.mobile-only,
    #taskClock.mobile-only {
        display: none !important;
    }
    
    .priority-buttons {
        justify-content: center;
    }
    
    .filter-section {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px;
    }

    .usage-btn {
        width: 100%;
    }
    
    .filter-btn,
    .sort-select {
        width: 100%;
        margin-bottom: 4px;
    }
    
    .task-list {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .task-item {
        padding: 12px 14px;
    }
    .delete-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    .mobile-action-bar { display: flex; }
    .mobile-only { display: block; }
    .desktop-only { display: none; }

    #mobileAddBtn {
        background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        color: #fff;
        border: none;
        box-shadow: 0 6px 16px rgba(79, 172, 254, 0.35);
        font-weight: 600;
    }
    .mobile-actions-group .mobile-action[data-filter="all"] {
        background: #e7f0ff;
        color: #1f62ff;
        border-color: #bcd2ff;
        font-weight: 600;
    }
    .mobile-actions-group .mobile-action[data-filter="pending"] {
        background: #e9f7ef;
        color: #2f9e44;
        border-color: #b7e4c7;
        font-weight: 600;
    }
    .mobile-actions-group .mobile-action[data-filter="completed"] {
        background: #fdecec;
        color: #dc3545;
        border-color: #f5c2c7;
        font-weight: 600;
    }
    .mobile-action {
        transition: box-shadow 0.2s ease, transform 0.2s ease;
    }
    .mobile-action.active {
        box-shadow: 0 0 0 3px rgba(31, 98, 255, 0.35), 0 6px 16px rgba(0,0,0,0.18);
        transform: translateY(-1px);
    }
    .mobile-action[data-filter="pending"].active {
        box-shadow: 0 0 0 3px rgba(47, 158, 68, 0.35), 0 6px 16px rgba(0,0,0,0.18);
    }
    .mobile-action[data-filter="completed"].active {
        box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.35), 0 6px 16px rgba(0,0,0,0.18);
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
        font-size: 14px;
    }
    
    .task-input,
    .time-input,
    .add-btn,
    .filter-btn,
    .sort-select {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .priority-btn {
        padding: 6px 10px;
        font-size: 14px;
    }
    
    .task-item {
        gap: 8px;
    }
    .task-text {
        font-size: 15px;
    }
    
    .task-time {
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .container {
        border-radius: 8px;
    }
    
    .input-section,
    .filter-section {
        padding: 8px;
    }
    
    .task-item {
        padding: 8px;
    }
    
    .priority-buttons {
        gap: 4px;
    }
    
    .priority-btn {
        min-width: 36px;
        padding: 4px 8px;
    }
}

/* 横屏适配 */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 8px;
    }
    
    .container {
        display: flex;
        flex-direction: column;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }
    
    .header p {
        font-size: 0.9rem;
    }
    
    .input-section {
        padding: 10px;
        gap: 6px;
    }
    
    .task-input,
    .time-input {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .filter-section {
        padding: 10px;
    }
    
    .task-list {
        flex: 1;
        overflow-y: auto;
        max-height: none;
        min-height: 100px;
        -webkit-overflow-scrolling: touch;
    }
    
    .stats-section {
        padding: 10px;
    }
    
    .mobile-action-bar {
        padding: 8px 12px;
    }
}

/* 触摸设备横屏也使用文本日期输入，隐藏原生 */
@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
    #taskDateTimeText.mobile-only { display: block !important; }
    #taskDate.mobile-only, #taskClock.mobile-only { display: none !important; }
    .container { display: flex; flex-direction: column; }
    .input-section { flex-direction: column; gap: 8px; align-items: center; }
    .task-input, .time-input, .priority-buttons, .add-btn { width: 100%; min-width: unset; margin-bottom: 8px; }
    .add-btn { display: none; }
    .mobile-only { display: block; }
    .desktop-only { display: none; }
    .filter-section { flex-direction: column; gap: 8px; }
    .filter-section .filter-buttons { display: none; }
    .filter-btn, .sort-select { width: 100%; margin-bottom: 4px; }
    .task-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .mobile-action-bar { display: flex !important; }
    .dt-modal-content { width: 92vw; max-height: 88vh; }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .filter-btn,
    .priority-btn,
    .add-btn,
    .delete-btn {
        min-height: 44px;
    }
    
    .task-checkbox {
        transform: scale(1.2);
        margin-right: 8px;
    }

    .mobile-action-bar { display: flex; }
    .mobile-only { display: block; }
    .desktop-only { display: none; }
    #mobileAddBtn {
        background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        color: #fff;
        border: none;
        box-shadow: 0 6px 16px rgba(79, 172, 254, 0.35);
        font-weight: 600;
    }
    .mobile-actions-group .mobile-action[data-filter="all"] {
        background: #e7f0ff;
        color: #1f62ff;
        border-color: #bcd2ff;
        font-weight: 600;
    }
    .mobile-actions-group .mobile-action[data-filter="pending"] {
        background: #e9f7ef;
        color: #2f9e44;
        border-color: #b7e4c7;
        font-weight: 600;
    }
    .mobile-actions-group .mobile-action[data-filter="completed"] {
        background: #fdecec;
        color: #dc3545;
        border-color: #f5c2c7;
        font-weight: 600;
    }
    .mobile-action { transition: box-shadow 0.2s ease, transform 0.2s ease; }
    .mobile-action.active {
        box-shadow: 0 0 0 3px rgba(31, 98, 255, 0.35), 0 6px 16px rgba(0,0,0,0.18);
        transform: translateY(-1px);
    }
    .mobile-action[data-filter="pending"].active {
        box-shadow: 0 0 0 3px rgba(47, 158, 68, 0.35), 0 6px 16px rgba(0,0,0,0.18);
    }
    .mobile-action[data-filter="completed"].active {
        box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.35), 0 6px 16px rgba(0,0,0,0.18);
    }
}
