/* ============================================================
   🔹 GLOBAL STYLES & RESET
============================================================ */
* {
  box-sizing: border-box;
  transition: background 0.3s, color 0.3s;
}

body {
  background-color: #f7f7f7;
  font-family: Arial, Helvetica, sans-serif;
  justify-content: center;
  align-items: flex-start;
  display: flex;
  padding: 2rem;
}

/* ============================================================
   🔹 MAIN CONTAINER
============================================================ */
#todo-container {
  background-color: #fff;
  padding: 1.5rem 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  width: 350px;
  transition: background 0.5s, color 0.5s;
}

/* ============================================================
   🔹 HEADINGS
============================================================ */
#todo-container h1 {
  text-align: center;
  margin-bottom: 1rem;
  color: #333;
}

/* ============================================================
   🔹 INPUT SECTION
============================================================ */
#input-section {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#taskInput {
  flex: 1;
  padding: 0.5rem;
  border-radius: 8px;
  font-size: 1rem;
  border: 1px solid #ccc;
}

#addBtn {
  flex: 0;
  background-color: green;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  transition: background 0.3s;
  cursor: pointer;
}

#addBtn:hover {
  background-color: #218838;
}

/* ============================================================
   🔹 DATE SECTION
============================================================ */
#date-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  border-color: var(--date-bg, #f0f0f0);
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  transition: background 0.3s, color 0.3s;
}

#date-section label {
  font-weight: bold;
  color: var(--date-bg, #333);
}

#date-section input[type="date"] {
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  background-color: white;
  color: #333;
  cursor: pointer;
  transition: background 0.3s, color 0.3s, border 0.3s;
}

#date-section input[type="date"]:hover {
  border-color: #007bff;
}

/* ============================================================
   🔹 DARK MODE DATE STYLES
============================================================ */
body.dark #date-section {
  --date-bg: #2b2b2b;
  --text-color: #f5f5f5;
}

body.dark #date-section input[type="date"] {
  background-color: #444;
  color: #fff;
  border-color: #666;
}

body.dark #date-section label {
  color: #ccc;
}

/* ============================================================
   🔹 DATE CONTROLS & TODAY BUTTON
============================================================ */
.date-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#todayBtn {
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.3s, transform 0.2s;
}

#todayBtn:hover {
  background-color: #0056b3;
  transform: scale(1.05);
}

body.dark #todayBtn {
  background-color: #4da3ff;
}

body.dark #todayBtn:hover {
  background-color: #1f75d9;
}

/* ============================================================
   🔹 CONFETTI ANIMATION
============================================================ */
.confetti {
  position: fixed;
  top: -10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  animation-name: fall;
  animation-timing-function: linear;
}

@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(100vh) rotate(360deg); }
}

/* ============================================================
   🔹 TASK LIST STYLES
============================================================ */
#taskList {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
}

#taskList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
  background: rgba(255,255,255,0.8);
  border-radius: 8px;
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

li.completed span {
  text-decoration: line-through;
  color: gray;
}

/* ============================================================
   🔹 CHECKBOX & BUTTONS IN TASKS
============================================================ */
.task-checkbox {
  margin-right: 0.5rem;
  width: 18px;
  height: auto;
  cursor: pointer;
}

li button {
  padding: 3px 6px;
  background-color: crimson;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
}

li button:hover {
  background-color: darkred;
}

/* ============================================================
   🔹 EDIT/DELETE BUTTON GROUP
============================================================ */
.btn-group {
  display: flex;
  gap: 0.4rem;
}

.btn-group button {
  padding: 4px 8px;
  font-size: 0.9rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-group button:first-child {
  background-color: #007bff;
  color: white;
}

.btn-group button:first-child:hover {
  background-color: #0056b3;
}

.btn-group button:last-child {
  background-color: crimson;
  color: white;
}

.btn-group button:last-child:hover {
  background-color: darkred;
}

/* ============================================================
   🔹 FILTER SECTION (ALL / COMPLETED / PENDING)
============================================================ */
#filter-section {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

#filter-section button {
  flex: 1;
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 20px;
  background-color: #eee;
  color: #333;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
  margin: 0 0.2rem;
  padding: 6px 12px;
}

#filter-section button:hover {
  background-color: #d1d1d1;
}

#filter-section button:active {
  background-color: #007bff;
  color: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* ============================================================
   🔹 TASK COUNTER & SUMMARY
============================================================ */
#taskCounter {
  text-align: right;
  font-size: 0.9rem;
  color: #555;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

body.dark #taskCounter {
  color: #ccc;
}

/* ============================================================
   🔹 CLEAR ALL BUTTON
============================================================ */
#clearAllBtn {
  background-color: #ff6600;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  width: 100%;
  margin-top: 1rem;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.3s;
}

#clearAllBtn:hover {
  background-color: #e65c00;
}

/* ============================================================
   🔹 THEME TOGGLE SWITCH
============================================================ */
#theme-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 25px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 34px;
}

.slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 3.5px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #2196f3;
}

input:checked + .slider::before {
  transform: translateX(24px);
}

/* ============================================================
   🔹 DARK MODE STYLING
============================================================ */
body.dark {
  background-color: #121212;
  color: #f1f1f1;
}

body.dark #todo-container {
  background-color: #1e1e1e;
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

body.dark input, 
body.dark button {
  background-color: #2b2b2b;
  color: white;
  border: 1px solid #444;
}

body.dark #todo-container h1 {
  color: #ccc;
}

body.dark li {
  border-bottom: 1px solid #444;
  color: #121212;
}

body.dark #clearAllBtn {
  background-color: #ff8c00;
}

body.dark #clearAllBtn:hover {
  background-color: #e67600;
}

/* ============================================================
   🔹 ANIMATIONS (FADE IN / SLIDE OUT)
============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); height: auto; margin-bottom: 0.5rem; }
  to { opacity: 0; transform: translateX(100%); height: 0; margin-bottom: 0; }
}

li {
  animation: fadeIn 0.3s ease forwards;
}

li.removing {
  animation: slideOut 0.4s ease forwards;
}

/* ============================================================
   🔹 RESPONSIVE STYLES
============================================================ */
@media (max-width: 480px) {
  body {
    padding: 1rem;
  }
  #todo-container {
    width: 100%;
    padding: 1rem;
  }
  #input-section {
    flex-direction: column;
  }
  #taskInput, #addBtn {
    width: 100%;
  }
  .date-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  #date-section {
    flex-direction: column;
    align-items: flex-start;
  }
  #filter-section {
    flex-direction: column;
    gap: 0.4rem;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  #todo-container {
    width: 90%;
  }
  #input-section {
    gap: 0.4rem;
  }
  #filter-section {
    gap: 0.3rem;
  }
}
