/* ============================================================
   CAT ACADEMY IMIPAS — css/components.css
   v2.0 — Komponen UI reusable

   Tanggung jawab: tombol, card, badge, chip, form, modal,
   toast, tab, dropdown, progress, skeleton, table, accordion,
   tooltip, dan elemen pendukung lainnya.

   ATURAN OWNERSHIP:
   - Komponen dipakai > 1 halaman → di sini (nama netral)
   - Page-specific (.dash-*, .exam-*, .admin-*) → file masing-masing
   - Layout (sidebar, topbar) → layout.css
   - Utility atom (.flex, .mt-*) → utilities.css

   PERBAIKAN v2.0:
   ✓ Fix --color-navy-950 → --text-on-accent (7 tempat salah)
   ✓ .card-footer & .modal-footer bg pakai --bg-surface-2
     agar terlihat pemisahan jelas di light mode
   ✓ Tambah .table (generic) + .table-wrap (responsive scroll)
   ✓ Tambah .accordion untuk FAQ/settings
   ✓ Tambah .segmented control
   ✓ Tambah varian .btn-*-soft (success/warning/danger/info/primary)
   ✓ Tambah .badge-xs, .badge-lg
   ✓ Tambah .tooltip-bottom/.left/.right
   ✓ Tambah .modal-fullscreen
   ✓ Tambah .code-block + .copy-btn
   ✓ Tambah .avatar-stack (alias avatar-group)
   ✓ Tambah .link variants (.link-muted, .link-brand)
   ✓ Modal pakai 100dvh (iOS Safari fix)
   ✓ Print rules lebih lengkap
   ============================================================ */

/* ============================================================
   1. BUTTON
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height-md);
  padding: 0 var(--btn-padding-x-md);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--btn-font-weight);
  line-height: 1;
  border-radius: var(--btn-radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  box-shadow: var(--shadow-focus);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-full { width: 100%; }

/* --- Varian: PRIMARY (solid teal) --- */
.btn-primary {
  background: var(--accent-primary);
  color: var(--text-on-accent);
  box-shadow: var(--shadow-brand);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  color: var(--text-on-accent);
  box-shadow: var(--shadow-brand-lg);
  text-decoration: none;
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-primary-active);
  box-shadow: var(--shadow-brand);
}

/* --- Varian: SECONDARY (outline teal) --- */
.btn-secondary {
  background: transparent;
  color: var(--accent-primary);
  border-color: var(--border-brand);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
  text-decoration: none;
}

/* --- Varian: GHOST (tanpa border) --- */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

/* --- Varian: OUTLINE (border netral) --- */
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  text-decoration: none;
}

/* --- Varian: DANGER --- */
.btn-danger {
  background: var(--color-danger-500);
  color: var(--color-white);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-600);
  color: var(--color-white);
  text-decoration: none;
}

/* --- Varian: SUCCESS --- */
.btn-success {
  background: var(--color-success-500);
  color: var(--color-white);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-success:hover:not(:disabled) {
  background: var(--color-success-600);
  color: var(--color-white);
  text-decoration: none;
}

/* --- Varian: WARNING (navy text di atas amber — selalu) --- */
.btn-warning {
  background: var(--color-warning-500);
  color: var(--color-navy-950);
}

.btn-warning:hover:not(:disabled) {
  background: var(--color-warning-600);
  color: var(--color-navy-950);
  text-decoration: none;
}

/* --- Varian: GRADIENT (navy text karena teal terang) --- */
.btn-gradient {
  background: var(--accent-gradient);
  color: var(--color-navy-950);
  box-shadow: var(--shadow-brand);
}

.btn-gradient:hover:not(:disabled) {
  color: var(--color-navy-950);
  box-shadow: var(--shadow-brand-lg);
  text-decoration: none;
  filter: brightness(1.05);
}

/* --- Varian SOFT: outline berwarna (BARU) --- */
.btn-primary-soft {
  background: var(--accent-subtle);
  color: var(--accent-primary);
  border-color: var(--border-brand);
}
.btn-primary-soft:hover:not(:disabled) {
  background: var(--accent-muted);
  border-color: var(--accent-primary-hover);
  text-decoration: none;
}

.btn-success-soft {
  background: rgba(16, 185, 129, 0.12);
  color: var(--color-success-600);
  border-color: rgba(16, 185, 129, 0.30);
}
.btn-success-soft:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.20);
  border-color: var(--color-success-500);
  text-decoration: none;
}

.btn-warning-soft {
  background: rgba(245, 158, 11, 0.12);
  color: var(--color-warning-600);
  border-color: rgba(245, 158, 11, 0.30);
}
.btn-warning-soft:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.20);
  border-color: var(--color-warning-500);
  text-decoration: none;
}

