/* === GLOBAL STYLE === */
body {
  font-family: "Poppins", "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #75928d, #999caa);
  color: #333;
  margin: 0;
  padding: 0;
  line-height: 1.5;
  overflow-x: hidden;
}

/* === CONTAINER === */
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: -webkit-fill-available; /* Perbaikan untuk browser mobile */
  overflow: hidden;
}

/* === HEADER === */
.top-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 15px;
}

/* BARIS 1: Judul + user + logout */
.header-row {
  display: flex;
  justify-content: center; /* Judul di tengah */
  align-items: center;
  position: relative;
}

/* Judul */
.header-row h1 {
  font-size: 1.7em;
  color: #2c3e50;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  margin: 0;
}

/* USER + LOGOUT AREA */
.user-area-container {
  position: absolute;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Username badge */
.user-label {
  font-weight: bold;
  font-size: 14px;
  background: rgba(128, 211, 153, 0.647);
  padding: 6px 12px;
  border-radius: 6px;
  color: #2c3e50;
}

/* Tombol Logout */
.logout-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: #e74c3c;
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

.logout-btn:hover {
  background: #c0392b;
}

/* === WEEK NAVIGATION & SEARCH === */
.week-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 1.0em;
  color: #242323;
  position: relative;
}

/* Tombol nav */
.week-nav button {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.3s;
}

.week-nav button:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

/* FITUR BARU: Pencarian (Diletakkan di kanan minggu selanjutnya) */
.search-wrapper {
  position: absolute;
  right: 15px;
}


.search-container {
  position: relative;
  width: 220px;
}

#searchInput {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  outline: none;
  transition: all 0.3s ease;
}

#searchInput:focus {
  background: white;
  box-shadow: 0 0 8px rgba(52, 152, 219, 0.3);
  border-color: #3498db;
}

.suggestions-box {
  position: absolute;
  top: 110%;
  right: 0;
  width: 280px; /* Sedikit lebih lebar dari input agar info tanggal muat */
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  z-index: 2000;
  max-height: 300px;
  overflow-y: auto;
  display: none; /* Muncul via JS */
  border: 1px solid #eee;
}

.suggestion-item {
  padding: 10px 15px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  text-align: left;
  transition: background 0.2s;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background-color: #f0f7ff;
}

.suggestion-text {
  display: block;
  font-weight: 600;
  color: #2c3e50;
  font-size: 13px;
  margin-bottom: 2px;
}

.suggestion-date {
  display: block;
  font-size: 11px;
  color: #7f8c8d;
}

/* === GRID === */
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 10px;
  flex: 1;
  opacity: 1;
  transition: all 0.5s ease;
  padding: 0 5px;
}

/* === DAY COLUMN === */
.day-column {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  padding: 6px;
  height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);

}

.day-column.today {
  background: linear-gradient(180deg, #fff6df, #ffedc2);
  border: 1px solid #f2d48a;
  box-shadow: 0 0 10px rgba(168, 201, 235, 0.4);
  transform: scale(1.01);
}

.day-header {
  font-weight: bold;
  color: #34495e;
  font-size: 1em;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding-bottom: 3px;
  text-align: center;
}

/* === TASK LIST & ITEMS === */
.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}

.task-item {
  margin-bottom: 5px;
  padding: 6px 8px;
  border-left: 3px solid #3498db;
  border-radius: 6px;
  font-size: 0.85em;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;   
  align-items: center;
  background-color: #fff;
  position: relative;
  min-height: 20px;
}

.task-main {
  display: flex;
  align-items: center;
  flex: 1;
  margin-right: 5px;
  word-break: break-word;
}

.task-item:hover {
  transform: scale(1.02);
  background-color: #f9f9f9;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.task-item.completed {
  text-decoration: line-through;
  opacity: 0.6;
  border-left-color: #27ae60;
}

/* Aksi Tombol (Pindah & Hapus) */
.task-actions {
  display: none;
  gap: 4px;
}

.task-item:hover .task-actions {
  display: flex;
}

.move-btn, .delete-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: white;
  font-size: 12px;
  transition: all 0.2s;
}

