/* short-link — Reusable Components v1
 * Depends on design-system.css (CSS variables)
 */

/* ========== Buttons ========== */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 9px 16px; border-radius: var(--r-sm);
  font-weight: 500; font-size: var(--fs-base); line-height: 1.2;
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  cursor: pointer; font-family: inherit; color: inherit;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }

.btn-outline { background: var(--bg-elev); border-color: var(--border-strong); color: var(--fg); }
.btn-outline:hover { background: var(--bg-card); border-color: var(--fg-muted); }

.btn-ghost { color: var(--fg-muted); background: transparent; }
.btn-ghost:hover { color: var(--fg); background: var(--bg-card); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.1); }

.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); }
.btn-lg { padding: 13px 22px; font-size: var(--fs-md); }
.btn-block { width: 100%; justify-content: center; }

.icon-btn {
  width: 36px; height: 36px; padding: 0;
  display: grid; place-items: center;
  border-radius: var(--r-sm); color: var(--fg-muted);
  background: transparent; border: 0;
  position: relative;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--bg-card); color: var(--fg); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--bg);
}

/* ========== Cards ========== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-6);
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--s-5); gap: var(--s-4);
}
.card-title { font-size: var(--fs-md); font-weight: 600; }
.card-sub { font-size: var(--fs-sm); color: var(--fg-muted); margin-top: 2px; }

/* ========== Badges ========== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.4;
}
.badge-muted { background: var(--bg-elev); color: var(--fg-dim); }
.badge-accent { background: var(--accent-soft); color: var(--accent-hi); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ========== Inputs ========== */
.input, .textarea, .select {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--fg);
  font: inherit; font-size: var(--fs-base);
  transition: border-color var(--t-fast);
}
.input:focus, .textarea:focus, .select:focus {
  outline: 0; border-color: var(--accent);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-dim); }
.textarea { resize: vertical; min-height: 80px; line-height: var(--lh-base); }

.field { margin-bottom: var(--s-4); }
.field-label {
  display: block;
  font-size: var(--fs-sm); font-weight: 500;
  color: var(--fg-muted); margin-bottom: 6px;
}
.field-hint { font-size: var(--fs-xs); color: var(--fg-dim); margin-top: 4px; }
.field-error { font-size: var(--fs-xs); color: var(--danger); margin-top: 4px; }

/* Checkbox / Radio */
.check, .radio {
  display: inline-flex; align-items: center; gap: var(--s-2);
  cursor: pointer; font-size: var(--fs-base);
}
.check input, .radio input {
  width: 16px; height: 16px; margin: 0;
  accent-color: var(--accent);
}

/* Toggle switch */
.toggle {
  position: relative; display: inline-block;
  width: 36px; height: 20px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border-strong); border-radius: var(--r-full);
  transition: background var(--t-fast);
}
.toggle-slider::before {
  content: ""; position: absolute;
  width: 14px; height: 14px; left: 3px; top: 3px;
  background: var(--fg); border-radius: 50%;
  transition: transform var(--t-fast);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }

/* ========== Tables ========== */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left; padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-base);
}
.table th {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--fg-dim); font-weight: 600;
  padding-top: 0;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--bg-hover); }
.table .num {
  font-variant-numeric: tabular-nums; font-weight: 600;
  text-align: right;
}
.table .num.small {
  font-size: var(--fs-sm); color: var(--fg-muted); font-weight: 500;
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(10, 13, 18, 0.7); backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: var(--s-4);
  animation: fadeIn var(--t-base);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-dialog {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  max-width: 560px; width: 100%; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-dialog.wizard { max-width: 720px; }
.modal-dialog.wide { max-width: 880px; }
.modal-header {
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-title { font-size: var(--fs-xl); font-weight: 600; }
.modal-sub { font-size: var(--fs-sm); color: var(--fg-muted); margin-top: 2px; }
.modal-close {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--fg-muted); background: transparent; border: 0; cursor: pointer;
}
.modal-close:hover { background: var(--bg-hover); color: var(--fg); }
.modal-body { padding: var(--s-6); overflow-y: auto; flex: 1; }
.modal-footer {
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--s-3); justify-content: flex-end;
}

/* ========== Tabs ========== */
.tabs {
  display: flex; gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-5);
}
.tab {
  padding: 10px 14px;
  font-size: var(--fs-base); color: var(--fg-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer; transition: all var(--t-fast);
  background: transparent; border-left: 0; border-right: 0; border-top: 0;
}
.tab:hover { color: var(--fg); }
.tab.active {
  color: var(--accent-hi);
  border-bottom-color: var(--accent);
}

/* ========== Empty state ========== */
.empty-state {
  padding: var(--s-12) var(--s-6);
  text-align: center;
  color: var(--fg-muted);
}
.empty-state-icon {
  width: 56px; height: 56px; margin: 0 auto var(--s-4);
  background: var(--bg-elev); border-radius: var(--r-lg);
  display: grid; place-items: center;
  color: var(--fg-dim);
}
.empty-state-icon svg { width: 28px; height: 28px; }
.empty-state h3 {
  font-size: var(--fs-lg); color: var(--fg);
  margin-bottom: 6px;
}
.empty-state p { max-width: 380px; margin: 0 auto var(--s-5); font-size: var(--fs-base); }

/* ========== Loading skeleton ========== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elev), var(--bg-hover), var(--bg-elev));
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== Spinner ========== */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Toast ========== */
.toast-container {
  position: fixed; right: var(--s-6); bottom: var(--s-6);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--s-2);
  pointer-events: none;
}
.toast {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 12px 16px;
  min-width: 260px; max-width: 380px;
  font-size: var(--fs-base);
  box-shadow: var(--shadow-md);
  display: flex; gap: var(--s-3); align-items: flex-start;
  animation: toastIn 0.25s ease-out;
  pointer-events: auto;
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger  { border-left-color: var(--danger);  }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ========== Tooltip ========== */
.tooltip { position: relative; display: inline-flex; }
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 4px 8px; font-size: var(--fs-xs); color: var(--fg);
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity var(--t-fast);
}
.tooltip:hover::after { opacity: 1; }

/* ========== Divider ========== */
.hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-6) 0; }

/* ========== Avatar ========== */
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #ff6b9d, #c44eb8);
  color: #fff; display: grid; place-items: center;
  font-size: var(--fs-sm); font-weight: 700;
  flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: var(--fs-xs); }
.avatar-lg { width: 40px; height: 40px; font-size: var(--fs-base); }
.avatar-xl { width: 56px; height: 56px; font-size: var(--fs-md); }

/* ========== Code ========== */
code, .code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent-hi);
}
pre {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: var(--fs-sm);
}
pre code { background: transparent; padding: 0; border: 0; color: var(--fg); }
