:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: white;
    --text-primary: #333;
    --text-secondary: #888;
    --text-muted: #aaa;
    --border-color: #e0e0e0;
    --border-light: #eee;
    --accent-color: #4a90d9;
    --accent-hover: #357abd;
    --danger-color: #d9534f;
    --danger-hover: #c9302c;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --hover-bg: #fafafa;
    --drag-handle: #ccc;
    --drag-handle-hover: #888;
}

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --text-primary: #eee;
    --text-secondary: #aaa;
    --text-muted: #666;
    --border-color: #3a3a5c;
    --border-light: #2a2a4a;
    --accent-color: #5a9fd9;
    --accent-hover: #4a8fc9;
    --danger-color: #e96060;
    --danger-hover: #d94040;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --hover-bg: #1e2a4a;
    --drag-handle: #555;
    --drag-handle-hover: #888;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    padding: 40px 20px;
    transition: background 0.3s ease;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    padding: 30px;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

h1 {
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 30px;
    font-weight: 300;
    font-size: 2rem;
    transition: color 0.3s ease;
}

#todo-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#todo-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.2s, background 0.3s ease, color 0.3s ease;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

#todo-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

#todo-input::placeholder {
    color: var(--text-secondary);
}

#todo-form button {
    padding: 12px 24px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#todo-form button:hover {
    background: var(--accent-hover);
}

#loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

#todo-list {
    list-style: none;
}

.todo-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s, transform 0.2s;
    cursor: grab;
}

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

.todo-item.drag-over {
    border-top: 2px solid var(--accent-color);
    padding-top: 13px;
}

.drag-handle {
    color: var(--drag-handle);
    margin-right: 10px;
    cursor: grab;
    font-size: 14px;
    user-select: none;
    transition: color 0.2s;
}

.todo-item:hover .drag-handle {
    color: var(--drag-handle-hover);
}

.todo-item:hover {
    background: var(--hover-bg);
}

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

.todo-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 15px;
    cursor: pointer;
}

.todo-item .title {
    flex: 1;
    font-size: 16px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

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

.todo-item .delete-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 5px 10px;
}

.todo-item:hover .delete-btn {
    opacity: 1;
}

.todo-item .delete-btn:hover {
    color: var(--danger-hover);
}

#stats {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-light);
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

/* Theme Toggle */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle-label {
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.theme-toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    background: var(--border-color);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.theme-toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

[data-theme="dark"] .theme-toggle-switch {
    background: var(--accent-color);
}

[data-theme="dark"] .theme-toggle-switch::after {
    transform: translateX(24px);
}

.theme-toggle-checkbox {
    display: none;
}