.move-btn { background: #3498db; }
.delete-btn { background: #e74c3c; }

.move-btn:hover { background: #2980b9; }
.delete-btn:hover { background: #c0392b; }

/* === ADD TASK SECTION === */
.add-task-section {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 6px;
  backdrop-filter: blur(5px);
}

.add-task-section input,
.add-task-section select,
.add-task-section button {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.add-task-section button {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: white;
  font-weight: bold;
  cursor: pointer;
}

/* === INSTRUCTIONS === */
.instructions {
  text-align: center;
  font-size: 0.85em;
  color: #2c3e50;
  padding-bottom: 10px;
}

/* === MODAL & LOGIN === */
.login-page {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  display: flex; justify-content: center; align-items: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 9999;
}

.login-card {
  width: 320px;
  padding: 30px;
  border-radius: 15px;
  background: white;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  text-align: center;
}

.login-input {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-sizing: border-box;
}

.modal {
  display: none;
  position: fixed;
  z-index: 3000;
  left: 0; top: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
}

.modal-content {
  background: white;
  margin: 10% auto;
  padding: 25px;
  border-radius: 12px;
  width: 320px;
  text-align: center;
}

/* Drag & Drop Styles */
.task-item.dragging {
  opacity: 0.5;
  border: 2px dashed #3498db;
}

.drop-hint {
  background: rgba(52, 152, 219, 0.1);
  border: 2px dashed #3498db;
  height: 40px;
  border-radius: 6px;
  margin-bottom: 5px;
}

/* === FUNGSI WARNA PELANGI OTOMATIS (KEMBALI DI SINI) === */
.task-item:nth-child(7n + 1) { background: linear-gradient(90deg, rgba(255,99,132,.15), rgba(255,99,132,.25)); }
.task-item:nth-child(7n + 2) { background: linear-gradient(90deg, rgba(255,159,64,.15), rgba(255,159,64,.25)); }
.task-item:nth-child(7n + 3) { background: linear-gradient(90deg, rgba(255,205,86,.15), rgba(255,205,86,.25)); }
.task-item:nth-child(7n + 4) { background: linear-gradient(90deg, rgba(75,192,192,.15), rgba(75,192,192,.25)); }
.task-item:nth-child(7n + 5) { background: linear-gradient(90deg, rgba(54,162,235,.15), rgba(54,162,235,.25)); }
.task-item:nth-child(7n + 6) { background: linear-gradient(90deg, rgba(153,102,255,.15), rgba(153,102,255,.25)); }
.task-item:nth-child(7n + 7) { background: linear-gradient(90deg, rgba(255,99,255,.15), rgba(255,99,255,.25)); }

/* === RESPONSIVE UNTUK HP / ANDROID === */

/* === PERBAIKAN KHUSUS MOBILE (PORTRAIT & LANDSCAPE) === */
@media (max-width: 915px) { /* Range umum untuk HP Landscape */
  
  /* 1. Header & User Area */
  .header-row {
    flex-direction: column;
    padding-bottom: 5px;
  }

  .user-area-container {
    position: relative; /* Lepaskan absolute agar tidak menumpuk */
    right: auto;
    align-items: center;
    margin-bottom: 10px;
  }

  /* 2. Navigasi Minggu & Pencarian (Solusi Utama) */
  .week-nav {
    display: grid; /* Gunakan grid untuk kontrol tata letak lebih baik */
    grid-template-columns: auto 1fr auto; /* Tombol - Info Minggu - Tombol */
    justify-items: center;
    gap: 10px;
    padding: 0 10px;
    position: relative;
  }

  /* Judul Minggu ke-X */
  #currentWeek {
    grid-column: 2;
    font-size: 0.9em;
    font-weight: bold;
  }

  /* Pindahkan Wrapper Pencarian ke baris baru di bawah navigasi */
  .search-wrapper {
    position: relative; /* Lepaskan dari absolute kanan */
    right: auto;
    grid-column: 1 / span 3; /* Membentang selebar navigasi */
    width: 100%;
    margin-top: 8px;
  }

  .search-container {
    width: 100%; /* Kotak pencarian selebar layar */
    max-width: 400px; /* Batasi agar tidak terlalu panjang di landscape */
    margin: 0 auto;
  }

  /* 3. Penyesuaian Grid & Kolom */
  .schedule-grid {
    height: auto;
    padding-bottom: 20px;
  }

  .day-column {
    /* Di landscape, kita beri tinggi yang cukup agar tidak terpotong */
    height: calc(100vh - 120px); 
    min-height: 300px;
  }

  /* 4. Area Input (Tambah Tugas) */
  .add-task-section {
    padding: 5px;
    gap: 5px;
  }

  .add-task-section input, 
  .add-task-section select, 
  .add-task-section button {
    font-size: 14px;
    padding: 8px;
  }
}

/* Tambahan khusus jika layar sangat pendek (Landscape murni) */
@media (max-height: 500px) {
  .top-header {
    padding: 5px 10px;
  }
  .header-row h1 {
    font-size: 1.2em;
  }
  .day-column {
    height: 250px; /* Perkecil tinggi kolom agar scroll halaman utama berfungsi */
  }
}