/* ============================================
   RIWAYAT (Spending Journal) — SplitAja
   Premium light/dark mode with app.css tokens
   ============================================ */

/* === Main Layout === */
.riwayat-main {
  max-width: 600px;
  margin: 0 auto;
  padding: 80px 16px 40px;
  min-height: 100vh;
}

/* === Hero === */
.riwayat-hero {
  text-align: center;
  padding: 24px 0 20px;
}
.riwayat-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.riwayat-title svg {
  color: var(--indigo, #6366f1);
}
.riwayat-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* === Stats Row === */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-surface, rgba(255,255,255,0.7));
  border: 1px solid var(--border-default, rgba(0,0,0,0.06));
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.stat-total::before { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.stat-count::before { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-avg::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.stat-value {
  font-size: clamp(0.72rem, 2.8vw, 1rem);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.stat-total .stat-value { color: var(--indigo, #6366f1); }

/* === Controls (Month + Search) === */
.riwayat-controls {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-bottom: 20px;
  align-items: stretch;
}

/* Month Picker */
.month-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-surface, rgba(255,255,255,0.7));
  border: 1px solid var(--border-default, rgba(0,0,0,0.06));
  border-radius: 12px;
  padding: 6px 10px;
  flex-shrink: 0;
}
.month-nav {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(99, 102, 241, 0.08);
  border-radius: 6px;
  color: var(--indigo, #6366f1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.month-nav:hover {
  background: rgba(99, 102, 241, 0.15);
  transform: scale(1.05);
}
.month-nav:disabled {
  opacity: 0.3;
  cursor: default;
  transform: none;
}
.month-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Search */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap .search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-secondary);
  pointer-events: none;
}
.search-wrap .search-input {
  width: 100%;
  padding: 11px 36px 11px 40px;
  border: 1px solid var(--border-default, rgba(0,0,0,0.1));
  border-radius: 12px;
  background: var(--bg-surface, rgba(255,255,255,0.7));
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-wrap .search-input:focus {
  border-color: var(--indigo, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.search-wrap .search-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}
.search-clear {
  position: absolute;
  right: 10px;
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === Timeline List === */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Date Group */
.date-group {
  margin-bottom: 6px;
}
.date-group-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  padding: 8px 4px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default, rgba(0,0,0,0.06));
}

/* Entry Card */
.entry-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-surface, rgba(255,255,255,0.7));
  border: 1px solid var(--border-default, rgba(0,0,0,0.05));
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  animation: fadeInUp 0.3s ease both;
}
.entry-card:hover {
  border-color: rgba(99, 102, 241, 0.2);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.08);
  transform: translateY(-1px);
}

/* Entry Icon */
.entry-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(139,92,246,0.1));
}

/* Entry Info */
.entry-info {
  flex: 1;
  min-width: 0;
}
.entry-merchant {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 3px;
}
.entry-meta .meta-dot {
  opacity: 0.4;
}
.entry-location {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--text-secondary);
}
.entry-location svg {
  flex-shrink: 0;
}

/* Entry Amount */
.entry-amount {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--indigo, #6366f1);
  white-space: nowrap;
  text-align: right;
}
.entry-participants {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 2px;
}

/* Entry Actions (delete + chevron) */
.entry-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 4px;
}

.btn-delete-entry {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #f87171;
  opacity: 0.4;
  border-radius: 6px;
  transition: all 0.2s;
  line-height: 0;
}
.btn-delete-entry:hover,
.btn-delete-entry:active {
  opacity: 1;
  color: #ef4444;
  background: rgba(239,68,68,0.08);
}

.entry-chevron-icon {
  color: var(--text-secondary);
  opacity: 0.3;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.entry-card:hover .entry-chevron-icon {
  opacity: 0.6;
  transform: translateX(2px);
}

/* === PRO Gate === */
.pro-gate, .login-gate {
  padding: 60px 20px;
}
.pro-gate-card {
  text-align: center;
  background: var(--bg-surface, rgba(255,255,255,0.7));
  border: 1px solid var(--border-default, rgba(0,0,0,0.06));
  border-radius: 20px;
  padding: 40px 24px;
  max-width: 360px;
  margin: 0 auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.06);
}
.pro-gate-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}
.pro-gate-card h2 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.pro-gate-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}
.btn-upgrade {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}
.btn-upgrade:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(99,102,241,0.4);
}

/* === Loading & Empty === */
.riwayat-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.riwayat-loading p {
  margin-top: 16px;
  font-size: 0.85rem;
}
.riwayat-empty {
  text-align: center;
  padding: 60px 20px;
}
.riwayat-empty .empty-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}
.riwayat-empty h3 {
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 1.1rem;
}
.riwayat-empty p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 24px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.35);
}

/* Load More */
.load-more {
  text-align: center;
  padding: 16px;
}
.btn-load-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  background: rgba(99,102,241,0.08);
  color: var(--indigo, #6366f1);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.btn-load-more:hover {
  background: rgba(99,102,241,0.15);
}

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

/* Spinner (reuse) */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(99,102,241,0.15);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === Utility === */
.hidden { display: none !important; }

/* === Dark Mode Overrides === */
.dark .stat-card {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(255,255,255,0.06);
}
.dark .month-picker {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(255,255,255,0.06);
}
.dark .search-wrap .search-input {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(255,255,255,0.08);
  color: #edeef3;
}
.dark .entry-card {
  background: rgba(30, 41, 59, 0.5);
  border-color: rgba(255,255,255,0.05);
}
.dark .entry-card:hover {
  border-color: rgba(99,102,241,0.3);
  box-shadow: 0 4px 16px rgba(99,102,241,0.12);
}
.dark .pro-gate-card {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(255,255,255,0.06);
}
.dark .date-group-label::after {
  background: rgba(255,255,255,0.06);
}
.dark .entry-icon {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.15));
}
.dark .search-clear {
  background: rgba(99,102,241,0.15);
}

/* === Responsive === */
@media (max-width: 420px) {
  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .stat-card {
    padding: 10px 8px;
  }
  .stat-value {
    font-size: 0.85rem;
  }
  .stat-label {
    font-size: 0.6rem;
  }
  .entry-card {
    padding: 12px;
    gap: 10px;
  }
  .entry-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    border-radius: 10px;
  }
  .entry-merchant {
    font-size: 0.85rem;
  }
  .entry-amount {
    font-size: 0.85rem;
  }
}

/* ============================================
   DELETE CONFIRMATION MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-card {
  background: var(--bg-card, #fff);
  border-radius: 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: slideUp 0.3s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}
.modal-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.2s;
}
.modal-close:hover {
  background: rgba(0,0,0,0.06);
  color: var(--text-primary);
}
.modal-body {
  padding: 20px;
}
.delete-warning {
  text-align: center;
  padding: 16px 0;
}
.delete-warning svg {
  margin-bottom: 12px;
}
.delete-warning p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.delete-sub {
  font-size: 0.75rem !important;
  color: var(--text-muted) !important;
  margin-top: 6px;
}
.modal-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.modal-btn-row button {
  flex: 1;
  padding: 11px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.btn-secondary {
  background: var(--bg-surface-2, #f1f5f9);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
}
.btn-secondary:hover {
  background: var(--bg-surface, #e2e8f0);
}
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
  color: #fff;
  box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}
.btn-danger:hover {
  box-shadow: 0 4px 16px rgba(239,68,68,0.4);
  transform: translateY(-1px);
}

.dark .modal-card {
  background: var(--bg-card, #1e1e2e);
}
.dark .modal-close:hover {
  background: rgba(255,255,255,0.06);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
