/* Root Variables & Base */
:root {
  --bg-main: #fff;
  --bg-task: #f1f1f1;
  --bg-input: #fff;
  --text-main: #222;
  --text-secondary: #888;
  --border-main: #222;
  --border-task: #eee;
  --heading: #222;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-main: #181818;
    --bg-task: #232323;
    --bg-input: #222;
    --text-main: #f5f5f5;
    --text-secondary: #aaa;
    --border-main: #444;
    --border-task: #333;
    --heading: #f5f5f5;
  }
}

/* Global Styles */
body {
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Layout & Containers */
.main-content {
  flex: 1;
}

.container {
  width: 400px;
  margin: 50px auto;
  padding: 20px 30px;
  background: var(--bg-main);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Headings */
h2 {
  color: var(--heading);
  margin-bottom: 20px;
}

/* Inputs & Buttons */
input[type="text"], input[type="search"], input[type="email"], input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  font-size: 16px;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1.5px solid var(--border-main);
  border-radius: 8px;
  margin-bottom: 20px;
  outline: none;
}

input::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}

button {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  background-color: #28a745;
  border: none;
  color: white;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 5px 12px rgba(40, 167, 69, 0.3);
  transition: background 0.2s;
}

/* Button Container */
#button-container {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  margin-bottom: 1rem;
}

#add-item {
  flex: 1;
}

#delete-all {
  background: var(--bg-main);
  color: #dc3545;
  border: 1px solid var(--border-task);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  height: 48px;
  width: 48px;
  min-width: 48px;
  padding: 0;
}

#delete-all svg {
  display: block;
  margin: auto;
  fill: #dc3545;
  width: 22px;
  height: 22px;
  transition: fill 0.2s;
}

#delete-all:hover {
  background: #fff;
}

#delete-all:hover svg {
  fill: #dc3545;
}

#delete-all:active {
  background: #ffeaea;
}

/* Task List */
ul {
  list-style-type: none;
  padding-left: 0;
  margin-top: 20px;
}

li {
  background: var(--bg-task);
  color: var(--text-main);
  border: 1px solid var(--border-task);
  padding: 10px 14px;
  border-radius: 5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding-left: 44px;
}

/* Hide the default checkbox */
.complete-checkbox {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  width: 12px;
  height: 12px;
  cursor: pointer;
  z-index: 2;
}

/* Custom checkmark icon */
li .checkmark {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 2px solid #bbb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: border-color 0.2s;
}

li.completed .checkmark {
  border-color: #28a745;
  background: #28a745;
}

li .checkmark svg {
  display: none;
}

li.completed .checkmark svg,
li .checkmark svg {
  display: block;
  color: #fff;
  width: 10px;
  height: 10px;
}

.task-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
  white-space: normal;
  display: inline-block;
  font-size: 16px;
  word-break: break-word;
  color: var(--text-main);
}

/* Delete Button (Single Task) */
.delete {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  background: var(--bg-main);
  color: #dc3545;
  border: 1px solid var(--border-task);
  padding: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
  opacity: 0;
  margin-left: 10px;
}

li:hover .delete {
  opacity: 1;
}

.delete:hover {
  background: #ffeaea;
}

.completed .task-text {
  text-decoration: line-through;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Footer */
.footer {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 20px;
  background: var(--bg-main);
  border-top: 1px solid var(--border-task);
}

.footer a {
  color: #555;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}