/* ==========================================================================
   Algo Tools — Shared Components
   Header, footer, buttons, cards, forms, badges, progress, modal, toast.
   Reused across every tool in the Algo Tools family.
   ========================================================================== */

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--c-bg) 85%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--c-border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }

.brand { display: flex; align-items: center; gap: var(--sp-2); font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-2));
  display: flex; align-items: center; justify-content: center;
  color: #06110C; font-weight: 800; font-size: var(--fs-sm);
  box-shadow: var(--shadow-sm);
}
.brand-name span { color: var(--c-accent); }

.header-actions { display: flex; align-items: center; gap: var(--sp-3); }

.lang-switch { position: relative; }
.lang-switch select {
  appearance: none;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  padding: var(--sp-2) var(--sp-6) var(--sp-2) var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.lang-switch::after {
  content: "";
  position: absolute; right: 12px; top: 50%;
  width: 8px; height: 8px;
  border-right: 2px solid var(--c-text-muted);
  border-bottom: 2px solid var(--c-text-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--c-border);
  padding-block: var(--sp-8);
  margin-top: var(--sp-12);
  color: var(--c-text-faint);
  font-size: var(--fs-sm);
}
.site-footer .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-full);
  font-weight: 600;
  font-size: var(--fs-sm);
  border: 1px solid transparent;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: linear-gradient(135deg, var(--c-accent), var(--c-accent-2)); color: #06110C; }
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-glow); transform: translateY(-1px); }

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

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

.btn-danger { background: transparent; border-color: var(--c-border); color: var(--c-danger); }
.btn-danger:hover:not(:disabled) { background: rgba(239, 69, 96, 0.1); border-color: var(--c-danger); }

.btn-sm { padding: var(--sp-2) var(--sp-4); font-size: var(--fs-xs); }
.btn-block { width: 100%; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: var(--r-full); }

/* ---------- Card / Surface ---------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

/* ---------- Badge / Chip ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--c-accent-soft);
  color: var(--c-accent);
  border: 1px solid transparent;
}
.badge-outline { background: transparent; border-color: var(--c-border); color: var(--c-text-muted); }

/* ---------- Progress Bar ---------- */
.progress {
  width: 100%;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--c-surface-2);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--c-accent), var(--c-accent-2));
  transition: width var(--dur-base) var(--ease-out);
}
.progress-fill.indeterminate {
  width: 40% !important;
  animation: progress-slide 1.1s var(--ease-out) infinite;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--c-accent-soft);
  border-top-color: var(--c-accent);
  animation: spin 0.8s linear infinite;
}

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  right: var(--sp-4);
  bottom: var(--sp-4);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: min(360px, calc(100vw - 2 * var(--sp-4)));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-sm);
  color: var(--c-text);
  animation: toast-in var(--dur-base) var(--ease-out);
}
.toast.hide { animation: toast-out var(--dur-base) var(--ease-out) forwards; }
.toast-success { border-left: 3px solid var(--c-success); }
.toast-error { border-left: 3px solid var(--c-danger); }
.toast-warn { border-left: 3px solid var(--c-warn); }
.toast-info { border-left: 3px solid var(--c-accent-2); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(4, 6, 16, 0.6);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  z-index: 1500;
  animation: fade-in var(--dur-fast) var(--ease-out);
}
.modal {
  width: 100%;
  max-width: 420px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: var(--sp-6);
  animation: modal-in var(--dur-base) var(--ease-out);
}

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--c-text-faint); }

/* ---------- Utility text ---------- */
.text-muted { color: var(--c-text-muted); }
.text-faint { color: var(--c-text-faint); }
.text-accent { color: var(--c-accent); }
