/* =========================================================
   TRADING PROFIT CALENDAR — STYLE
   Tema: hitam/abu premium, tanpa emas/kuning sama sekali
   ========================================================= */

:root {
  --bg: #0d0d0d;
  --card: #171717;
  --card-hover: #202020;
  --border: rgba(255, 255, 255, 0.08);
  --text-main: #ffffff;
  --text-secondary: #a3a3a3;
  --profit: #22c55e;
  --profit-bg: rgba(34, 197, 94, 0.14);
  --loss: #ef4444;
  --loss-bg: rgba(239, 68, 68, 0.14);
  --zero: #6b7280;
  --zero-bg: rgba(107, 114, 128, 0.14);
  --accent: #3b82f6;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  overflow-x: hidden;
  width: 100%;
}

body {
  background: var(--bg);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  padding-bottom: 40px;
  -webkit-font-smoothing: antialiased;
}

/* ===== HEADER ===== */
.app-header {
  padding: 28px 20px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg) 60%, rgba(13, 13, 13, 0.85) 100%);
  backdrop-filter: blur(10px);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
}

.brand h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-sub {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
  margin-left: 44px;
}

/* ===== MAIN LAYOUT ===== */
.app-main {
  padding: 0 16px;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== STATISTIK ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  min-width: 0;
  transition: background var(--transition), transform var(--transition);
}

.stat-card:active {
  transform: scale(0.97);
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.stat-value {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

/* Auto-shrink saat angka terlalu panjang untuk kartu (ditambahkan via JS) */
.stat-value.text-md { font-size: 13px; }
.stat-value.text-sm { font-size: 11.5px; }

.stat-profit { color: var(--profit); }
.stat-loss { color: var(--loss); }

/* ===== KALENDER CARD ===== */
.calendar-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px 20px;
  box-shadow: var(--shadow-soft);
  animation: fadeIn 0.4s ease;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.month-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-hover);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.nav-btn:hover {
  background: #2a2a2a;
}

.nav-btn:active {
  transform: scale(0.9);
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 8px;
}

.weekday-row span {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

/* ===== SEL TANGGAL ===== */
.day-cell {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px 2px;
  background: transparent;
  border: 1px solid transparent;
  position: relative;
  transition: background var(--transition), transform var(--transition), border var(--transition);
  min-width: 0;
  overflow: hidden;
}

.day-cell.empty {
  visibility: hidden;
}

.day-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.day-amount {
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
}

.day-amount.day-amount-sm {
  font-size: 8px;
}

/* Tanggal yang BISA diklik (hari ini & kemarin) */
.day-cell.clickable {
  cursor: pointer;
  background: var(--card-hover);
  border-color: var(--border);
}

.day-cell.clickable:hover {
  background: #2a2a2a;
  transform: translateY(-2px);
}

.day-cell.clickable:active {
  transform: scale(0.94);
}

/* Tanggal yang TIDAK bisa diklik */
.day-cell.disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

/* Highlight khusus "hari ini" */
.day-cell.today {
  border: 1.5px solid var(--accent);
}

/* Status data profit/loss/zero */
.day-cell.has-profit {
  background: var(--profit-bg);
  border-color: rgba(34, 197, 94, 0.35);
}
.day-cell.has-profit .day-amount { color: var(--profit); }

.day-cell.has-loss {
  background: var(--loss-bg);
  border-color: rgba(239, 68, 68, 0.35);
}
.day-cell.has-loss .day-amount { color: var(--loss); }

.day-cell.has-zero {
  background: var(--zero-bg);
  border-color: rgba(107, 114, 128, 0.35);
}
.day-cell.has-zero .day-amount { color: var(--text-secondary); }

/* ===== LEGEND ===== */
.legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 4px 0 8px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-profit { background: var(--profit); }
.dot-loss { background: var(--loss); }
.dot-zero { background: var(--zero); }

/* ===== ANALITIK / GRAFIK PROFIT ===== */
.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px 20px;
  box-shadow: var(--shadow-soft);
  animation: fadeIn 0.4s ease;
}

.chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.chart-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.chart-sub {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ----- 4 kartu statistik di atas grafik ----- */
.chart-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.chart-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 10px;
  min-width: 0;
  transition: background var(--transition);
}

.chart-stat-icon {
  font-size: 15px;
  flex-shrink: 0;
}

.chart-stat-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chart-stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.chart-stat-value {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  max-width: 100%;
}

.chart-stat-value.text-sm {
  font-size: 10.5px;
}

/* ----- area grafik (scroll horizontal di mobile) ----- */
.chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.chart-scroll::-webkit-scrollbar {
  height: 5px;
}

.chart-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.chart-inner {
  position: relative;
  height: 220px;
  min-width: 100%;
}

.chart-inner canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ----- empty state ----- */
.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 44px 20px;
  color: var(--text-secondary);
  text-align: center;
  font-size: 13px;
  animation: fadeIn 0.4s ease;
}

.chart-empty-icon {
  font-size: 34px;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

@media (min-width: 480px) {
  .chart-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .chart-stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateY(24px) scale(0.98);
  opacity: 0;
  transition: transform var(--transition), opacity var(--transition);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Desktop / tablet: modal jadi center popup, bukan bottom sheet */
@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
  .modal {
    border-radius: var(--radius);
    transform: scale(0.92);
  }
  .modal-overlay.open .modal {
    transform: scale(1);
  }
}

.modal h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-date {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.input-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ===== TOGGLE PROFIT / LOSS ===== */
.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.type-btn {
  padding: 13px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: #0d0d0d;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), border var(--transition), color var(--transition), transform var(--transition);
}

.type-btn:active {
  transform: scale(0.96);
}

.type-btn-profit.active {
  background: var(--profit-bg);
  border-color: var(--profit);
  color: var(--profit);
}

.type-btn-loss.active {
  background: var(--loss-bg);
  border-color: var(--loss);
  color: var(--loss);
}

.profit-input {
  width: 100%;
  background: #0d0d0d;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 14px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  transition: border var(--transition);
}

.profit-input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-hint {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  flex: 1;
  padding: 15px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), background var(--transition), opacity var(--transition);
}

.btn:active {
  transform: scale(0.96);
}

.btn-secondary {
  background: var(--card-hover);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #2a2a2a;
}

.btn-primary {
  background: var(--text-main);
  color: #0d0d0d;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* ===== RIPPLE EFFECT ===== */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0);
  animation: rippleAnim 0.55s ease-out;
  pointer-events: none;
}

@keyframes rippleAnim {
  to {
    transform: scale(2.6);
    opacity: 0;
  }
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #1f1f1f;
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 13px 22px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  max-width: 90vw;
}

.toast::before {
  content: "✓";
  color: var(--profit);
  font-weight: 800;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== ANIMASI ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE: TABLET & DESKTOP ===== */
@media (min-width: 640px) {
  .app-main {
    max-width: 560px;
  }
  .day-number {
    font-size: 14px;
  }
  .day-amount {
    font-size: 9.5px;
  }
}

@media (min-width: 900px) {
  .app-main {
    max-width: 620px;
  }
}

/* Layar sangat kecil (contoh: iPhone SE) */
@media (max-width: 340px) {
  .stat-value {
    font-size: 13px;
  }
  .day-number {
    font-size: 11.5px;
  }
  .day-amount {
    font-size: 7.5px;
  }
}