.btn-danger-soft {
  background: rgba(239, 68, 68, 0.12);
  color: var(--color-danger-600);
  border-color: rgba(239, 68, 68, 0.30);
}
.btn-danger-soft:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.20);
  border-color: var(--color-danger-500);
  text-decoration: none;
}

.btn-info-soft {
  background: rgba(59, 130, 246, 0.12);
  color: var(--color-info-600);
  border-color: rgba(59, 130, 246, 0.30);
}
.btn-info-soft:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.20);
  border-color: var(--color-info-500);
  text-decoration: none;
}

/* --- Varian GLASS (overlay di hero/image) --- */
.btn-glass {
  background: rgba(255, 255, 255, 0.15);
  color: var(--color-white);
  border-color: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-glass:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.40);
  color: var(--color-white);
  text-decoration: none;
}

/* --- Ukuran --- */
.btn-xs {
  height: 26px;
  padding: 0 var(--space-2);
  font-size: var(--fs-2xs);
  border-radius: var(--radius-sm);
  gap: var(--space-1);
}
.btn-xs svg { width: 14px; height: 14px; }

.btn-sm {
  height: var(--btn-height-sm);
  padding: 0 var(--btn-padding-x-sm);
  font-size: var(--fs-xs);
}
.btn-sm svg { width: 16px; height: 16px; }

.btn-lg {
  height: var(--btn-height-lg);
  padding: 0 var(--btn-padding-x-lg);
  font-size: var(--fs-md);
  border-radius: var(--radius-lg);
}
.btn-lg svg { width: 20px; height: 20px; }

.btn-icon {
  padding: 0;
  width: var(--btn-height-md);
}
.btn-icon.btn-sm { width: var(--btn-height-sm); }
.btn-icon.btn-lg { width: var(--btn-height-lg); }

/* Loading state — spinner menggantikan teks */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}
.btn.is-loading > * {
  visibility: hidden;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-circle);
  animation: btn-spin 0.6s linear infinite;
  color: var(--text-on-accent);
}
.btn-secondary.is-loading::after,
.btn-ghost.is-loading::after,
.btn-outline.is-loading::after,
.btn-primary-soft.is-loading::after {
  color: var(--accent-primary);
}
.btn-danger.is-loading::after,
.btn-success.is-loading::after,
.btn-danger-soft.is-loading::after,
.btn-success-soft.is-loading::after,
.btn-warning.is-loading::after,
.btn-warning-soft.is-loading::after {
  color: var(--color-white);
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Button group */
.btn-group {
  display: inline-flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ============================================================
   2. CARD
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  transition: var(--transition-colors);
  position: relative;
  overflow: hidden;
}

.card-hoverable {
  cursor: pointer;
  transition:
    transform var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

.card-hoverable:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.card-interactive {
  cursor: pointer;
  transition:
    transform var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

.card-interactive:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-brand);
}

.card-interactive:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.card.is-selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* Card header/body/footer */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: calc(var(--card-padding) * -1);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--card-padding);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
}

.card-subtitle {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin: 2px 0 0;
}

.card-body {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0 calc(var(--card-padding) * -1) calc(var(--card-padding) * -1);
  padding: var(--space-3) var(--card-padding);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
}

/* Stat card */
.card-stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: var(--transition-colors);
  min-height: 100px;
}

.card-stat:hover {
  border-color: var(--border-default);
  background: var(--bg-surface-2);
}

.card-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.card-stat-label {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

.card-stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-active);
  color: var(--accent-primary);
  flex-shrink: 0;
}

.card-stat-icon svg { width: 18px; height: 18px; }

