/**
 * ============================================================
 * MENTAYA — Reusable UI Components
 * File    : css/components.css
 * Purpose : Semua komponen UI yang dipakai lebih dari satu kali
 *           di berbagai screen. Setiap komponen berdiri sendiri
 *           dan tidak bergantung pada konteks screen tertentu.
 * Audit   : Setiap perubahan di sini berdampak ke seluruh UI.
 * ============================================================
 */

/* ══════════════════════════════════════════════════════
   BUTTONS
   Sistem tombol tiga tingkat: primary, secondary, ghost.
   Selalu tambahkan :disabled state untuk aksesibilitas.
   ══════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  letter-spacing: 0;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  -webkit-user-select: none;
  user-select: none;
  text-align: center;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

/* Tombol utama — untuk aksi paling penting di halaman */
.btn-primary {
  background: linear-gradient(135deg, var(--color-leaf), var(--color-forest));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(26, 77, 46, 0.30);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(26, 77, 46, 0.38);
}

/* Tombol sekunder — untuk aksi pendukung */
.btn-secondary {
  background: var(--color-warm);
  color: var(--color-forest);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-sage);
  background: var(--color-mint-soft);
}

/* Tombol ghost — untuk aksi tersier, inline */
.btn-ghost {
  background: transparent;
  color: var(--color-leaf);
  border-color: transparent;
  padding: 8px var(--space-3);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-mint-soft);
}

/* Varian full-width */
.btn-full {
  width: 100%;
}

/* Varian ukuran */
.btn-sm {
  padding: 8px var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 16px var(--space-6);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

/* State disabled — berlaku untuk semua varian */
.btn:disabled {
  background: var(--color-border);
  color: var(--color-muted);
  border-color: transparent;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* ══════════════════════════════════════════════════════
   FORM ELEMENTS
   ══════════════════════════════════════════════════════ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

/* Kontainer untuk input dengan ikon di kiri */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input,
.form-select {
  width: 100%;
  padding: 13px var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-warm);
  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

/* Input dengan ikon — padding kiri lebih besar */
.input-wrapper .form-input {
  padding-left: var(--space-4);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(74, 171, 109, 0.18);
}

.form-input::placeholder {
  color: var(--color-border);
}

/* ── Custom select arrow ── */
.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '▾';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  pointer-events: none;
  font-size: 12px;
}

.select-wrapper .form-select {
  padding-right: 36px;
}

/* ══════════════════════════════════════════════════════
   CARDS
   Kontainer konten utama. Tiga varian: default, elevated, flat.
   ══════════════════════════════════════════════════════ */

.card {
  background: var(--color-warm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card-elevated {
  box-shadow: var(--shadow-md);
  border-color: transparent;
}

.card-hoverable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Garis aksen di bagian atas kartu */
.card-accent-top::before {
  content: '';
  display: block;
  height: 3px;
  margin: calc(var(--space-5) * -1) calc(var(--space-5) * -1) var(--space-4);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(90deg, var(--color-sage), var(--color-mint));
}

/* ══════════════════════════════════════════════════════
   BADGES & PILLS
   ══════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.5px;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(45, 122, 79, 0.2);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: #8a6200;
  border: 1px solid rgba(212, 168, 81, 0.25);
}

.badge-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge-info {
  background: var(--color-info-bg);
  color: var(--color-info);
}

.badge-neutral {
  background: rgba(122, 140, 125, 0.12);
  color: var(--color-muted);
}

/* Badge kategori checklist — warna dinamis via inline style */
.badge-category {
  font-size: 10px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
}

/* ══════════════════════════════════════════════════════
   PROGRESS BAR
   Digunakan untuk skor kategori dan progress checklist.
   ══════════════════════════════════════════════════════ */

.progress-track {
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-sage), var(--color-leaf));
  animation: progressFill 1s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 0.2s;
}

/* ── Progress Circle ── */
.progress-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring__track {
  fill: none;
  stroke: var(--color-border);
}

.progress-ring__fill {
  fill: none;
  stroke: var(--color-leaf);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-ring__label {
  position: absolute;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-forest);
  text-align: center;
  line-height: 1.2;
}

/* ══════════════════════════════════════════════════════
   STAT CARD
   Kartu angka statistik kecil untuk dashboard.
   ══════════════════════════════════════════════════════ */

.stat-card {
  background: var(--color-warm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* Aksen warna di bagian atas */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-sage), var(--color-mint));
}

.stat-card__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: var(--space-2);
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-forest);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card__sub {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* ══════════════════════════════════════════════════════
   SECTION TITLE
   ══════════════════════════════════════════════════════ */

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-forest);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.app-content .section-title {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.card .section-title,
.stat-card .section-title,
.trend-chart-card .section-title,
.question-group .section-title,
.modal-box .section-title {
  color: var(--color-forest);
  text-shadow: none;
}

/* ══════════════════════════════════════════════════════
   DIVIDER
   ══════════════════════════════════════════════════════ */

.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-5) 0;
  border: none;
}

/* ══════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-5);
  color: var(--color-muted);
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--color-muted);
  margin-bottom: var(--space-2);
}

.empty-state__desc {
  font-size: var(--text-sm);
  color: var(--color-muted);
  max-width: 280px;
  margin: 0 auto;
}

/* ══════════════════════════════════════════════════════
   TOAST NOTIFICATION
   Notifikasi sementara yang muncul dari bawah layar.
   ══════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: calc(var(--bottomnav-height) + var(--space-4));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast {
  background: var(--color-forest);
  color: #fff;
  padding: 12px var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn 0.4s var(--transition-slow) both;
  max-width: 100%;
  text-align: center;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.toast.toast-success { background: var(--color-leaf); }
.toast.toast-warning { background: #a07826; }
.toast.toast-error   { background: var(--color-danger); }

.toast.toast-hide {
  animation: toastOut 0.3s ease forwards;
}

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

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

/* ══════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 14, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-end;        /* Mobile: muncul dari bawah */
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Desktop: modal di tengah layar */
@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
  }
}

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

.modal-box {
  background: var(--color-warm);
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-lg) var(--radius-lg);
  padding: var(--space-10) var(--space-8);
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  transform: translateY(40px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 600px) {
  .modal-box {
    border-radius: var(--radius-xl);
    transform: scale(0.92);
  }

  .modal-overlay.modal-open .modal-box {
    transform: scale(1);
  }
}

.modal-overlay.modal-open .modal-box {
  transform: translateY(0);
}

.modal-box__title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.modal-box__desc {
  font-size: var(--text-sm);
  color: var(--color-muted);
  line-height: 1.7;
  margin-bottom: var(--space-2);
}

.modal-box__score {
  font-family: var(--font-display);
  font-size: 52px;
  font-weight: var(--weight-bold);
  color: var(--color-leaf);
  line-height: 1;
  margin: var(--space-4) 0;
  display: block;
}

/* ══════════════════════════════════════════════════════
   SKELETON LOADER
   Placeholder saat data sedang dimuat.
   ══════════════════════════════════════════════════════ */

.skeleton {
  background: var(--color-border);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ══════════════════════════════════════════════════════
   CATEGORY ROW (untuk breakdown dashboard)
   ══════════════════════════════════════════════════════ */

.cat-row {
  background: var(--color-warm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: box-shadow var(--transition-base);
}

.cat-row:hover {
  box-shadow: var(--shadow-xs);
}

.cat-row__body {
  flex: 1;
  min-width: 0;
}

.cat-row__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: 5px;
}

.cat-row__pct {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-forest);
  flex-shrink: 0;
}
