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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #06b6d4;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 0.5rem;
    --transition: all 0.3s ease;
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 700;
}

.month-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.nav-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

#currentMonth {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 180px;
}

/* 主要内容区域 */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* 日历样式 */
.calendar-section {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.weekday {
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.5rem;
    font-size: 0.875rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
}

.calendar-day {
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
    border-radius: calc(var(--radius) * 0.5);
    background: var(--bg-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 0.9rem;
}

.calendar-day:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.calendar-day.other-month {
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
}

.calendar-day.today {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.calendar-day.selected {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.calendar-day.has-todos::after {
    content: '•';
    position: absolute;
    bottom: 4px;
    right: 4px;
    color: var(--success-color);
    font-size: 0.8rem;
}

.calendar-day.selected.has-todos::after {
    color: white;
}

/* TODO区域样式 */
.todo-section {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
}

.todo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.todo-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: var(--bg-secondary);
    color: var(--danger-color);
}

.todo-input-area {
    margin-bottom: 1.5rem;
}

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

.todo-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
}

.todo-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.add-btn {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.add-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}

.todo-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

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

.todo-list {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
}

.todo-item {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
    animation: fadeIn 0.3s ease;
}

.todo-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.todo-item.completed {
    opacity: 0.6;
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

.todo-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--success-color);
}

.todo-text {
    flex: 1;
    color: var(--text-primary);
    word-break: break-word;
}

.todo-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.todo-delete {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: calc(var(--radius) * 0.5);
    cursor: pointer;
    font-size: 0.75rem;
    transition: var(--transition);
}

.todo-delete:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* 空状态样式 */
.empty-state {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    grid-column: span 2;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* 页脚样式 */
.footer {
    text-align: center;
    padding: 1rem;
    color: white;
    font-size: 0.875rem;
    opacity: 0.8;
}

/* 工具样式 */
.hidden {
    display: none !important;
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

/* 成功消息 */
.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideInRight 0.3s ease;
}

/* 动画定义 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

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

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

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

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

    .calendar-grid {
        gap: 0.25rem;
    }

    .calendar-day {
        font-size: 0.8rem;
    }

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

    .todo-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .empty-state {
        grid-column: span 1;
        padding: 2rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1rem;
    }

    .month-navigation {
        gap: 0.5rem;
    }

    .nav-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    #currentMonth {
        font-size: 1.2rem;
        min-width: 140px;
    }

    .calendar-section,
    .todo-section {
        padding: 1rem;
    }
}