.card-stat-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.card-stat-meta {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.card-stat-meta.is-up { color: var(--color-success-500); }
.card-stat-meta.is-down { color: var(--color-danger-500); }

/* Glass card — theme-aware */
.card-glass {
  background: rgba(15, 36, 56, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.10);
}

[data-theme="light"] .card-glass {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(10, 25, 41, 0.08);
}

/* Featured card */
.card-featured {
  border-left: 3px solid var(--accent-primary);
  padding-left: calc(var(--card-padding) - 3px);
}

/* ============================================================
   3. BADGE, CHIP, TAG
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  line-height: 1.4;
  letter-spacing: var(--ls-wide);
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  color: var(--text-secondary);
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-primary {
  background: rgba(112,166,237, 0.15);
  color: var(--accent-primary);
  border-color: rgba(112,166,237, 0.30);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success-600);
  border-color: rgba(16, 185, 129, 0.30);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning-600);
  border-color: rgba(245, 158, 11, 0.30);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger-600);
  border-color: rgba(239, 68, 68, 0.30);
}

.badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-info-600);
  border-color: rgba(59, 130, 246, 0.30);
}

.badge-solid {
  background: var(--accent-primary);
  color: var(--text-on-accent);
  border-color: transparent;
}

.badge-xs {
  padding: 1px 6px;
  font-size: 9px;
  letter-spacing: 0.2px;
}

.badge-lg {
  padding: 4px 10px;
  font-size: var(--fs-xs);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-circle);
  background: currentColor;
  display: inline-block;
  flex-shrink: 0;
}

/* Chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  height: 32px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--transition-colors);
  white-space: nowrap;
  text-decoration: none;
}

.chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
  text-decoration: none;
}

.chip:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.chip.is-active {
  background: var(--accent-primary);
  color: var(--text-on-accent);
  border-color: var(--accent-primary);
  font-weight: var(--fw-semibold);
}

.chip.is-active:hover {
  background: var(--accent-primary-hover);
  color: var(--text-on-accent);
  border-color: var(--accent-primary-hover);
}

.chip-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-circle);
  background: rgba(0, 0, 0, 0.15);
  color: inherit;
  border: 0;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}

.chip-close:hover {
  background: rgba(0, 0, 0, 0.30);
}

/* Chip group */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip-group-scroll {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chip-group-scroll::-webkit-scrollbar { display: none; }

/* ============================================================
   4. AVATAR
   ============================================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-md);
  height: var(--avatar-md);
  border-radius: var(--radius-circle);
  background: var(--accent-gradient);
  color: var(--color-navy-950);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--border-default);
  text-transform: uppercase;
}

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

.avatar-xs { width: 24px; height: 24px; font-size: var(--fs-2xs); border-width: 1px; }
.avatar-sm { width: var(--avatar-sm); height: var(--avatar-sm); font-size: var(--fs-xs); }
.avatar-lg { width: var(--avatar-lg); height: var(--avatar-lg); font-size: var(--fs-lg); }
.avatar-xl { width: var(--avatar-xl); height: var(--avatar-xl); font-size: var(--fs-2xl); border-width: 3px; }

.avatar-square { border-radius: var(--radius-md); }

/* Avatar dengan status */
.avatar-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.avatar-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-circle);
  border: 2px solid var(--bg-surface);
}

.avatar-status.is-online { background: var(--color-success-500); }
.avatar-status.is-offline { background: var(--color-navy-500); }
.avatar-status.is-busy { background: var(--color-danger-500); }

/* Avatar group */
.avatar-group,
.avatar-stack {
  display: inline-flex;
}
.avatar-group .avatar,
.avatar-stack .avatar {
  margin-left: -8px;
}
.avatar-group .avatar:first-child,
.avatar-stack .avatar:first-child {
  margin-left: 0;
}
.avatar-group .avatar:not(:first-child),
.avatar-stack .avatar:not(:first-child) {
  border-color: var(--bg-surface);
}

/* ============================================================
   5. FORM — INPUT, SELECT, TEXTAREA, CHECKBOX, RADIO, SWITCH
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.form-label .required {
  color: var(--color-danger-500);
  font-weight: var(--fw-bold);
}

.form-helper {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: -2px;
}

.form-error {
  font-size: var(--fs-xs);
  color: var(--color-danger-500);
  display: none;
  align-items: center;
  gap: var(--space-1);
}

.form-group.has-error .form-error { display: flex; }
.form-group.has-error .input,
.form-group.has-error .textarea,
.form-group.has-error .select { border-color: var(--color-danger-500); }
.form-group.has-error .input:focus,
.form-group.has-error .textarea:focus,
.form-group.has-error .select:focus {
  border-color: var(--color-danger-500);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.20);
}

/* Input dasar */
.input,
.textarea,
.select {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--input-padding-x);
  font-size: var(--fs-sm);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--input-radius);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
}

.textarea {
  height: auto;
  min-height: 100px;
  padding: var(--space-3) var(--input-padding-x);
  line-height: var(--lh-relaxed);
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input:hover:not(:disabled),
.textarea:hover:not(:disabled),
.select:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  background: var(--bg-surface);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  background: var(--bg-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Select chevron */
.select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238ba3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: calc(var(--input-padding-x) + 24px);
}

[data-theme="light"] .select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23526a82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* Input dengan ikon */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .input {
  padding-left: 42px;
}

.input-group-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.input-group-icon svg { width: 18px; height: 18px; }

.input-group-suffix {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.input-suffix-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: var(--transition-colors);
}

.input-suffix-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Checkbox */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-surface-2);
  cursor: pointer;
  transition: var(--transition-colors);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.checkbox input[type="checkbox"]:hover {
  border-color: var(--accent-primary);
}

.checkbox input[type="checkbox"]:checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0px;
  width: 5px;
  height: 10px;
  border: solid var(--text-on-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Radio */
.radio {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.radio input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-circle);
  background: var(--bg-surface-2);
  cursor: pointer;
  transition: var(--transition-colors);
  position: relative;
}

