/* ============================================
   Stethiano · Components
   Buttons · Cards · Badges · Forms · Modals · Tabs · Toasts
   ============================================ */

/* -------- Buttons -------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-5);
  height: 44px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease-out);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .icon { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }

.btn-accent { background: var(--color-accent); color: #1F1300; }
.btn-accent:hover:not(:disabled) { background: var(--color-accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-2); border-color: var(--color-border-strong); }

.btn-ghost { background: transparent; color: var(--color-text); }
.btn-ghost:hover:not(:disabled) { background: var(--color-surface-2); }

.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #DC2626; }

.btn-link { background: transparent; color: var(--color-primary); padding: 0; height: auto; }
.btn-link:hover { color: var(--color-primary-hover); text-decoration: underline; text-underline-offset: 3px; }

.btn-sm { height: 36px; padding: 0 var(--space-4); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-lg { height: 52px; padding: 0 var(--space-6); font-size: var(--text-base); border-radius: var(--radius-md); }
.btn-xl { height: 60px; padding: 0 var(--space-7); font-size: var(--text-lg); border-radius: var(--radius-lg); }

.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn-icon.btn-lg { width: 52px; }

.btn-block { width: 100%; }

/* -------- Cards -------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.card-flat { border: none; box-shadow: var(--shadow-sm); }
.card-elevated { border: none; box-shadow: var(--shadow-md); }
.card-interactive {
  transition: all var(--dur-base) var(--ease-out);
  cursor: pointer;
}
.card-interactive:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-border-strong);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}
.card-title { font-size: var(--text-lg); font-weight: 600; margin: 0; }

/* -------- Badges -------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-accent { background: var(--color-accent-soft); color: #92400E; }
.badge-success { background: var(--color-success-soft); color: #047857; }
.badge-warning { background: var(--color-warning-soft); color: #92400E; }
.badge-danger { background: var(--color-danger-soft); color: #B91C1C; }
.badge-info { background: var(--color-info-soft); color: #1D4ED8; }
.badge-neutral { background: var(--color-surface-2); color: var(--color-text-2); }
.badge-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-text-2); }
.badge-verified {
  background: linear-gradient(135deg, #0F766E, #14B8A6);
  color: white;
  padding: 4px 10px 4px 8px;
}

/* -------- Forms -------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}
.label-hint { color: var(--color-muted); font-weight: 400; margin-left: 4px; }

.input, .textarea, .select {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--color-muted-2); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--color-border-strong); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}
.textarea { height: auto; padding: var(--space-3) var(--space-4); resize: vertical; min-height: 96px; line-height: var(--leading-normal); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236B7280'%3E%3Cpath d='M5.23 7.21a.75.75 0 011.06.02L10 11.06l3.71-3.83a.75.75 0 011.08 1.04l-4.25 4.4a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group .input { padding-left: 42px; }
.input-group .input.has-suffix { padding-right: 42px; }
.input-group .input-icon {
  position: absolute;
  left: 14px;
  width: 18px; height: 18px;
  color: var(--color-muted);
  pointer-events: none;
}
.input-group .input-suffix {
  position: absolute;
  right: 12px;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.field-help { font-size: var(--text-xs); color: var(--color-muted); }
.field-error .input, .field-error .textarea, .field-error .select { border-color: var(--color-danger); }
.field-error .field-help { color: var(--color-danger); }

/* Checkbox / Radio */
.check {
  display: inline-flex; align-items: flex-start; gap: 10px;
  cursor: pointer; user-select: none;
  font-size: var(--text-sm);
  color: var(--color-text-2);
}
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 18px; height: 18px;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--color-surface);
  transition: all var(--dur-fast) var(--ease-out);
  margin-top: 1px;
}
.check input:checked + .box {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.check input:checked + .box::after {
  content: "";
  width: 10px; height: 6px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg) translate(1px, -1px);
}
.check.radio .box { border-radius: 50%; }
.check.radio input:checked + .box::after {
  content: "";
  width: 8px; height: 8px;
  background: white;
  border: none;
  border-radius: 50%;
  transform: none;
}

/* Switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: var(--color-surface-3);
  border-radius: var(--radius-pill);
  transition: background var(--dur-base) var(--ease-out);
}
.switch .slider::before {
  content: ""; position: absolute;
  width: 18px; height: 18px;
  left: 2px; top: 2px;
  background: white;
  border-radius: 50%;
  transition: transform var(--dur-base) var(--ease-out);
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--color-primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* -------- Avatar -------- */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--color-surface-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; color: var(--color-text-2);
  font-size: var(--text-sm);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-base); }
.avatar-xl { width: 96px; height: 96px; font-size: var(--text-2xl); }
.avatar-2xl { width: 128px; height: 128px; font-size: var(--text-3xl); }
.avatar .status-dot {
  position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--color-surface);
  background: var(--color-success);
}

/* Tinted avatar palette */
.avatar.tone-a { background: #FEE2E2; color: #B91C1C; }
.avatar.tone-b { background: #DBEAFE; color: #1D4ED8; }
.avatar.tone-c { background: #CCFBF1; color: #0F766E; }
.avatar.tone-d { background: #FEF3C7; color: #92400E; }
.avatar.tone-e { background: #E0E7FF; color: #4338CA; }
.avatar.tone-f { background: #FCE7F3; color: #BE185D; }
.avatar.tone-g { background: #D1FAE5; color: #047857; }
.avatar.tone-h { background: #F3E8FF; color: #6D28D9; }

/* -------- Tabs -------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 12px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.tab:hover { color: var(--color-text); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab .count { background: var(--color-surface-2); padding: 2px 8px; border-radius: 999px; font-size: 11px; margin-left: 6px; color: var(--color-text-2); }
.tab.active .count { background: var(--color-primary-soft); color: var(--color-primary); }

/* -------- Pills (segmented) -------- */
.pills {
  display: inline-flex;
  background: var(--color-surface-2);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 2px;
}
.pill {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-muted);
  transition: all var(--dur-fast) var(--ease-out);
  cursor: pointer;
}
.pill:hover { color: var(--color-text); }
.pill.active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-xs); }

/* -------- Dropdown -------- */
.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: var(--z-dropdown);
  animation: scaleIn var(--dur-fast) var(--ease-out);
  transform-origin: top right;
}
.dropdown-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  text-align: left;
  width: 100%;
}
.dropdown-item:hover { background: var(--color-surface-2); }
.dropdown-item .icon { width: 16px; height: 16px; color: var(--color-muted); }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger .icon { color: var(--color-danger); }
.dropdown-divider { height: 1px; background: var(--color-divider); margin: 4px 0; }
.dropdown-header { padding: 10px 12px 6px; font-size: var(--text-xs); font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* -------- Modal -------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: grid; place-items: center;
  padding: var(--space-5);
  animation: fadeIn var(--dur-base) var(--ease-out);
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-xl);
  animation: scaleIn var(--dur-base) var(--ease-out);
}
.modal-lg { max-width: 720px; }
.modal-header {
  padding: var(--space-6) var(--space-6) var(--space-4);
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--space-4);
}
.modal-title { font-size: var(--text-xl); font-weight: 600; }
.modal-subtitle { font-size: var(--text-sm); color: var(--color-muted); margin-top: 4px; }
.modal-body { padding: 0 var(--space-6) var(--space-4); }
.modal-footer { padding: var(--space-4) var(--space-6) var(--space-6); display: flex; gap: var(--space-3); justify-content: flex-end; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--color-muted);
  transition: background var(--dur-fast) var(--ease-out);
}
.modal-close:hover { background: var(--color-surface-2); color: var(--color-text); }

