/* ==============================================================================
   style.css — Reka Bentuk Moden, Lembut, & Mesra Telefon Pintar (Mobile-First)
   Tema: Sage Green Lembut, Krim, Putih & Aksen Bersih
   ============================================================================== */

/* --- 1. Pembolehubah Warna & Asas (CSS Variables) --- */
:root {
  --color-primary: #4E7D65;       /* Sage green tenang */
  --color-primary-dark: #3B614E;  /* Sage green gelap untuk butang aktif */
  --color-primary-light: #EBF3EE; /* Sage green cair untuk latar kad aktif */
  --color-primary-border: #C5DCCE;
  
  --color-bg: #F7F6F2;           /* Background krim lembut */
  --color-card: #FFFFFF;         /* Putih bersih untuk kad */
  --color-card-subtle: #FAFAF7;   /* Warna latar kecil */
  
  --color-text-main: #243028;     /* Teks utama gelap & jelas */
  --color-text-muted: #6B7C72;    /* Teks pudar / penerangan */
  --color-border: #E5E9E4;        /* Garisan sempadan halus */
  
  --color-danger: #D94841;        /* Merah amaran lembut bila terlebih bajet */
  --color-danger-bg: #FDF1F0;     /* Latar merah lembut */
  --color-danger-border: #F7C8C5;
  
  --color-shopee: #EE4D2D;        /* Warna oren Shopee */
  --color-shopee-bg: #FEF3F0;     /* Latar lembut Shopee */
  --color-whatsapp: #25D366;      /* Hijau WhatsApp */
  --color-whatsapp-dark: #1EBE5D;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 6px rgba(46, 68, 55, 0.05);
  --shadow-md: 0 6px 18px rgba(46, 68, 55, 0.08);
  --shadow-sticky: 0 10px 25px rgba(36, 48, 40, 0.1);

  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- 2. CSS Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text-main);
  line-height: 1.5;
  font-size: 15px;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
}

/* Pembungkus Maksimum (Mobile Frame di desktop, lebar penuh di telefon) */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background-color: var(--color-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.03);
}

/* --- 3. Header Atas --- */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 14px;
  background: linear-gradient(180deg, #FFFFFF 0%, var(--color-bg) 100%);
}

.header-icon {
  font-size: 32px;
  background: var(--color-primary-light);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  border: 1px solid var(--color-primary-border);
  flex-shrink: 0;
}

.header-text h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-main);
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}

.header-text p {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* --- 4. Bahagian Atas: Sticky Budget Card --- */
.sticky-budget-card {
  position: sticky;
  top: 10px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  margin: 0 16px 16px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(229, 233, 228, 0.9);
  box-shadow: var(--shadow-sticky);
  transition: all 0.2s ease;
}

/* Input Bajet Anda */
.budget-input-group {
  margin-bottom: 12px;
}

.budget-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.currency-tag {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}

.input-with-prefix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-prefix .prefix {
  position: absolute;
  left: 14px;
  font-weight: 700;
  font-size: 16px;
  color: var(--color-text-main);
  pointer-events: none;
}

.budget-field {
  width: 100%;
  height: 48px;
  padding: 8px 14px 8px 46px;
  font-family: var(--font-family);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text-main);
  background: var(--color-card-subtle);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.budget-field:focus {
  border-color: var(--color-primary);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(78, 125, 101, 0.15);
}

.budget-field::placeholder {
  font-size: 13.5px;
  font-weight: 500;
  color: #A0AEC0;
}

/* Slider Interaktif Bajet */
.budget-slider-wrapper {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.budget-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #E5E9E4;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  margin: 6px 0 4px;
  transition: background 0.1s ease;
}

/* Tombol Slider (Thumb) - Webkit (Chrome, Safari, iOS, Edge) */
.budget-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid var(--color-primary);
  box-shadow: 0 2px 6px rgba(46, 68, 55, 0.25);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.budget-slider::-webkit-slider-thumb:hover,
.budget-slider::-webkit-slider-thumb:active {
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(78, 125, 101, 0.4);
}

/* Tombol Slider (Thumb) - Mozilla Firefox */
.budget-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid var(--color-primary);
  box-shadow: 0 2px 6px rgba(46, 68, 55, 0.25);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.budget-slider::-moz-range-thumb:hover,
.budget-slider::-moz-range-thumb:active {
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(78, 125, 101, 0.4);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 0 2px;
}

/* Paparan Grid: Sudah Beli & Baki */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--color-border);
  background: var(--color-card-subtle);
  transition: all 0.2s ease;
}