.radio input[type="radio"]:hover {
  border-color: var(--accent-primary);
}

.radio input[type="radio"]:checked {
  border-color: var(--accent-primary);
  background: var(--bg-surface);
}

.radio input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: var(--radius-circle);
  background: var(--accent-primary);
}

.radio input[type="radio"]:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-3);
  border: 0;
  cursor: pointer;
  transition: background-color var(--duration-base) var(--ease-out);
  flex-shrink: 0;
}

.switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-circle);
  background: var(--text-secondary);
  transition:
    transform var(--duration-base) var(--ease-out),
    background-color var(--duration-base) var(--ease-out);
}

.switch input[type="checkbox"]:checked {
  background: var(--accent-primary);
}

.switch input[type="checkbox"]:checked::after {
  transform: translateX(18px);
  background: var(--text-on-accent);
}

.switch input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Range */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-surface-3);
  border-radius: var(--radius-pill);
  outline: none;
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-circle);
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-circle);
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid var(--bg-surface);
}

/* ============================================================
   6. ALERT / BANNER
   ============================================================ */
.alert {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  margin-bottom: var(--space-4);
  position: relative;
}

.alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  font-size: var(--fs-sm);
}

.alert-body {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin: 0;
}

.alert-dismiss {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  color: currentColor;
  opacity: 0.6;
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.alert-dismiss:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.10);
}

.alert-success {
  background: rgba(16, 185, 129, 0.10);
  border-color: rgba(16, 185, 129, 0.30);
  color: var(--color-success-600);
}
.alert-success .alert-title { color: var(--color-success-600); }
.alert-success .alert-body { color: var(--color-success-600); opacity: 0.85; }

.alert-warning {
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.30);
  color: var(--color-warning-600);
}
.alert-warning .alert-title { color: var(--color-warning-600); }
.alert-warning .alert-body { color: var(--color-warning-600); opacity: 0.85; }

.alert-danger {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.30);
  color: var(--color-danger-600);
}
.alert-danger .alert-title { color: var(--color-danger-600); }
.alert-danger .alert-body { color: var(--color-danger-600); opacity: 0.85; }

.alert-info {
  background: rgba(59, 130, 246, 0.10);
  border-color: rgba(59, 130, 246, 0.30);
  color: var(--color-info-600);
}
.alert-info .alert-title { color: var(--color-info-600); }
.alert-info .alert-body { color: var(--color-info-600); opacity: 0.85; }

/* ============================================================
   7. MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  padding-top: calc(var(--space-4) + var(--safe-top));
  padding-bottom: calc(var(--space-4) + var(--safe-bottom));
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--duration-base) var(--ease-out),
    visibility var(--duration-base) var(--ease-out);
}

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

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - var(--space-8));
  max-height: calc(100dvh - var(--space-8));
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: translateY(16px) scale(0.98);
  transition: transform var(--duration-base) var(--ease-out);
}

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

.modal-sm { max-width: 360px; }
.modal-lg { max-width: 640px; }
.modal-xl { max-width: 800px; }

.modal-fullscreen {
  max-width: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 0;
  border: 0;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
}

.modal-subtitle {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-colors);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-close svg { width: 18px; height: 18px; }

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ============================================================
   8. TOAST
   ============================================================ */
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  line-height: 1.5;
  animation: toast-in var(--duration-base) var(--ease-out);
  max-width: 100%;
  word-break: break-word;
  position: relative;
  overflow: hidden;
}

.toast.is-leaving {
  animation: toast-out var(--duration-base) var(--ease-out) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.toast-content { flex: 1; min-width: 0; }

.toast-title {
  font-weight: var(--fw-semibold);
  margin-bottom: 2px;
  font-size: var(--fs-sm);
}

.toast-message {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.toast-close {
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: currentColor;
  opacity: 0.6;
  animation: toast-progress linear forwards;
}

@keyframes toast-progress {
  from { width: 100%; }
  to   { width: 0%; }
}

.toast-success { border-left-color: var(--color-success-500); }
.toast-success .toast-icon { color: var(--color-success-500); }

.toast-error,
.toast-danger { border-left-color: var(--color-danger-500); }
.toast-error .toast-icon,
.toast-danger .toast-icon { color: var(--color-danger-500); }

.toast-warning { border-left-color: var(--color-warning-500); }
.toast-warning .toast-icon { color: var(--color-warning-500); }

.toast-info { border-left-color: var(--color-info-500); }
.toast-info .toast-icon { color: var(--color-info-500); }

/* ============================================================
   9. TABS & SEGMENTED
   ============================================================ */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-tertiary);
  background: transparent;
  border: 0;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  text-decoration: none;
  transition: var(--transition-colors);
}

.tab:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.tab:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
  border-radius: var(--radius-xs);
}

