/**
 * components.css — Kartu, Tombol, Badge, Form, Dialog, Tabel, Skeleton, Toast
 * =============================================================================
 * Pola: DESIGN.md §Components + PRD §7.1 §G
 * - Kartu radius 24px, tombol pil 9999px, input radius 12px
 * - Sidebar dengan token --sidebar-*
 * - Dialog sebagai modal normal
 */

/* ══════════════════════════════════════════
   A. KARTU (BENTO CARDS)
   ══════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card--dark {
  background: var(--primary-900);
  border-color: transparent;
  color: var(--text-on-dark);
}

.card--sky {
  background: var(--sky-100);
  border-color: transparent;
}

.card--accent {
  background: var(--accent-200);
  border-color: transparent;
}

.card--cyan {
  background: var(--secondary-600);
  border-color: transparent;
  color: var(--text-on-dark);
}

.card--gradient-hero {
  background: var(--gradient-hero);
  border-color: transparent;
  color: var(--text-on-dark);
}

.card--gradient-dark {
  background: var(--gradient-panel-dark);
  border-color: transparent;
  color: var(--text-on-dark);
}

.card--muted {
  background: var(--surface-muted);
  border-color: transparent;
}

.card--interactive {
  cursor: pointer;
}

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

/* Produk card */
.card-product {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.card-product:hover {
  box-shadow: var(--shadow-md);
}

.card-product__image {
  aspect-ratio: 16 / 10;
  width: 100%;
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
  background: var(--surface-muted);
}

.card-product__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card-product:hover .card-product__image img {
  transform: scale(1.05);
}

.card-product__ribbon {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font: var(--label-sm);
  letter-spacing: var(--label-sm-ls);
}

.card-product__ribbon--kelas {
  background: var(--secondary-600);
  color: var(--text-on-dark);
}

.card-product__ribbon--aplikasi {
  background: var(--primary-900);
  color: var(--text-on-dark);
}

.card-product__ribbon--dokumen {
  background: var(--tertiary-400);
  color: var(--primary-900);
}

.card-product__ribbon--paused {
  background: var(--text-muted);
  color: var(--surface);
}

.card-product__meta {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-md);
  background: rgba(14, 31, 83, 0.75);
  backdrop-filter: blur(4px);
  color: var(--text-on-dark);
  font: var(--label-sm);
}

.card-product__title {
  font: var(--headline-sm);
  letter-spacing: var(--headline-sm-ls);
  color: var(--text-strong);
  margin-top: var(--space-sm);
}

.card-product__desc {
  font: var(--body-sm);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.card-product__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.card-product__price {
  font: var(--headline-sm);
  color: var(--text-strong);
}

.card-product__price--free {
  color: var(--secondary-600);
}

.card-product__price-old {
  font: var(--label-sm);
  color: var(--text-muted);
  text-decoration: line-through;
}

/* ══════════════════════════════════════════
   B. TOMBOL (PILL BUTTONS)
   ══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font: var(--label-lg);
  letter-spacing: var(--label-lg-ls);
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

/* Primary (gelap) */
.btn--primary {
  background: var(--primary-900);
  color: var(--text-on-dark);
}

.btn--primary:hover {
  background: var(--secondary-600);
}

/* Accent (limau) */
.btn--accent {
  background: var(--accent-400);
  color: var(--primary-900);
  font-weight: 700;
}

.btn--accent:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 16px rgba(225, 235, 89, 0.35);
}

/* Ghost / Outline */
.btn--ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-strong);
}

.btn--ghost:hover {
  background: var(--surface);
}

/* Secondary */
.btn--secondary {
  background: var(--surface-muted);
  color: var(--text-strong);
}

.btn--secondary:hover {
  background: var(--surface-sunken);
}

/* Danger */
.btn--danger {
  background: var(--danger);
  color: var(--text-on-dark);
}

.btn--danger:hover {
  filter: brightness(1.1);
}

/* Success */
.btn--success {
  background: var(--success);
  color: var(--text-on-dark);
}

/* Sizes */
.btn--sm {
  padding: 6px 16px;
  font: var(--label-md);
  letter-spacing: var(--label-md-ls);
}

.btn--lg {
  padding: 14px 28px;
  font: var(--label-lg);
}

.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
}

.btn--icon-sm {
  width: 32px;
  height: 32px;
  padding: 0;
}

