/* 04-components.css — Reusable UI components */

/* Card */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.card:hover {
  border-color: var(--c-border-hi);
}
.card--flat {
  border: none;
  background: var(--c-surface-2);
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  gap: var(--s-3);
  flex-wrap: wrap;
}
.card__title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--c-text);
}
.card__subtitle {
  font-size: var(--text-sm);
  color: var(--c-text-3);
  margin-top: var(--s-1);
}
.card__body { color: var(--c-text-2); }
.card__foot {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  flex-wrap: wrap;
}

/* Stat Card */
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
}
.stat-card__label {
  font-size: var(--text-xs);
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--s-2);
}
.stat-card__value {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--c-text);
}
.stat-card__change {
  font-size: var(--text-xs);
  margin-top: var(--s-1);
  display: flex;
  align-items: center;
  gap: var(--s-1);
}
.stat-card__change--up { color: var(--c-accent); }
.stat-card__change--down { color: var(--c-danger); }

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
  min-height: 40px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
/* Ikon SVG di dalam tombol: ukuran eksplisit agar tidak kolaps ke 0×0
   (reset global svg memakai max-width:100% tanpa ukuran dasar) */
.btn svg {
  width: 16px;
  height: 16px;
  max-width: none;
  flex-shrink: 0;
}
.btn--primary {
  background: var(--c-primary);
  color: #fff;
}
.btn--primary:hover { background: var(--c-primary-d); }
.btn--accent {
  background: var(--c-accent);
  color: #fff;
}
.btn--accent:hover { background: var(--c-accent-d); }
.btn--warn {
  background: var(--c-warn);
  color: #fff;
}
.btn--warn:hover { background: #b45309; }
.btn--secondary {
  background: var(--c-surface-2);
  color: var(--c-text);
  border: 1px solid var(--c-border);
}
.btn--secondary:hover { background: var(--c-surface-3); border-color: var(--c-border-hi); }
.btn--danger {
  background: var(--c-danger-bg);
  color: var(--c-danger);
  border: 1px solid var(--c-danger);
}
.btn--danger:hover { background: var(--c-danger); color: #fff; }
.btn--ghost {
  background: transparent;
  color: var(--c-text-2);
  padding: var(--s-2) var(--s-3);
}
.btn--ghost:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn--sm { padding: var(--s-2) var(--s-3); font-size: var(--text-xs); min-height: 32px; }
.btn--lg { padding: var(--s-3) var(--s-5); font-size: var(--text-base); min-height: 48px; }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn--icon {
  padding: var(--s-2);
  width: 40px; height: 40px;
  min-width: 40px; min-height: 40px;
}

/* Input / Field */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.field__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-text);
}
.field__input,
.field__select,
.field__textarea {
  padding: var(--s-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: var(--text-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  width: 100%;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}
.field__input:focus,
.field__select:focus,
.field__textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-bg);
}
.field__input::placeholder { color: var(--c-text-3); }
.field__select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.field__hint {
  font-size: var(--text-xs);
  color: var(--c-text-3);
}
.field__error {
  font-size: var(--text-xs);
  color: var(--c-danger);
  display: flex;
  align-items: center;
  gap: var(--s-1);
}
.field--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--s-3);
}

/* Table */
.table-wrap {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  font-size: var(--text-sm);
  min-width: 600px;
}
.table th {
  text-align: left;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface-2);
  color: var(--c-text-2);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: var(--text-xs);
  white-space: nowrap;
}
.table td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--c-surface-2); }
.table__actions { display: flex; gap: var(--s-1); }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge--primary { background: var(--c-primary-bg); color: var(--c-primary); }
.badge--success { background: var(--c-success-bg); color: var(--c-success); }
.badge--warn    { background: var(--c-warn-bg);    color: var(--c-warn); }
.badge--danger  { background: var(--c-danger-bg);  color: var(--c-danger); }
.badge--neutral { background: var(--c-surface-2);  color: var(--c-text-2); }

/* Tabs */
.tabs {
  display: flex;
  gap: var(--s-1);
  border-bottom: 1px solid var(--c-border);
  margin-bottom: var(--s-4);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
  padding: var(--s-3) var(--s-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--dur-fast);
  white-space: nowrap;
  min-height: 44px;
}
.tabs__item:hover { color: var(--c-text); }
.tabs__item--active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
}

/* Progress */
.progress {
  height: 6px;
  background: var(--c-surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--c-primary);
  border-radius: 999px;
  transition: width var(--dur-slow) var(--ease);
}
.progress--success .progress__bar { background: var(--c-accent); }
.progress--danger  .progress__bar { background: var(--c-danger); }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--c-surface-2) 25%, var(--c-surface-3) 50%, var(--c-surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty State */
.empty {
  text-align: center;
  padding: var(--s-8) var(--s-4);
  color: var(--c-text-3);
}
.empty__icon {
  width: 48px; height: 48px;
  margin: 0 auto var(--s-4);
  color: var(--c-border-hi);
}
.empty__title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--c-text-2);
  margin-bottom: var(--s-2);
}
.empty__desc {
  font-size: var(--text-sm);
  margin-bottom: var(--s-4);
}

/* Search Bar */
.search {
  position: relative;
  max-width: 400px;
  width: 100%;
}
.search__input {
  width: 100%;
  padding: var(--s-3) var(--s-4) var(--s-3) 2.5rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: var(--text-sm);
  transition: all var(--dur-fast);
  min-height: 44px;
}
.search__input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-bg);
}
.search__icon {
  position: absolute;
  left: var(--s-3); top: 50%;
  transform: translateY(-50%);
  color: var(--c-text-3);
  pointer-events: none;
}
.search.has-clear .search__input { padding-right: 2.6rem; }
.search__clear {
  position: absolute;
  right: var(--s-2); top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--c-text-3);
  cursor: pointer;
}
.search.has-clear .search__clear { display: inline-flex; }
.search__clear:hover { background: var(--c-surface-2); color: var(--c-text); }

/* Toggle Switch */
.toggle {
  position: relative;
  width: 44px; height: 24px;
  background: var(--c-border);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--dur-fast);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--dur-fast) var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle--on {
  background: var(--c-primary);
}
.toggle--on::after {
  transform: translateX(20px);
}

/* Tooltip */
.tooltip {
  position: relative;
}
.tooltip__text {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  padding: var(--s-2) var(--s-3);
  background: var(--c-text);
  color: var(--c-bg);
  font-size: var(--text-xs);
  border-radius: var(--radius);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--dur-fast);
  z-index: 200;
}
.tooltip:hover .tooltip__text {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ======================== */
/* MOBILE COMPONENT TWEAKS  */
/* ======================== */
@media (max-width: 768px) {
  .card__foot {
    flex-direction: column;
  }
  .card__foot .btn {
    width: 100%;
  }
  .field--inline {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
  }
  .tabs__item {
    padding: var(--s-3);
    font-size: var(--text-xs);
  }
}