/* -------- Accordion -------- */
.accordion-item {
  border-bottom: 1px solid var(--color-border);
}
.accordion-header {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  text-align: left;
}
.accordion-header .chev { transition: transform var(--dur-base) var(--ease-out); color: var(--color-muted); }
.accordion-item.open .accordion-header .chev { transform: rotate(180deg); }
.accordion-body {
  max-height: 0; overflow: hidden;
  transition: max-height var(--dur-base) var(--ease-out);
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.accordion-item.open .accordion-body { max-height: 400px; padding-bottom: var(--space-5); }

/* -------- Table -------- */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: var(--space-4) var(--space-5);
  text-align: left;
  font-size: var(--text-sm);
}
.table th {
  background: var(--color-surface-2);
  font-weight: 600;
  color: var(--color-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.table tbody tr {
  border-top: 1px solid var(--color-divider);
  transition: background var(--dur-fast) var(--ease-out);
}
.table tbody tr:hover { background: var(--color-surface-2); }
.table td { color: var(--color-text-2); }
.table td .strong { color: var(--color-text); font-weight: 500; }

/* -------- Toast -------- */
.toast-container {
  position: fixed;
  top: calc(var(--header-h) + 16px);
  right: 16px;
  z-index: var(--z-toast);
  display: flex; flex-direction: column;
  gap: 10px;
  max-width: 380px;
}
.toast {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  animation: slideUp var(--dur-base) var(--ease-out);
}
.toast .icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.toast.success .icon { color: var(--color-success); }
.toast.warning .icon { color: var(--color-warning); }
.toast.danger .icon { color: var(--color-danger); }
.toast .body { flex: 1; }
.toast .title { font-size: var(--text-sm); font-weight: 600; }
.toast .desc { font-size: var(--text-xs); color: var(--color-muted); margin-top: 2px; }

/* -------- Skeleton -------- */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface-2) 0%, #EAECEF 50%, var(--color-surface-2) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line { height: 12px; }
.skeleton-text { height: 14px; }
.skeleton-title { height: 22px; }
.skeleton-card { height: 220px; border-radius: var(--radius-lg); }

/* -------- Star rating -------- */
.rating { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-sm); }
.rating .star { color: var(--color-accent); width: 14px; height: 14px; }
.rating .star.dim { color: var(--color-surface-3); }
.rating .value { font-weight: 600; color: var(--color-text); }
.rating .count { color: var(--color-muted); }

/* -------- Progress -------- */
.progress { height: 8px; background: var(--color-surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.progress-bar { height: 100%; background: var(--color-primary); border-radius: var(--radius-pill); transition: width var(--dur-slow) var(--ease-out); }
.progress-bar.accent { background: var(--color-accent); }

/* -------- Divider with text -------- */
.divider-text {
  display: flex; align-items: center; gap: 14px;
  color: var(--color-muted); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600;
}
.divider-text::before, .divider-text::after {
  content: ""; flex: 1; height: 1px; background: var(--color-border);
}

/* -------- Empty state -------- */
.empty-state {
  text-align: center;
  padding: var(--space-9) var(--space-5);
}
.empty-state .empty-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  display: grid; place-items: center;
  margin: 0 auto var(--space-4);
}
.empty-state h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.empty-state p { font-size: var(--text-sm); color: var(--color-muted); max-width: 360px; margin: 0 auto; }

/* -------- Spinner -------- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* -------- Chip -------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  color: var(--color-text-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.chip.active { background: var(--color-primary); border-color: var(--color-primary); color: white; }
.chip .icon { width: 14px; height: 14px; }

/* -------- Stat card -------- */
.stat {
  display: flex; flex-direction: column; gap: 4px;
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.stat-label { font-size: var(--text-xs); color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat-value { font-size: var(--text-3xl); font-weight: 700; letter-spacing: var(--tracking-tight); font-variant-numeric: tabular-nums; }
.stat-delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); font-weight: 600; margin-top: 2px; }
.stat-delta.up { color: var(--color-success); }
.stat-delta.down { color: var(--color-danger); }
.stat-icon-wrap {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
}
.stat { position: relative; }