.stat-bought {
  border-color: #E2ECE5;
  background: #F4F8F5;
}

.stat-bought .stat-value {
  color: var(--color-primary);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
}

.stat-value {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

/* Gaya Baki Bajet: Positif vs Negatif */
.stat-balance {
  border-color: var(--color-border);
}

.stat-balance.is-negative {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  animation: gentlePulse 2s infinite ease-in-out;
}

.stat-balance.is-negative .stat-label {
  color: var(--color-danger);
}

.stat-balance.is-negative .stat-value {
  color: var(--color-danger);
}

@keyframes gentlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* --- 2 Kolum Simetri 50/50: Status Persiapan & Due Date --- */
.summary-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

/* Tajuk Selaras Bagi Kedua-dua Kolum (Sama persis dengan stat-label di atasnya, berada di tengah) */
.summary-grid-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 6px;
  line-height: 1.2;
  text-align: center;
  width: 100%;
}

/* Kolum Kiri: Status Persiapan (Dipusatkan / Centered) */
.status-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
}

.status-col .progress-bar-track {
  width: 100%;
  height: 7px;
  background: #E8ECE6;
  border-radius: 999px;
  overflow: hidden;
  margin: 3px 0 5px 0;
}

.status-col .progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #5CA47C, #4E7D65);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.status-col .progress-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-main);
  letter-spacing: -0.2px;
  white-space: nowrap;
  text-align: center;
  width: 100%;
}

/* Kolum Kanan: Due Date (Dipusatkan / Centered, Tanpa Kotak & Tanpa Border) */
.duedate-col {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  min-height: auto;
}

.due-date-native-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  font-size: 16px; /* Cegah auto-zoom di iOS Safari */
}

/* Lebarkan kawasan ikon kalendar dalaman supaya meliputi 100% ruang klik pada Chrome/Edge/Safari */
input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.duedate-display {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  user-select: none;
  pointer-events: none;
  min-height: 26px;
  text-align: center;
}

/* 1. Keadaan BELUM Pilih Tarikh (Arahan Ringkas, Kemas & Saiz Lembut) */
.duedate-prompt-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 26px;
}

.duedate-prompt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 13px; /* Setara dengan saiz font label Bajet Anda (13px) */
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 0.1px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.duedate-icon-svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.duedate-col:hover .duedate-prompt {
  color: var(--color-primary-dark);
}

/* 2. Keadaan SUDAH Pilih Tarikh (Sebaris Kemas, Saiz Besar & Tebal clamp(1.15rem, 4.6vw, 1.5rem)) */
.duedate-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  font-size: clamp(1.15rem, 4.6vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  line-height: 1.2;
  min-height: 26px;
}

/* Nombor & Perkataan HARI LAGI Sama Besar & Tebal */
.duedate-number {
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

.duedate-unit {
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  text-transform: uppercase;
}

/* Keadaan Khas: Hari Ini / Tahniah */
.duedate-special-badge {
  font-size: clamp(1.15rem, 4.6vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

/* Nota Kecil Anggaran Penuh */
.full-estimate-note {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--color-border);
  font-size: 11.5px;
  color: var(--color-text-muted);
}

.full-estimate-note strong {
  font-size: 13px;
  color: var(--color-text-main);
}

/* --- 5. Bahagian Tengah: Senarai Semak --- */
.checklist-main {
  padding: 0 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Seksyen Kategori */
.category-section {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.category-header {
  padding: 14px 16px;
  background: #FCFCF9;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.category-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-main);
}

.category-icon {
  font-size: 18px;
}

.category-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  padding: 2px 8px;
  border-radius: 12px;
}

/* Senarai Barang Dalam Kategori */
.items-list {
  list-style: none;
}

.item-row {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--color-border);
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

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

/* Bahagian Atas Baris: Checkbox + Nama Barang */
.item-header-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* Checkbox Khas yang Mesra Sentuhan Skrin Telefon */
.custom-checkbox-wrapper {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 1px;
}

.custom-checkbox-input {
  opacity: 0;
  position: absolute;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
  margin: 0;
}

.custom-checkbox-box {
  width: 24px;
  height: 24px;
  border: 2px solid #B8C7BE;
  border-radius: 7px;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: #FFFFFF;
}

.custom-checkbox-box svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.18s ease;
}

.custom-checkbox-input:checked + .custom-checkbox-box {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.custom-checkbox-input:checked + .custom-checkbox-box svg {
  opacity: 1;
  transform: scale(1);
}

/* Nama Barang */
.item-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-main);
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
  flex-grow: 1;
  transition: color 0.2s ease, text-decoration 0.2s ease;
}

/* UI bila sudah di-tick: strikethrough & pudar */
.item-row.is-completed {
  background-color: #FAFBF9;
}

.item-row.is-completed .item-label {
  text-decoration: line-through;
  color: #94A399;
}

/* Pudarkan butang Cari di Shopee untuk barang yang sudah dibeli (kekal boleh diklik) */
.item-row.is-completed .shopee-link {
  opacity: 0.4;
  filter: grayscale(80%);
}

.item-row.is-completed .shopee-link:hover,
.item-row.is-completed .shopee-link:active {
  opacity: 0.8;
  filter: grayscale(20%);
}

/* Bahagian Bawah Baris: Input Harga & Butang Shopee */
.item-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 36px; /* Selaras dengan teks selepas kotak checkbox */
  gap: 10px;
}

