/* iOS Reminders-inspired To-Do List Styles */

:root {
  --bg-primary: #f2f2f7;
  --bg-secondary: #ffffff;
  --text-primary: #000000;
  --text-secondary: #8e8e93;
  --accent-blue: #007aff;
  --border-color: rgba(0, 0, 0, 0.1);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --checkbox-bg: #ffffff;
  --checkbox-border: #c7c7cc;
  --completed-text: #8e8e93;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --accent-blue: #0a84ff;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --checkbox-bg: #1c1c1e;
    --checkbox-border: #3a3a3c;
    --completed-text: #6e6e73;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.47;
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page {
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
}

/* Main container */
.todo-container {
  width: 100%;
  max-width: 600px;
  background: var(--bg-secondary);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Header */
.todo-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border-color);
}

.todo-header h1 {
  margin: 0 0 8px 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.task-count {
  margin: 0;
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Add task section */
.add-task {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

#new-task-input {
  flex: 1;
  font-size: 17px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

#new-task-input:focus {
  border-color: var(--accent-blue);
}

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

#add-task-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent-blue);
  color: white;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
}

#add-task-btn:hover {
  opacity: 0.8;
}

#add-task-btn:active {
  opacity: 0.6;
}

/* Task list */
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease;
  min-height: 56px;
}

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

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

/* Checkbox */
.task-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--checkbox-border);
  background: var(--checkbox-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
  color: white;
}

.task-checkbox:hover {
  border-color: var(--accent-blue);
}

.task-item.completed .task-checkbox {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.task-checkbox svg {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.task-item.completed .task-checkbox svg {
  opacity: 1;
}

/* Task text */
.task-text {
  flex: 1;
  font-size: 17px;
  color: var(--text-primary);
  word-break: break-word;
  transition: color 0.2s ease, text-decoration 0.2s ease;
}

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

/* Delete button */
.task-delete {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
  font-weight: 300;
}

.task-item:hover .task-delete {
  opacity: 1;
}

.task-delete:hover {
  background: rgba(255, 59, 48, 0.1);
  color: #ff3b30;
}

.task-delete:active {
  background: rgba(255, 59, 48, 0.2);
}

/* Empty state */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 17px;
  list-style: none;
}

/* Responsive design for mobile */
@media (max-width: 640px) {
  .page {
    padding: 0;
  }

  .todo-container {
    border-radius: 0;
    min-height: 100vh;
  }

  .todo-header h1 {
    font-size: 28px;
  }

  #new-task-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .task-delete {
    opacity: 1; /* Always visible on mobile */
  }
}

/* Animation for adding tasks */
@media (prefers-reduced-motion: no-preference) {
  .task-item {
    animation: slideIn 0.3s ease-out;
  }

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

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .task-delete {
    opacity: 1;
  }

  .task-checkbox {
    width: 28px;
    height: 28px;
  }

  #add-task-btn {
    width: 44px;
    height: 44px;
  }
}