.tab.is-active {
  color: var(--accent-primary);
  font-weight: var(--fw-semibold);
}

.tab.is-active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: var(--space-3);
  right: var(--space-3);
  height: 2px;
  background: var(--accent-primary);
  border-radius: var(--radius-pill);
}

/* Tabs pill */
.tabs-pill {
  display: inline-flex;
  padding: var(--space-1);
  gap: var(--space-1);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  border-bottom: 0;
  margin-bottom: var(--space-4);
}

.tabs-pill .tab {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
}

.tabs-pill .tab.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.tabs-pill .tab.is-active::after { display: none; }

/* Segmented control */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.segmented-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-tertiary);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: var(--transition-colors);
  white-space: nowrap;
}

.segmented-item:hover {
  color: var(--text-primary);
}

.segmented-item.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.segmented-item:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
}

/* ============================================================
   10. DROPDOWN
   ============================================================ */
.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 200px;
  padding: var(--space-2);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition:
    opacity var(--duration-fast) var(--ease-out),
    visibility var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
  list-style: none;
  margin: 0;
}

.dropdown.is-open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: var(--transition-colors);
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
  outline: none;
}

.dropdown-item.is-active {
  background: var(--accent-subtle);
  color: var(--accent-primary);
  font-weight: var(--fw-semibold);
}

.dropdown-item.is-danger {
  color: var(--color-danger-500);
}

.dropdown-item.is-danger:hover {
  background: rgba(239, 68, 68, 0.10);
  color: var(--color-danger-500);
}

.dropdown-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-2) 0;
  border: 0;
}

/* ============================================================
   11. PROGRESS
   ============================================================ */
.progress {
  width: 100%;
  height: 8px;
  background: var(--bg-surface-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}

.progress-sm { height: 4px; }
.progress-lg { height: 12px; }

.progress-bar {
  height: 100%;
  background: var(--accent-primary);
  border-radius: inherit;
  transition: width var(--duration-slow) var(--ease-out);
  min-width: 0;
}

.progress-bar-gradient {
  background: var(--accent-gradient);
}

.progress-bar-success { background: var(--color-success-500); }
.progress-bar-warning { background: var(--color-warning-500); }
.progress-bar-danger { background: var(--color-danger-500); }

/* Striped animation */
.progress-bar-striped {
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  );
  background-size: 16px 16px;
  animation: progress-striped 1s linear infinite;
}

@keyframes progress-striped {
  from { background-position: 0 0; }
  to   { background-position: 16px 0; }
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.progress-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.progress-info strong {
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
}

/* Donut */
.donut {
  --donut-size: 120px;
  --donut-thickness: 12px;
  --donut-percent: 0;
  --donut-color: var(--accent-primary);
  --donut-track: var(--bg-surface-3);
  width: var(--donut-size);
  height: var(--donut-size);
  border-radius: var(--radius-circle);
  background: conic-gradient(
    var(--donut-color) 0% calc(var(--donut-percent) * 1%),
    var(--donut-track) calc(var(--donut-percent) * 1%) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.donut::before {
  content: "";
  position: absolute;
  inset: var(--donut-thickness);
  border-radius: var(--radius-circle);
  background: var(--bg-surface);
}

.donut-content {
  position: relative;
  z-index: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-value {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  line-height: 1;
}

.donut-label {
  font-size: var(--fs-2xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  margin-top: var(--space-1);
}

/* ============================================================
   12. SKELETON & SPINNER
   ============================================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface-2) 25%,
    var(--bg-surface-3) 50%,
    var(--bg-surface-2) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  display: block;
  min-height: 12px;
}

.skeleton-text {
  height: 12px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-xs);
}

.skeleton-title {
  height: 20px;
  width: 50%;
  margin-bottom: var(--space-3);
}

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

.skeleton-card {
  height: 100px;
  border-radius: var(--radius-lg);
}

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

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

/* Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: var(--radius-circle);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }
.spinner-md { width: 28px; height: 28px; border-width: 3px; }
.spinner-lg { width: 44px; height: 44px; border-width: 4px; }

.spinner-success { border-top-color: var(--color-success-500); }
.spinner-warning { border-top-color: var(--color-warning-500); }
.spinner-danger  { border-top-color: var(--color-danger-500); }

@keyframes spin { to { transform: rotate(360deg); } }

/* Full page loader */
.loader-full {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 40vh;
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
}

.loader-full .spinner {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* ============================================================
   13. EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-4);
  text-align: center;
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-2xl);
  background: var(--bg-muted);
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
  font-size: 28px;
}

.empty-icon svg {
  width: 28px;
  height: 28px;
}

.empty-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0;
}

.empty-description {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  max-width: 320px;
  margin: 0;
  line-height: var(--lh-relaxed);
}

.empty-state .btn {
  margin-top: var(--space-2);
}

/* ============================================================
   14. PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  padding: var(--space-4) 0;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-colors);
  text-decoration: none;
}

.page-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
  text-decoration: none;
}

.page-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.page-btn.is-active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--text-on-accent);
  font-weight: var(--fw-semibold);
}

.page-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ============================================================
   15. TOOLTIP (4 posisi)
   ============================================================ */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  padding: var(--space-2) var(--space-3);
  background: var(--color-navy-950);
  color: var(--color-white);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--duration-fast) var(--ease-out),
    visibility var(--duration-fast) var(--ease-out);
  z-index: var(--z-tooltip);
  box-shadow: var(--shadow-md);
  line-height: 1.4;
}

