/* --- FONT & RESET --- */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* --- GAYA DASAR (MOBILE & TABLET SEBAGAI DEFAULT) --- */
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
  color: #e2e8f0;
  line-height: 1.4;
  /* Boleh di-scroll secara default */
}
.app-container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 20px;
  padding-top: 80px; /* Jarak dari atas */
  display: flex;
}

.header {
  position: fixed;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 8px 25px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 99px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(15px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  background: linear-gradient(135deg, #e2e8f0, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.main-layout {
  display: flex;
  flex-direction: column; /* Tata letak vertikal */
  gap: 20px;
  width: 100%;
}

.financial-ladder {
  display: flex;
  flex-direction: row; /* Navigasi menjadi baris */
  gap: 8px;
  overflow-x: auto; /* Bisa di-scroll ke samping */
  padding-bottom: 10px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.financial-ladder::-webkit-scrollbar {
  height: 0px;
}

.ladder-step {
  background: linear-gradient(
    135deg,
    rgba(30, 41, 59, 0.7),
    rgba(51, 65, 85, 0.6)
  );
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-width: 170px; /* Lebar minimum per item nav */
  min-height: 95px; /* Tinggi minimum per item nav */
}
.ladder-step:hover {
  border-color: rgba(148, 163, 184, 0.3);
}

.dashboard-content {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.controls-header {
  display: flex;
  flex-wrap: wrap; /* Tombol bisa pindah baris jika layar sempit */
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.dashboard-main-area {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.dashboard-row {
  display: flex;
  flex-wrap: wrap; /* KARTU AKAN OTOMATIS PINDAH BARIS */
  gap: 15px;
}

.card-wrapper {
  flex-grow: 1;
  flex-basis: 300px; /* Lebar dasar kartu, akan wrap jika tidak cukup ruang */
  min-width: 280px;
  display: flex;
}
.card-wrapper.priority {
  flex-basis: 350px;
}

.progress-history-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(
    135deg,
    rgba(30, 41, 59, 0.8),
    rgba(51, 65, 85, 0.6)
  );
  border-radius: 15px;
  padding: 15px;
  border: 1px solid rgba(148, 163, 184, 0.1);
  min-height: 250px; /* Beri tinggi minimum agar tidak gepeng */
}

/* ... (SISA GAYA ASLI ANDA) ... */
.ladder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
}
.ladder-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ladder-icon {
  font-size: 1rem;
}
.ladder-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f1f5f9;
}
.ladder-description {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-bottom: 5px;
}
.ladder-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 2px;
  overflow: hidden;
  margin-top: auto;
}
.ladder-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  border-radius: 2px;
}
.ladder-progress-text {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 3px;
  text-align: right;
}
.ladder-step.active {
  border-color: #06b6d4;
  background: linear-gradient(
    135deg,
    rgba(6, 182, 212, 0.2),
    rgba(51, 65, 85, 0.7)
  );
}
.priority-tag {
  background-color: #f59e0b;
  color: #1e293b;
  padding: 1px 6px;
  font-size: 0.6rem;
  font-weight: 800;
  border-radius: 4px;
}
.current-step-title {
  font-size: 1.6rem;
  font-weight: 800;
}
.toggle-form-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}
.toggle-form-btn:hover {
  transform: translateY(-2px);
}
.text-gradient-orange {
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.text-gradient-green {
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.text-gradient-red {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.card {
  background: linear-gradient(
    135deg,
    rgba(30, 41, 59, 0.8),
    rgba(51, 65, 85, 0.6)
  );
  border-radius: 15px;
  padding: 15px;
  border: 1px solid rgba(148, 163, 184, 0.1);
  display: flex;
  flex-direction: column;
  width: 100%;
}
.card-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}
.card-icon {
  font-size: 1.4rem;
  margin-right: 10px;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #cbd5e1;
}
.amount {
  font-size: 1.7rem;
  font-weight: 800;
  margin-bottom: auto;
}
.target {
  background: rgba(59, 130, 246, 0.1);
  padding: 6px 10px;
  border-radius: 8px;
  border-left: 3px solid #3b82f6;
  margin-top: 8px;
  width: 100%;
}
.target-label {
  font-size: 0.75rem;
  color: #94a3b8;
}
.target-value {
  font-size: 1rem;
  font-weight: 700;
  color: #3b82f6;
  display: flex;
  align-items: center;
  gap: 8px;
}
.edit-goal-icon {
  cursor: pointer;
  font-style: normal;
  font-weight: 400;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}
.edit-goal-icon:hover {
  opacity: 1;
}
.edit-goal-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.edit-goal-form input {
  flex-grow: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid #3b82f6;
  color: #e2e8f0;
  font-size: 1rem;
  font-weight: 700;
  padding: 2px 0;
  outline: none;
}
.edit-goal-form button {
  background: #3b82f6;
  border: none;
  color: white;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 0.7rem;
  cursor: pointer;
}
.projection-text {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 4px;
}
.card-wrapper.priority .card {
  align-items: center;
  justify-content: center;
  text-align: center;
}
.card-wrapper.priority .card-header {
  margin-bottom: 12px;
  justify-content: center;
}
.card-wrapper.priority .card-title {
  font-size: 1.1rem;
}
.card-wrapper.priority .amount {
  font-size: 2.5rem;
  margin-bottom: 0;
}
.card-wrapper.priority .target {
  margin-top: 15px;
}
.summary-card .card-title {
  margin-bottom: 5px;
}
.summary-card .summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-grow: 1;
}
.summary-card .summary-stat {
  text-align: center;
  padding: 5px;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.summary-card .summary-stat-value {
  font-size: 1rem;
  font-weight: 600;
}
.summary-card .summary-stat-label {
  font-size: 0.65rem;
  color: #94a3b8;
  line-height: 1.2;
}
.chart-container-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
  height: 100%;
}
.chart-canvas-container {
  position: relative;
  flex-grow: 1;
  min-width: 0;
  min-height: 0;
  height: 160px;
  max-height: 100%;
  max-width: 100%;
  overflow: hidden;
}
.chart-canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}
.custom-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  padding-left: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  font-size: 0.7rem;
  color: #94a3b8;
}
.legend-color-box {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
}
.section-title {
  font-size: 1.1rem;
  padding-bottom: 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
}
.history-table-container {
  overflow-y: auto;
  flex-grow: 1;
}
.history-table-container table {
  width: 100%;
  border-collapse: collapse;
}
.history-table-container th,
.history-table-container td {
  padding: 8px 10px;
  font-size: 0.8rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
.history-table-container th {
  font-weight: 600;
  color: #94a3b8;
  position: sticky;
  top: 0;
  background: #1e293b;
  z-index: 10;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.amount-history {
  color: #10b981;
  font-weight: 600;
}
.action-buttons button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 5px;
  opacity: 0.7;
  transition: opacity 0.3s ease, color 0.3s ease;
}
.action-buttons button:hover {
  opacity: 1;
}
.edit-btn {
  color: #3b82f6;
}
.edit-btn:hover {
  color: #60a5fa;
}
.delete-btn {
  color: #ef4444;
}
.delete-btn:hover {
  color: #f87171;
}
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 15, 35, 0.6);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.modal-content {
  background: linear-gradient(135deg, #1e293b, #16213e);
  padding: 30px;
  border-radius: 20px;
  width: 90%;
  max-width: 450px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  position: relative;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}
.modal-overlay.show .modal-content {
  transform: scale(1);
}
.close-modal-btn {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 2rem;
  cursor: pointer;
}
.update-title {
  font-size: 1.7rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 25px;
  text-align: center;
}
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 8px;
}
.form-input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  color: #e2e8f0;
  font-size: 1rem;
  transition: all 0.3s ease;
}
.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.bulk-btn {
  width: 100%;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}
