/* =========================
   THEME (dark par défaut)
   ========================= */
:root {
  --bg-a: #050607;
  --bg-b: #6f7688; /* proche de ton dégradé */
  --card: #3f3f3f; /* proche de ton container #464343 */
  --card-2: #4a4a4a;
  --border: rgba(207, 207, 207, 0.25);

  --text: #e9e9e9;
  --text-soft: rgba(233, 233, 233, 0.75);

  --input-bg: #d7d7d7; /* proche de ton #cfcfcf mais un peu plus doux */
  --input-text: #2b2b2b;

  --btn: #d0d0d0;
  --btn-hover: #bfbfbf;

  --danger: #e74c3c;
  --danger-hover: #c0392b;

  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 10px 20px rgba(0, 0, 0, 0.25);

  --radius: 16px;
  --radius-sm: 12px;
  --gap: 12px;
}

:root[data-theme="light"] {
  --bg-a: #f2f3f6;
  --bg-b: #c9cedb;
  --card: #ffffff;
  --card-2: #f4f5f7;
  --border: rgba(17, 24, 39, 0.12);

  --text: #1f2937;
  --text-soft: rgba(31, 41, 55, 0.65);

  --input-bg: #ffffff;
  --input-text: #111827;

  --btn: #1f2937;
  --btn-hover: #111827;

  --shadow: 0 18px 50px rgba(17, 24, 39, 0.18);
  --shadow-soft: 0 10px 20px rgba(17, 24, 39, 0.12);
}

/* =========================
     BASE
     ========================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);

  /* même vibe que ton gradient, mais plus clean */
  background: radial-gradient(
      900px 500px at 20% 10%,
      rgba(207, 207, 207, 0.12),
      transparent 55%
    ),
    radial-gradient(800px 420px at 85% 0%, rgba(0, 0, 0, 0.25), transparent 60%),
    linear-gradient(135deg, var(--bg-a), var(--bg-b));

  display: grid;
  place-items: center;
  padding: 22px;
}

header {
  display: flex;
  justify-content: space-between;
  height: 30.4px;
  margin-bottom: 15px;
}

/* =========================
     CONTAINER
     ========================= */
.app-container {
  width: min(430px, 100%);
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

/* Titre */
.app-container h1 {
  margin: 0 0 14px;
  font-size: clamp(1.35rem, 2.8vw, 1.9rem);
  letter-spacing: 0.2px;
  color: var(--text);
}

/* petit “sous-ton” optionnel si tu ajoutes un <p> */
.app-container p {
  margin: -6px 0 14px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

/* =========================
     FORM (propre + responsive)
     ========================= */
#todo-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--gap);
  margin-bottom: 16px;
}

/* input */
#todo-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  outline: none;

  background: var(--input-bg);
  color: var(--input-text);

  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

#todo-input::placeholder {
  color: rgba(43, 43, 43, 0.55);
}

:root[data-theme="light"] #todo-input::placeholder {
  color: rgba(17, 24, 39, 0.45);
}

#todo-input:focus {
  border-color: rgba(207, 207, 207, 0.65);
  box-shadow: 0 0 0 4px rgba(207, 207, 207, 0.18);
  transform: translateY(-1px);
}

/* bouton Add */
button {
  border: none;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.2px;
}

#todo-form button {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--btn);
  color: var(--card);
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, filter 0.2s ease;
}

:root[data-theme="light"] #todo-form button {
  color: #ffffff;
}

#todo-form button:hover {
  transform: translateY(-1px);
  filter: brightness(0.95);
}

#todo-form button:active {
  transform: translateY(0px);
}

/* =========================
     LISTE
     ========================= */
#todo-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

/* item */
#todo-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;

  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);

  background: var(--input-bg);
  color: var(--input-text);

  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

#todo-list li:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

/* checkbox */
.task-toggle {
  width: 18px;
  height: 18px;
  cursor: pointer;
  transform: scale(1.12);
  accent-color: #8b8f97;
}

/* completed */
#todo-list li.completed {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(43, 43, 43, 0.55);
  text-decoration: line-through;
}

:root[data-theme="light"] #todo-list li.completed {
  background: #f1f2f4;
  color: rgba(17, 24, 39, 0.45);
}

/* bouton delete (style clean, pas agressif) */
.delete-btn {
  background: transparent;
  border: 1px solid rgba(231, 76, 60, 0.35);
  color: var(--danger);
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.delete-btn:hover {
  transform: translateY(-1px);
  background: rgba(231, 76, 60, 0.12);
  border-color: rgba(231, 76, 60, 0.6);
}

.delete-btn:active {
  transform: translateY(0px);
}

/* =========================
   THEME TOGGLE (icônes)
   ========================= */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);

  background: rgba(255, 255, 255, 0.06);
  color: var(--text);

  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, background 0.2s ease;
}

:root[data-theme="light"] .theme-toggle {
  background: rgba(0, 0, 0, 0.04);
}

.theme-toggle:hover {
  transform: translateY(-1px);
}

.theme-toggle:active {
  transform: translateY(0px);
}

.theme-toggle .icon {
  font-size: 1.05rem;
  line-height: 1;
}

/* Affiche l'icône correcte selon le thème */
:root[data-theme="dark"] .theme-toggle .sun {
  display: none;
}
:root[data-theme="light"] .theme-toggle .moon {
  display: none;
}

/* =========================
     RESPONSIVE (mobile)
     ========================= */
@media (max-width: 520px) {
  body {
    padding: 14px;
    align-items: start;
    place-items: start center;
  }

  .app-container {
    padding: 16px;
  }

  #todo-form {
    grid-template-columns: 1fr;
  }

  #todo-form button {
    width: 100%;
  }

  /* items plus lisibles sur mobile */
  #todo-list li {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "check text"
      "delete delete";
    align-items: start;
  }

  #todo-list li .task-toggle {
    grid-area: check;
    margin-top: 2px;
  }

  #todo-list li .delete-btn {
    grid-area: delete;
    width: 100%;
  }
}

/* Motion respect */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