.tooltip::before {
  content: "";
  position: absolute;
  border: 4px solid transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--duration-fast) var(--ease-out),
    visibility var(--duration-fast) var(--ease-out);
  z-index: var(--z-tooltip);
}

/* Default: atas */
.tooltip::after {
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
}
.tooltip::before {
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border-top-color: var(--color-navy-950);
}

/* Bawah */
.tooltip.tooltip-bottom::after {
  bottom: auto;
  top: calc(100% + 8px);
}
.tooltip.tooltip-bottom::before {
  bottom: auto;
  top: calc(100% + 2px);
  border-top-color: transparent;
  border-bottom-color: var(--color-navy-950);
}

/* Kiri */
.tooltip.tooltip-left::after {
  bottom: auto;
  top: 50%;
  left: auto;
  right: calc(100% + 8px);
  transform: translateY(-50%);
}
.tooltip.tooltip-left::before {
  bottom: auto;
  top: 50%;
  left: auto;
  right: calc(100% + 2px);
  transform: translateY(-50%);
  border-top-color: transparent;
  border-left-color: var(--color-navy-950);
}

/* Kanan */
.tooltip.tooltip-right::after {
  bottom: auto;
  top: 50%;
  left: calc(100% + 8px);
  transform: translateY(-50%);
}
.tooltip.tooltip-right::before {
  bottom: auto;
  top: 50%;
  left: calc(100% + 2px);
  transform: translateY(-50%);
  border-top-color: transparent;
  border-right-color: var(--color-navy-950);
}

.tooltip:hover::after,
.tooltip:hover::before,
.tooltip:focus-visible::after,
.tooltip:focus-visible::before {
  opacity: 1;
  visibility: visible;
}

/* ============================================================
   16. BREADCRUMB
   ============================================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-bottom: var(--space-4);
  list-style: none;
  padding: 0;
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.breadcrumb-item a {
  color: var(--text-tertiary);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  color: var(--accent-primary);
  text-decoration: none;
}

.breadcrumb-item.is-current {
  color: var(--text-primary);
  font-weight: var(--fw-medium);
}

.breadcrumb-separator {
  color: var(--text-muted);
  user-select: none;
}

/* ============================================================
   17. DIVIDER DENGAN LABEL
   ============================================================ */
.divider-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-5) 0;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  font-weight: var(--fw-semibold);
}

.divider-label::before,
.divider-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ============================================================
   18. STICKY BOTTOM ACTION BAR
   ============================================================ */
.action-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-default);
  z-index: var(--z-sticky);
  margin: var(--space-4) calc(var(--space-4) * -1) calc(var(--space-6) * -1);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .action-bar { background: var(--bg-surface); }
}

.action-bar .btn { flex: 1; }

/* ============================================================
   19. TAG / PILL KECIL
   ============================================================ */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  color: var(--text-tertiary);
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.tag-success { background: rgba(16, 185, 129, 0.12); color: var(--color-success-600); }
.tag-warning { background: rgba(245, 158, 11, 0.12); color: var(--color-warning-600); }
.tag-danger  { background: rgba(239, 68, 68, 0.12); color: var(--color-danger-600); }
.tag-info    { background: rgba(59, 130, 246, 0.12); color: var(--color-info-600); }

/* ============================================================
   20. LIST ITEM
   ============================================================ */
.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  transition: var(--transition-colors);
  text-decoration: none;
}

.list-item:last-child { border-bottom: 0; }

.list-item:hover {
  background: var(--bg-hover);
  text-decoration: none;
  color: var(--text-primary);
}

.list-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-muted);
  color: var(--accent-primary);
  flex-shrink: 0;
}

.list-item-icon svg { width: 20px; height: 20px; }

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-subtitle {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

/* ============================================================
   21. TABLE (BARU — generic)
   ============================================================ */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  color: var(--text-tertiary);
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table-hover tbody tr {
  transition: background-color var(--duration-fast) var(--ease-out);
}

.table-hover tbody tr:hover {
  background: var(--bg-hover);
}

.table-striped tbody tr:nth-child(odd) {
  background: var(--bg-muted);
}

.table-compact thead th,
.table-compact tbody td {
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-xs);
}