/* Input Harga Barang */
.price-input-wrapper {
  display: inline-flex;
  align-items: center;
  background: var(--color-card-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  height: 36px;
  transition: border-color 0.2s ease;
}

.price-input-wrapper:focus-within {
  border-color: var(--color-primary);
  background: #FFFFFF;
}

.price-prefix {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-right: 4px;
}

.price-input {
  width: 65px;
  border: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text-main);
  outline: none;
  padding: 0;
  text-align: left;
}

/* Hilangkan anak panah spinners input number */
.price-input::-webkit-outer-spin-button,
.price-input::-webkit-inner-spin-button,
.budget-field::-webkit-outer-spin-button,
.budget-field::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.price-input[type=number],
.budget-field[type=number] {
  -moz-appearance: textfield;
}

/* Butang Shopee */
.shopee-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-shopee);
  background: var(--color-shopee-bg);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 1px solid rgba(238, 77, 45, 0.2);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.shopee-link:hover, .shopee-link:active {
  background: #FEE8E2;
  transform: translateY(-1px);
}

.shopee-icon-svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

/* --- 6. Bahagian Bawah: Butang Tindakan --- */
.app-footer {
  padding: 10px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Butang Utama WhatsApp */
.btn-whatsapp {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-md);
  background-color: var(--color-whatsapp);
  color: #FFFFFF;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
  transition: all 0.2s ease;
}

.btn-whatsapp:hover {
  background-color: var(--color-whatsapp-dark);
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.45);
  transform: translateY(-1px);
}

.btn-whatsapp:active {
  transform: translateY(1px);
}

.whatsapp-icon {
  width: 22px;
  height: 22px;
}

/* Butang Reset Semula */
.reset-wrapper {
  display: flex;
  justify-content: center;
}

.btn-reset {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-family: var(--font-family);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reset:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

.reset-icon {
  width: 14px;
  height: 14px;
}

/* Bahagian Footer Kredit & Lencana ceklis */
.footer-credit {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  text-align: center;
}

.footer-text {
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.4;
}

.footer-by {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--color-text-muted);
}

.ceklis-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 4px;
  background: #FFFFFF;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  text-decoration: none;
  color: var(--color-text-main);
  box-shadow: 0 1px 3px rgba(46, 68, 55, 0.06);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}

.ceklis-pill:hover,
.ceklis-pill:active {
  background: var(--color-primary-lighter);
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 2px 6px rgba(78, 125, 101, 0.15);
  transform: translateY(-1px);
}

.ceklis-logo-img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

.ceklis-brand {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1;
}

.ceklis-pill-icon {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  opacity: 0.6;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.ceklis-pill:hover .ceklis-pill-icon {
  opacity: 1;
  transform: translate(1px, -1px);
}

.copyright {
  text-align: center;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Responsif: Skrin Sangat Kecil (iPhone SE / lebar < 360px) */
@media (max-width: 360px) {
  .item-controls-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .stat-value {
    font-size: 15px;
  }
}