.bulk-btn:hover {
  transform: translateY(-2px);
}
.toast-notification {
  position: fixed;
  top: 15px;
  left: calc(50% + 150px);
  color: white;
  padding: 10px 18px;
  border-radius: 99px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: 옆으로-나타나기-사라지기 4s ease-in-out forwards;
  white-space: nowrap;
}
.toast-notification.success {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}
.toast-notification.error {
  background: linear-gradient(135deg, #f87171, #ef4444);
}
@keyframes 옆으로-나타나기-사라지기 {
  0% {
    transform: translateX(50px);
    opacity: 0;
  }
  15% {
    transform: translateX(0);
    opacity: 1;
  }
  85% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(50px);
    opacity: 0;
  }
}
.button-group {
  display: flex;
  gap: 10px;
}
.auth-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}
.auth-btn:hover {
  transform: translateY(-2px);
}
.auth-btn.primary {
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: white;
}
.auth-btn.secondary {
  background: #334555;
  color: #e2e8f0;
  border: 1px solid #475569;
}

/* ================================================================================= */
/* ATURAN UNTUK LAYAR DESKTOP (TATA LETAK GRID SINGLE-WINDOW)                        */
/* ================================================================================= */
@media (min-width: 1200px) {
  body {
    overflow: hidden; /* Kunci single-window di desktop */
  }
  .app-container {
    height: 100vh;
    padding-top: 70px;
  }
  .main-layout {
    display: grid;
    grid-template-columns: 290px 1fr;
    height: 100%;
    min-height: 0;
  }
  .financial-ladder {
    flex-direction: column; /* Kembali ke vertikal */
    overflow-y: auto;
    padding-bottom: 0;
    height: 100%;
  }
  .ladder-step {
    min-width: 0;
    min-height: 0;
    flex-grow: 1;
  }
  .dashboard-content {
    height: 100%;
    min-height: 0;
  }
  .dashboard-main-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1;
    min-height: 0;
  }
  .dashboard-row {
    display: flex;
    flex-wrap: nowrap; /* Jangan wrap di desktop */
    flex: 1;
    min-height: 0;
  }
  .card-wrapper {
    flex-basis: auto; /* Hapus lebar dasar */
  }
  .card-wrapper.priority {
    flex: 1.5;
  }
  .card-wrapper.summary {
    flex: 1;
  }
  .card-wrapper.chart {
    flex: 1;
  }
  .progress-history-card {
    flex-shrink: 0;
    flex-basis: 28%;
    max-height: 28%;
    min-height: 140px;
  }
}
