/* =========================================================
   CSS Custom Properties — light theme defaults
   ========================================================= */
:root {
    --primary:        #6366f1;
    --primary-dark:   #4f46e5;
    --primary-glow:   rgba(99, 102, 241, 0.18);
    --success:        #10b981;
    --danger:         #ef4444;
    --text-primary:   #1e293b;
    --text-secondary: #64748b;
    --bg-page:        white;
    --bg-item:        #f8fafc;
    --border:         #e2e8f0;
    --container-bg:   rgba(255, 255, 255, 0.97);
    --shadow-container: 0 24px 64px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(255, 255, 255, 0.6);
    --shadow-item:    0 4px 18px rgba(0, 0, 0, 0.07);
}

/* =========================================================
   Reset & Base
   ========================================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 48px 20px 80px;
}

/* =========================================================
   Container
   ========================================================= */
.container {
    background: var(--container-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 40px;
    border-radius: 24px;
    box-shadow: var(--shadow-container);
    width: 100%;
    max-width: 560px;
    animation: fadeInUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(28px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Header
   ========================================================= */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#themeToggleBtn {
    padding: 8px 18px;
    background: var(--bg-item);
    color: var(--text-secondary);
    border: 2px solid var(--border);
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
    white-space: nowrap;
}

#themeToggleBtn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* =========================================================
   Stats Bar
   ========================================================= */
.stats-bar {
    margin-bottom: 24px;
}

.stats-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.progress-track {
    height: 5px;
    background: var(--border);
    border-radius: 100px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #34d399);
    border-radius: 100px;
    transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    width: 0%;
}

/* =========================================================
   Input
   ========================================================= */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

#todoInput.shake {
    animation: shake 0.35s ease-out;
    border-color: var(--danger);
}

.input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
}

#todoInput {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 14px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-item);
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

#todoInput::placeholder {
    color: var(--text-secondary);
    font-weight: 400;
}

#todoInput:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-page);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

#addBtn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 22px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    white-space: nowrap;
}

.btn-icon {
    font-size: 20px;
    line-height: 1;
    font-weight: 300;
}

#addBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

#addBtn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* =========================================================
   Todo List
   ========================================================= */
#todoList {
    list-style: none;
}

/* =========================================================
   Todo Item
   ========================================================= */
.todo-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 16px;
    background: var(--bg-item);
    border-radius: 14px;
    border: 2px solid transparent;
    margin-bottom: 10px;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
    overflow: hidden;
}

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

@keyframes slideOut {
    0%  { opacity: 1; transform: translateX(0);     max-height: 200px; margin-bottom: 10px; padding-top: 15px; padding-bottom: 15px; }
    55% { opacity: 0; transform: translateX(28px);  max-height: 200px; margin-bottom: 10px; }
    100%{ opacity: 0; transform: translateX(28px);  max-height: 0;    margin-bottom: 0;    padding-top: 0;    padding-bottom: 0;  border-width: 0; }
}

.todo-item.removing {
    animation: slideOut 0.35s ease-out forwards;
    pointer-events: none;
}

.todo-item:hover {
    border-color: var(--border);
    background: var(--bg-page);
    box-shadow: var(--shadow-item);
}

/* =========================================================
   Custom Checkbox
   ========================================================= */
.todo-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2.5px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    position: relative;
}

.todo-checkbox:hover {
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.todo-checkbox:checked {
    background: var(--success);
    border-color: var(--success);
}

.todo-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: 2.5px solid white;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

/* =========================================================
   Todo Text
   ========================================================= */
.todo-text {
    flex: 1;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    cursor: pointer;
    word-break: break-word;
    transition: color 0.25s, opacity 0.25s, text-decoration 0.25s;
    user-select: none;
}

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

/* =========================================================
   Delete Button
   ========================================================= */
.delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    background: transparent;
    color: var(--border);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    transform: scale(1.15);
}

/* =========================================================
   Empty State
   ========================================================= */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 48px 20px;
    font-size: 15px;
    line-height: 1.6;
}

.empty-state-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 14px;
}

/* =========================================================
   Dark Theme
   ========================================================= */
body.dark-theme {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}

body.dark-theme {
    --text-primary:   #f1f5f9;
    --text-secondary: #94a3b8;
    --bg-page:        #1e293b;
    --bg-item:        #0f172a;
    --border:         #334155;
    --primary-glow:   rgba(99, 102, 241, 0.22);
    --container-bg:   rgba(15, 23, 42, 0.97);
    --shadow-container: 0 24px 64px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --shadow-item:    0 4px 18px rgba(0, 0, 0, 0.3);
}

body.dark-theme .container {
    box-shadow: var(--shadow-container);
}

body.dark-theme #todoInput {
    color: var(--text-primary);
}

body.dark-theme #todoInput:focus {
    background: #1e293b;
}