.table .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* ============================================================
   22. ACCORDION (BARU)
   ============================================================ */
.accordion {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
}

.accordion-item {
  border-bottom: 1px solid var(--border-subtle);
}

.accordion-item:last-child {
  border-bottom: 0;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  text-align: left;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.accordion-trigger:hover {
  background: var(--bg-hover);
}

.accordion-trigger:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
}

.accordion-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  transition: transform var(--duration-base) var(--ease-out);
  color: var(--text-tertiary);
}

.accordion-trigger[aria-expanded="true"] .accordion-icon {
  transform: rotate(180deg);
  color: var(--accent-primary);
}

.accordion-panel {
  padding: 0 var(--space-4) var(--space-4);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
}

.accordion-panel[hidden] {
  display: none;
}

/* ============================================================
   23. CODE BLOCK + COPY (BARU)
   ============================================================ */
.code-block {
  position: relative;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface-3);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.code-block pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: var(--space-4);
  overflow-x: auto;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: var(--transition-colors);
}

.copy-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.copy-btn.is-copied {
  color: var(--color-success-500);
  border-color: var(--color-success-500);
}

/* ============================================================
   24. LINK VARIANTS
   ============================================================ */
.link-muted {
  color: var(--text-tertiary);
}
.link-muted:hover {
  color: var(--text-primary);
}
.link-brand {
  color: var(--text-brand);
  font-weight: var(--fw-medium);
}
.link-brand:hover {
  color: var(--accent-primary-hover);
  text-decoration: underline;
}

/* ============================================================
   25. RESPONSIF
   ============================================================ */
