/* Variabel warna dasar untuk tema terang dan gelap */
:root {
  --bg-light: #f0f4f8;
  --bg-dark: #151818;
  --card-light: #ffffff;
  --card-dark: #2a2e31;
  --text-light: #1c1c1e;
  --text-dark: #e1e1e1;
  --accent: #4a90e2;
  --accent-hover: #357ab8;
  --border-light: #d0d5dd;
  --border-dark: #3a3f44;
  --shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
  --shadow-1: 0 4px 8px rgba(0, 0, 0, 0.2);
  --shadow-hover: 0 15px 30px rgba(0, 0, 0, 0.1);
}

/* Gaya dasar untuk body */
body {
  font-family: "Inter", sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--card-light);
  color: var(--text-light);
  transition: background-color 0.3s, color 0.3s;
}

/* Container utama aplikasi */
.app {
  max-width: 900px;
  margin: 40px auto;
  padding: 30px;
  background: var(--bg-light);
  border-radius: 16px;
  box-shadow: var(--shadow-1);
  transition: background 0.3s, box-shadow 0.3s;
}

/* Tombol Install Aplikai */
#installBtn {
  display: none; /* Awalnya tetap disembunyikan */
  padding: 10px 20px;
  background-color: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.2s;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
}

#installBtn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

#installBtn i {
  font-size: 1.2rem;
}

/* Header dan tombol tema */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

h1 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: -0.5px;
}

#toggleTheme {
  font-size: 1.6rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.3s;
}

/* Form input tambah tugas */
.form-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.form-section input,
.form-section select,
.form-section button {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 1rem;
  border: 1px solid var(--border-light);
  background: var(--card-light);
  transition: border-color 0.3s, background-color 0.3s;
}

.form-section input:focus,
.form-section select:focus {
  border-color: var(--accent);
  outline: none;
}

.form-section button {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.form-section button:hover {
  background: var(--accent-hover);
}

/* Bagian Daftar Tugas */
h2 {
  text-align: center;
  position: relative;
  margin: 30px 0 20px;
  padding-top: 15px;
  font-weight: 700;
  font-size: 1.8rem;
}

/* Statistik tugas */
.stats {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1 1 200px;
  background: var(--card-light, #ffffff);
  padding: 20px;
  border-radius: 16px;
  box-shadow: var(--shadow, 0 4px 12px rgba(0, 0, 0, 0.1));
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
}

.stat-icon {
  font-size: 24px;
  padding: 12px;
  border-radius: 50%;
  background-color: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.total {
  background-color: #2196f3;
  color: white;
}

.stat-icon.done {
  background-color: #4caf50;
  color: white;
}

.stat-icon.active {
  background-color: #ff9800;
  color: white;
}

.stat-card p {
  margin: 0;
  font-size: 16px;
  color: #000;
}

.stat-card span {
  font-size: 24px;
  font-weight: bold;
  color: #000;
}

/* Filter Kategori */
#categoryFilter {
  width: 100%;
  padding: 10px;
  margin-bottom: 20px;
  font-size: 1rem;
  border-radius: 6px;
  border: 1px solid var(--border-light);
}

/* Kolom pencarian tugas */
#searchTask {
  width: 96%;
  padding: 12px 16px;
  margin-bottom: 25px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--card-light);
  transition: border-color 0.3s;
}

#searchTask:focus {
  border-color: var(--accent);
  outline: none;
}

/* Tombol Filter Semua, Belum, dan Selesai */
.button-semua {
  background-color: #2196f3;
  color: white;
  padding: 6px 12px;
  border: none;
  margin-right: 6px;
  border-radius: 5px;
  cursor: pointer;
}

.button-semua:hover {
  filter: brightness(0.9);
}

.button-belum {
  background-color: #f44336;
  color: white;
  padding: 6px 12px;
  border: none;
  margin-right: 6px;
  border-radius: 5px;
  cursor: pointer;
}

.button-belum:hover {
  filter: brightness(0.9);
}

.button-selesai {
  background-color: #4caf50;
  color: white;
  padding: 6px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.button-selesai:hover {
  filter: brightness(0.9);
}

/* Tombol Hapus Semua Tugas */
.button-hapus-semua {
  background-color: #dc3545;
  color: white;
  padding: 6px 12px;
  border: none;
  margin-right: 6px;
  border-radius: 5px;
  cursor: pointer;
}

.button-hapus-semua:hover {
  filter: brightness(0.9);
}

/* Daftar tugas */
#taskList {
  list-style: none;
  padding: 0;
  margin: 0;
}

#taskList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--card-light);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.3s;
}

#taskList li:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

/* Gaya untuk tugas yang sudah diselesaikan */
#taskList li.completed {
  background-color: #c6ead9; /* lebih gelap dari #eafaf1 */
  border-color: #22a55f; /* hijau tua yang matching */
  color: #064e3b; /* warna teks hijau gelap */
  text-decoration: line-through;
}