/* CTA aksen (pil putih dengan ikon Accent bulat) — PRD §7.1 §G */
.btn--cta {
  background: var(--surface);
  color: var(--primary-900);
  padding-right: 6px;
  box-shadow: var(--shadow-md);
}

.btn--cta:hover {
  background: var(--sky-50);
}

.btn__cta-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-400);
  color: var(--primary-900);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: var(--space-md);
  transition: transform var(--transition-fast);
}

.btn--cta:hover .btn__cta-icon {
  transform: scale(1.05);
}

/* Loading state */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
  margin-left: var(--space-xs);
}

/* ══════════════════════════════════════════
   C. BADGE & CHIP
   ══════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font: var(--label-sm);
  letter-spacing: var(--label-sm-ls);
  white-space: nowrap;
}

.badge--live {
  background: var(--accent-400);
  color: var(--primary-900);
}

.badge--progress {
  background: var(--info-soft);
  color: var(--secondary-600);
}

.badge--complete {
  background: var(--success-soft);
  color: var(--success);
}

.badge--pending {
  background: var(--warning-soft);
  color: var(--warning);
}

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

.badge--owned {
  background: var(--accent-400);
  color: var(--primary-900);
  font-weight: 700;
}

.badge--locked {
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.badge--new {
  background: var(--secondary-600);
  color: var(--text-on-dark);
}

/* Dot pulsing (LIVE indicator) */
.dot-pulse {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  animation: pulse 2s infinite;
}

/* Chip (filter) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font: var(--label-md);
  letter-spacing: var(--label-md-ls);
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.chip:hover {
  background: var(--surface-sunken);
  color: var(--text-strong);
}

.chip.active {
  background: var(--primary-900);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-sm);
}

/* ══════════════════════════════════════════
   D. FORM CONTROLS
   ══════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-label {
  font: var(--label-md);
  letter-spacing: var(--label-md-ls);
  color: var(--text-strong);
}

.form-hint {
  font: var(--body-sm);
  color: var(--text-muted);
}

.form-input {
  height: 48px;
  padding: 0 var(--space-md);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font: var(--body-md);
  color: var(--text-strong);
  transition: all var(--transition-fast);
  width: 100%;
}

.form-input:focus {
  border-color: var(--secondary-600);
  box-shadow: 0 0 0 2px rgba(0, 145, 199, 0.2);
}

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

.form-input--error:focus {
  box-shadow: 0 0 0 2px rgba(229, 72, 77, 0.2);
}

.form-textarea {
  min-height: 120px;
  padding: var(--space-md);
  resize: vertical;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237A85A6' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.form-error {
  font: var(--body-sm);
  color: var(--danger);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle.active {
  background: var(--secondary-600);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.toggle.active::after {
  transform: translateX(20px);
}

/* ══════════════════════════════════════════
   E. DIALOG / MODAL
   ══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-xl);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-normal);
}

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

.modal--lg { max-width: 680px; }
.modal--xl { max-width: 900px; }
.modal--full { max-width: 1200px; }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.modal__title {
  font: var(--headline-sm);
  letter-spacing: var(--headline-sm-ls);
  color: var(--text-strong);
}

.modal__close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition-fast);
}

.modal__close:hover {
  background: var(--surface-muted);
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════
   F. TABEL
   ══════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-2xl);
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  padding: var(--space-md);
  font: var(--label-md);
  letter-spacing: var(--label-md-ls);
  color: var(--text-muted);
  text-align: left;
  background: var(--surface-muted);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.table td {
  padding: var(--space-md);
  font: var(--body-md);
  color: var(--text-body);
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:nth-child(even) td {
  background: var(--surface-sunken);
}

.table tr:hover td {
  background: var(--sky-50);
}

/* ══════════════════════════════════════════
   G. SKELETON / LOADING STATE
   ══════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-muted) 25%,
    var(--surface-sunken) 50%,
    var(--surface-muted) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton--text {
  height: 14px;
  width: 80%;
  margin-bottom: var(--space-xs);
}

.skeleton--title {
  height: 22px;
  width: 60%;
  margin-bottom: var(--space-sm);
}

.skeleton--card {
  height: 200px;
  border-radius: var(--radius-2xl);
}

.skeleton--avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
}

.skeleton--btn {
  height: 40px;
  width: 120px;
  border-radius: var(--radius-full);
}

/* Loading bar (top of page) */
.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--secondary-600);
  z-index: 9999;
  transition: width 0.3s ease;
  border-radius: 0 2px 2px 0;
}