@media (max-width: 480px) {
  .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .tooltip::after {
    max-width: 200px;
    white-space: normal;
    text-align: center;
  }

  .empty-state {
    padding: var(--space-8) var(--space-3);
  }

  .empty-icon {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
}

/* ============================================================
   26. PRINT
   ============================================================ */
@media print {
  .btn,
  .chip,
  .toast,
  .modal-backdrop,
  .dropdown-menu,
  .action-bar,
  .pagination,
  .tabs,
  .tabs-pill,
  .segmented,
  .tooltip::after,
  .tooltip::before,
  .code-block-header,
  .copy-btn {
    display: none !important;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
    background: #ffffff !important;
  }

  .table thead th {
    background: #f5f5f5 !important;
    color: #000 !important;
  }
}

/* ============================================================
   CAT ACADEMY IMIPAS — css/components.css
   v2.1 — UI STABILITY PATCH
   Tambahkan setelah kode v2.0.
   ============================================================ */

/* 1. GLOBAL COMPONENT SAFETY */

.btn,
.card,
.modal,
.dropdown-menu,
.input,
.select,
.textarea,
.table-wrap {
  box-sizing: border-box;
  min-width: 0;
}

.btn svg,
.modal-close svg,
.dropdown-item svg {
  flex-shrink: 0;
  max-width: 100%;
}

/* 2. BUTTON LOADING FIX */

.btn.is-loading {
  cursor: wait;
  color: transparent !important;
}

.btn.is-loading::after {
  color: var(--text-on-accent, #fff);
  border-color: currentColor;
  border-right-color: transparent;
}

.btn-secondary.is-loading::after,
.btn-outline.is-loading::after,
.btn-ghost.is-loading::after,
.btn-primary-soft.is-loading::after,
.btn-success-soft.is-loading::after,
.btn-warning-soft.is-loading::after,
.btn-danger-soft.is-loading::after,
.btn-info-soft.is-loading::after {
  color: var(--accent-primary, #70a6ed);
}

.btn-warning.is-loading::after,
.btn-gradient.is-loading::after {
  color: var(--color-navy-950, #07111f);
}

/* 3. DISABLED STATES */

.input:disabled,
.select:disabled,
.textarea:disabled,
.checkbox input:disabled,
.radio input:disabled,
.switch input:disabled {
  opacity: .65;
  cursor: not-allowed;
}

.checkbox input:disabled,
.radio input:disabled,
.switch input:disabled {
  pointer-events: none;
}

/* 4. FORM VALIDATION */

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--color-danger-500, #ef4444);
}

.input[aria-invalid="true"]:focus,
.select[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .18);
}

/* 5. MODAL SAFE AREA */

.modal-backdrop {
  padding:
    calc(var(--space-3, 12px) + env(safe-area-inset-top, 0px))
    var(--space-3, 12px)
    calc(var(--space-3, 12px) + env(safe-area-inset-bottom, 0px));
}

.modal {
  max-height: calc(
    100dvh -
    24px -
    env(safe-area-inset-top, 0px) -
    env(safe-area-inset-bottom, 0px)
  );
}

.modal-body {
  min-height: 0;
  overscroll-behavior: contain;
}

.modal-fullscreen {
  max-height: 100dvh;
  height: 100dvh;
}

/* 6. NATIVE DIALOG SUPPORT */

dialog.modal {
  margin: auto;
  padding: 0;
  color: var(--text-primary);
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, .68);
}

dialog.modal:not([open]) {
  display: none;
}

/* 7. DROPDOWN MOBILE SAFETY */

.dropdown-menu {
  max-width: min(320px, calc(100vw - 24px));
  max-height: min(65dvh, 480px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dropdown-menu[hidden] {
  display: none !important;
}

/* 8. TOAST CONTAINER */

.toast-container {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
  z-index: 12000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast-container .toast {
  width: 100%;
  pointer-events: auto;
}

.toast-message {
  overflow-wrap: anywhere;
}

/* 9. ACCESSIBLE STATUS COLORS */

[data-theme="dark"] .badge-success,
[data-theme="dark"] .tag-success,
[data-theme="dark"] .btn-success-soft {
  color: #6ee7b7;
}

[data-theme="dark"] .badge-warning,
[data-theme="dark"] .tag-warning,
[data-theme="dark"] .btn-warning-soft {
  color: #fcd34d;
}

[data-theme="dark"] .badge-danger,
[data-theme="dark"] .tag-danger,
[data-theme="dark"] .btn-danger-soft {
  color: #fca5a5;
}

[data-theme="dark"] .badge-info,
[data-theme="dark"] .tag-info,
[data-theme="dark"] .btn-info-soft {
  color: #93c5fd;
}

/* 10. CARD CONTENT SAFETY */

.card,
.card-header,
.card-body,
.card-footer {
  min-width: 0;
}

.card-title,
.card-subtitle,
.alert-content,
.empty-description {
  overflow-wrap: anywhere;
}

/* 11. RESPONSIVE TABLE */

.table-wrap {
  max-width: 100%;
  overscroll-behavior-x: contain;
}

.table {
  min-width: 0;
}

.table th,
.table td {
  overflow-wrap: break-word;
}

.table th[scope="row"] {
  color: var(--text-primary);
  font-weight: 600;
}

/* 12. STICKY ACTION BAR */

@media (max-width: 1023px) {
  .action-bar {
    bottom: calc(
      var(--bottom-nav-height, 64px) +
      env(safe-area-inset-bottom, 0px)
    );
  }
}

@media (min-width: 1024px) {
  .action-bar {
    bottom: 0;
  }
}

/* 13. MOBILE OPTIMIZATION */

@media (max-width: 480px) {
  .toast-container {
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    width: auto;
  }

  .modal {
    max-width: 100%;
  }

  .modal-header,
  .modal-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .btn-group {
    max-width: 100%;
  }

  .segmented {
    max-width: 100%;
    overflow-x: auto;
  }

  .table-wrap {
    border-radius: 10px;
  }
}

/* 14. REDUCED MOTION */

@media (prefers-reduced-motion: reduce) {
  .btn,
  .card-hoverable,
  .card-interactive,
  .modal,
  .toast,
  .progress-bar,
  .spinner,
  .skeleton,
  .donut,
  .dropdown-menu {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* 15. PRINT SAFETY */

@media print {
  .toast-container,
  dialog.modal,
  .modal-backdrop {
    display: none !important;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
  }

  .table {
    width: 100%;
  }

  .table tr {
    break-inside: avoid;
  }
}

.ca-file-panel { margin:1rem auto;max-width:64rem;padding:1rem;border:1px solid var(--border-default);border-radius:14px;background:var(--bg-surface);color:var(--text-primary) }
.ca-file-panel form { display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,14rem),1fr));gap:.75rem;margin-block:1rem }
.ca-file-panel label,.ca-file-panel a {display:block;margin-block:.4rem}
.ca-file-panel input,.ca-file-panel select,.ca-file-panel button {min-height:44px;max-width:100%;border:1px solid var(--border-default);padding:.45rem .75rem;border-radius:8px;background:var(--bg-surface);color:inherit}
.ca-file-panel article {padding-block:1rem;border-bottom:1px solid var(--border-default)}
.ca-inbox {width:min(94vw,440px);max-height:75dvh;border:1px solid var(--border-default);border-radius:16px;padding:1rem;background:var(--bg-surface);color:var(--text-primary)}
.ca-inbox::backdrop {background:#06122499}
.ca-inbox button {display:block;min-height:44px;margin:.5rem 0;width:100%;text-align:left;background:var(--bg-surface-2);color:inherit;border:1px solid var(--border-default);border-radius:8px;padding:.6rem}
.am2-inner[hidden],.mat7-inner[hidden],.ca-file-panel [hidden] { display:none!important }
.ca-file-panel button[aria-pressed=true] {border-color:var(--accent-primary,#2369c4);font-weight:bold}
