/* Basic reset so spacing looks the same in all browsers */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* All the colours are kept here as variables (the light theme) */
:root {
  --bg: #eef2ff;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --heading: #4f46e5;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --border: #cbd5e1;
  --input-bg: #ffffff;
  --task-bg: #f8fafc;
  --task-border: #e2e8f0;
  --soft-bg: #f1f5f9;
  --soft-text: #475569;
  --soft-hover: #e2e8f0;
  --completed: #94a3b8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --shadow: rgba(79, 70, 229, 0.12);
}

/* The dark theme just changes the variable values */
body.dark {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --heading: #a5b4fc;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --border: #475569;
  --input-bg: #0f172a;
  --task-bg: #273449;
  --task-border: #334155;
  --soft-bg: #334155;
  --soft-text: #e2e8f0;
  --soft-hover: #3f4d63;
  --completed: #64748b;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --shadow: rgba(0, 0, 0, 0.4);
}

body {
  font-family: Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  padding: 20px;
  transition: background-color 0.3s, color 0.3s;
}

/* The card in the middle of the page */
.container {
  background-color: var(--card);
  max-width: 500px;
  margin: 40px auto;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 6px 18px var(--shadow);
  transition: background-color 0.3s;
}

/* Title row with the theme toggle button */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

h1 {
  font-size: 24px;
  color: var(--heading);
}

.theme-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background-color: var(--soft-bg);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.theme-btn:hover {
  background-color: var(--soft-hover);
}

/* The input box and the Add button row */
.input-area {
  display: flex;
  gap: 10px;
}

#taskInput {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  background-color: var(--input-bg);
  color: var(--text);
  border-radius: 6px;
  font-size: 16px;
}

#taskInput:focus {
  outline: none;
  border-color: var(--primary);
}

#addButton {
  padding: 10px 18px;
  border: none;
  background-color: var(--primary);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.2s;
}

#addButton:hover {
  background-color: var(--primary-hover);
}

/* Red message shown when the input is empty */
.error {
  color: var(--danger);
  font-size: 14px;
  min-height: 18px;
  margin-top: 6px;
}

/* The filter buttons row */
.filters {
  display: flex;
  gap: 8px;
  margin: 15px 0;
}

.filter-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  background-color: var(--soft-bg);
  color: var(--soft-text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.filter-btn:hover {
  background-color: var(--soft-hover);
}

/* The filter button that is currently selected */
.filter-btn.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* The task list */
ul {
  list-style: none;
}

li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background-color: var(--task-bg);
  padding: 12px;
  border: 1px solid var(--task-border);
  border-radius: 8px;
  margin-bottom: 10px;
}

li span {
  flex: 1;
  word-break: break-word;
}

li input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* How a completed task looks */
li.completed span {
  text-decoration: line-through;
  color: var(--completed);
}

/* The Edit button inside a task */
.edit-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  background-color: var(--soft-bg);
  color: var(--soft-text);
  transition: background-color 0.2s;
}

.edit-btn:hover {
  background-color: var(--soft-hover);
}

/* The Delete button inside a task */
.delete-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: white;
  font-size: 14px;
  background-color: var(--danger);
  transition: background-color 0.2s;
}

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

/* Message shown when the list is empty */
.empty {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  margin: 10px 0;
}

/* The footer row: counter on the left, clear button on the right */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.counter {
  color: var(--muted);
  font-size: 14px;
}

/* The "Clear completed" text button */
.clear-btn {
  border: none;
  background: none;
  color: var(--danger);
  font-size: 14px;
  cursor: pointer;
}

.clear-btn:hover {
  text-decoration: underline;
}

/* Helper class to hide an element */
.hidden {
  display: none;
}

/* Make it look good on small phone screens */
@media (max-width: 400px) {
  .input-area {
    flex-direction: column;
  }
}