/* ══════════════════════════════════════════
   H. TOAST
   ══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: fadeIn 0.3s ease;
  min-width: 280px;
  max-width: 420px;
}

.toast--success { border-left: 4px solid var(--success); }
.toast--error   { border-left: 4px solid var(--danger); }
.toast--warning { border-left: 4px solid var(--warning); }
.toast--info    { border-left: 4px solid var(--info); }

.toast__icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.toast__message {
  flex: 1;
  font: var(--body-md);
  color: var(--text-strong);
}

.toast__close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════
   I. STEPPER (Wizard / Checkout)
   ══════════════════════════════════════════ */
.stepper {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md) 0;
}

.stepper__step {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.stepper__dot {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font: var(--label-md);
  background: var(--surface-muted);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.stepper__step.active .stepper__dot {
  background: var(--primary-900);
  color: var(--text-on-dark);
}

.stepper__step.done .stepper__dot {
  background: var(--success);
  color: var(--text-on-dark);
}

.stepper__label {
  font: var(--label-md);
  color: var(--text-muted);
}

.stepper__step.active .stepper__label {
  color: var(--text-strong);
}

.stepper__line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 var(--space-xs);
}

.stepper__step.done + .stepper__line {
  background: var(--success);
}

/* ══════════════════════════════════════════
   J. ICON BOX
   ══════════════════════════════════════════ */
.icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl);
  flex-shrink: 0;
}

.icon-box--sm { width: 32px; height: 32px; }
.icon-box--md { width: 40px; height: 40px; }
.icon-box--lg { width: 48px; height: 48px; }

.icon-box--sky     { background: var(--sky-100); color: var(--secondary-600); }
.icon-box--accent  { background: var(--accent-200); color: var(--primary-900); }
.icon-box--primary { background: var(--primary-900); color: var(--text-on-dark); }
.icon-box--surface { background: var(--surface-muted); color: var(--primary-600); }
.icon-box--success { background: var(--success-soft); color: var(--success); }
.icon-box--danger  { background: var(--danger-soft); color: var(--danger); }

/* ══════════════════════════════════════════
   K. PROGRESS BAR
   ══════════════════════════════════════════ */
.progress {
  width: 100%;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--secondary-600);
  transition: width 0.5s ease;
}

/* Segmented progress (distribusi) */
.progress--segmented {
  display: flex;
}

.progress--segmented .progress__fill {
  border-radius: 0;
}

.progress--segmented .progress__fill:first-child {
  border-radius: var(--radius-full) 0 0 var(--radius-full);
}

.progress--segmented .progress__fill:last-child {
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

/* ══════════════════════════════════════════
   L. EMPTY STATE
   ══════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  color: var(--text-muted);
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state__title {
  font: var(--headline-sm);
  color: var(--text-body);
  margin-bottom: var(--space-xs);
}

.empty-state__desc {
  font: var(--body-md);
  max-width: 400px;
}

/* ══════════════════════════════════════════
   M. TABS
   ══════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: var(--space-xs);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: var(--space-sm) var(--space-md);
  font: var(--label-lg);
  letter-spacing: var(--label-lg-ls);
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
}

.tab:hover {
  color: var(--text-strong);
}

.tab.active {
  color: var(--primary-900);
  border-bottom-color: var(--primary-900);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}

.tab-panel.active {
  display: block;
}

/* ══════════════════════════════════════════
   N. AVATAR
   ══════════════════════════════════════════ */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font: var(--label-md);
  color: var(--text-on-dark);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar--sm { width: 32px; height: 32px; }
.avatar--md { width: 40px; height: 40px; }
.avatar--lg { width: 56px; height: 56px; }

.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ══════════════════════════════════════════
   O. ANNOUNCEMENT STRIP
   ══════════════════════════════════════════ */
.announce-strip {
  width: 100%;
  background: var(--sky-100);
  border-radius: var(--radius-2xl);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  box-shadow: var(--shadow-sm);
}

/* ══════════════════════════════════════════
   P. DIVIDER
   ══════════════════════════════════════════ */
.divider {
  height: 1px;
  background: var(--border);
  width: 100%;
}