/* Informasi tugas */
.task-info {
  flex: 1;
  margin-right: 20px;
}

.task-info strong {
  display: block;
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.task-meta {
  font-size: 0.9rem;
  color: #6b7280;
}

/* Tombol aksi tugas (selesai & hapus) */
.task-actions button {
  background: none;
  border: none;
  font-size: 1.4rem;
  margin-left: 12px;
  cursor: pointer;
  transition: color 0.2s;
}

.task-actions button.done {
  color: #34d399;
}

.task-actions button.delete {
  color: #ef4444;
}

.task-actions button.done:hover {
  color: #059669;
}

.task-actions button.delete:hover {
  color: #b91c1c;
}

/* Modal pop-up reminder */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  width: 100%;
  height: 100vh; /* Ganti dari 100% ke 100vh */
  background-color: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--card-light);
  padding: 24px;
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  max-width: 440px;
  width: 90%; /* Tambahkan agar muat di layar sempit */
  text-align: center;
  position: relative;
}

.modal-content h2 {
  margin-bottom: 12px;
}

.close-btn {
  position: absolute;
  right: 16px;
  top: 16px;
  font-size: 2.3rem;
  font-weight: bold;
  cursor: pointer;
  color: #f44336;
}

.close-btn:hover {
  filter: brightness(0.9);
}

/* Animasi */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Footer */
footer {
  text-align: center;
  padding: 0 0 10px;
}

footer p,
a {
  color: #555;
}

/* Mode gelap */
body.dark {
  background-color: var(--bg-dark);
  color: var(--text-dark);
}

body.dark .app {
  background: var(--card-dark);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

body.dark .dark-mode {
  color: var(--text-dark);
}

body.dark input,
body.dark select,
body.dark #searchTask,
body.dark #categoryFilter {
  background: #1f2426;
  border: 1px solid var(--border-dark);
  color: var(--text-dark);
}

body.dark #taskList li {
  background: #1f2426;
  border-color: var(--border-dark);
}

body.dark #taskList li.completed {
  background-color: #064e3b;
  border-color: #10b981;
  color: #bbf7d0;
}

body.dark .modal-content {
  background: #1f2426;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

body.dark .stat-card {
  background: #1f2426;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

body.dark .stat-card p {
  color: var(--text-dark);
}

body.dark .stat-card span {
  color: var(--text-dark);
}

body.dark footer p,
body.dark footer a {
  color: #aaa;
}

body.dark .modal1 {
  background-color: rgba(255, 255, 255, 0.1);
}

body.dark .modal-content1 {
  background-color: var(--bg-dark);
  color: var(--text-dark);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .app {
    margin: 20px auto;
    padding: 20px;
    border-radius: 12px;
  }

  .install-container {
    flex-direction: column; /* Susun vertikal */
    align-items: flex-start; /* Rata kiri */
  }

  #installBtn {
    width: 100%; /* Tombol full lebar */
    justify-content: center; /* Ikon dan teks rata tengah */
  }

  .header-links {
    margin-bottom: 30px;
  }

  .header-links a,
  .header-links span {
    margin: 0; /* Hapus margin horizontal */
    text-align: left; /* Rata kiri */
  }

  header {
    flex-direction: row; /* Ubah kembali jadi horizontal */
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }

  h1 {
    font-size: 1.7rem;
    margin: 0;
  }

  #toggleTheme {
    font-size: 1.6rem;
    margin-left: auto;
  }

  .form-section {
    grid-template-columns: 1fr; /* stack input */
    gap: 12px;
    margin-top: -15px;
  }

  .form-section input,
  .form-section select,
  .form-section button {
    font-size: 0.95rem;
    padding: 10px 14px;
  }

  .stats {
    flex-wrap: wrap;
  }

  .stat-card {
    flex: 1 1 calc(50% - 50px); /* 2 kartu per baris dengan gap */
  }

  .stat-card:nth-child(3) {
    flex: 1 1 100%; /* Kartu ke-3 (Selesai) full lebar */
  }

  #searchTask {
    width: 90%;
    font-size: 1rem;
    padding: 10px 14px;
  }

  #categoryFilter {
    font-size: 1rem;
    padding: 10px;
  }

  .filter-container {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-buttons {
    width: 100%;
    justify-content: space-between;
  }

  /* .button-hapus-semua {
    width: 100%;
  } */

  #taskList li {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px;
  }

  .task-info {
    margin-right: 0;
    margin-bottom: 10px;
  }

  .task-actions {
    align-self: flex-end;
  }

  .task-actions button {
    font-size: 1.3rem;
    margin-left: 8px;
  }

  .modal-content {
    max-width: 80%;
    padding: 16px;
  }
  .close-btn {
    font-size: 2rem;
    right: 12px;
    top: 12px;
  }

  footer {
    font-size: 0.9rem;
    padding: 0 30px;
  }
}
