/* ---------------------------------------------------------------------------
 * html-ui.css — plain HTML + CSS mirror of the squad-ui Button & Input.
 *
 * No Tailwind, no React. Every rule reuses the same design tokens
 * (--primary, --input, --ring, --radius, …) that globals.css declares on
 * :root / .dark .squad-ui, so these classes render byte-identical to the
 * Tailwind components and follow the app's light/dark theme automatically.
 *
 * Spacing/shadow numbers are Tailwind v4's defaults, matched to the utility
 * classes in button.tsx / input.tsx (h-10 = 2.5rem, shadow-sm, etc.).
 * ------------------------------------------------------------------------- */

.sqd-btn {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.5rem;          /* h-10 */
  padding: 0 1rem;         /* px-4 */
  border: 1px solid transparent;
  border-radius: 9999px;   /* rounded-full */
  font-family: var(--font-sans, inherit);
  font-size: 0.875rem;     /* text-sm */
  line-height: 1;          /* leading-none */
  font-weight: 500;        /* font-medium */
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  outline: none;
  transition: all 0.15s ease;
  text-decoration: none;
}

/* When a button is an <a> (e.g. inside a Tailwind Typography `prose`
 * container), stop link underline from leaking in. The `link` variant opts
 * back in via its own :hover rule below. */
a.sqd-btn:not(.sqd-btn--link),
a.sqd-btn:not(.sqd-btn--link):hover {
  text-decoration: none;
}

.sqd-btn:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring), transparent 50%);
}

.sqd-btn:active:not([aria-haspopup]) {
  transform: translateY(1px);
}

.sqd-btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.sqd-btn svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  pointer-events: none;
}

/* --- variants -------------------------------------------------------------- */

.sqd-btn--default {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}
.sqd-btn--default:hover {
  background: color-mix(in oklch, var(--primary), transparent 10%);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.sqd-btn--outline {
  border-color: var(--input);
  background: #fff;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}
.sqd-btn--outline:hover {
  background: var(--accent);
  color: var(--accent-foreground);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.dark .sqd-btn--outline {
  border-color: #242428;
  background: transparent;
}
.dark .sqd-btn--outline:hover {
  background: #242428;
  border-color: #242428;
  color: var(--foreground);
}

.sqd-btn--secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}
.sqd-btn--secondary:hover {
  background: color-mix(in oklch, var(--secondary), transparent 20%);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.sqd-btn--ghost {
  background: transparent;
  color: inherit;
}
.sqd-btn--ghost:hover {
  background: color-mix(in oklch, var(--primary), transparent 90%);
  color: var(--primary);
}

.sqd-btn--soft {
  background: color-mix(in oklch, var(--primary), transparent 90%);
  color: var(--primary);
}
.sqd-btn--soft:hover {
  background: color-mix(in oklch, var(--primary), transparent 85%);
}

.sqd-btn--destructive {
  background: color-mix(in oklch, var(--destructive), transparent 90%);
  color: var(--destructive);
}
.sqd-btn--destructive:hover {
  background: color-mix(in oklch, var(--destructive), transparent 80%);
}

.sqd-btn--coral {
  background: #f9635d;
  color: #fff;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}
.sqd-btn--coral:hover {
  background: color-mix(in oklch, #f9635d, transparent 10%);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.sqd-btn--link {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
  text-underline-offset: 4px;
}
.sqd-btn--link:hover {
  text-decoration: underline;
}

/* --- sizes ----------------------------------------------------------------- */

.sqd-btn--sm {
  height: 2rem;            /* h-8 */
  padding: 0 0.75rem;      /* px-3 */
  gap: 0.375rem;
  font-size: 0.8rem;
}
.sqd-btn--xs {
  height: 1.5rem;          /* h-6 */
  padding: 0 0.5rem;
  gap: 0.25rem;
  font-size: 0.75rem;
}
.sqd-btn--xl {
  height: 3rem;            /* h-12 */
  padding: 0 1.5rem;       /* px-6 */
  font-size: 1rem;
}

/* ---------------------------------------------------------------------------
 * Input — mirror of input.tsx (h-9, rounded-md, border-input, focus ring).
 * ------------------------------------------------------------------------- */

.sqd-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.sqd-label {
  font-family: var(--font-sans, inherit);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
  line-height: 1;
}

.sqd-input {
  height: 2.25rem;                        /* h-9 */
  width: 100%;
  min-width: 0;
  padding: 0 0.75rem;                     /* px-3 */
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) * 0.8); /* rounded-md */
  background: #fff;
  font-family: var(--font-sans, inherit);
  font-size: 0.875rem;
  line-height: 1;
  color: var(--foreground);
  outline: none;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}
.dark .sqd-input {
  background: color-mix(in oklch, var(--input), transparent 70%);
}
.sqd-input::placeholder {
  color: var(--muted-foreground);
}
.sqd-input:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--ring);
}
.sqd-input:disabled {
  pointer-events: none;
  cursor: not-allowed;
  background: color-mix(in oklch, var(--muted), transparent 50%);
  opacity: 0.5;
}
.sqd-input[aria-invalid="true"] {
  border-color: #f87171;                  /* red-400 */
  background: color-mix(in oklch, #fef2f2, transparent 50%);
}
.sqd-input[aria-invalid="true"]:focus-visible {
  border-color: #ef4444;                  /* red-500 */
  box-shadow: 0 0 0 2px #ef4444;
}

/* ---------------------------------------------------------------------------
 * Card — mirror of card.tsx (rounded-md, ring-1 foreground/10, bg-card).
 * ------------------------------------------------------------------------- */

.sqd-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: calc(var(--radius) * 0.8);
  background: var(--card, var(--background));
  color: var(--card-foreground, var(--foreground));
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground), transparent 90%);
}
.sqd-card-header { padding: 1.5rem 1.5rem 0; }
.sqd-card-title {
  font-family: var(--font-sans, inherit);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--foreground);
}
.sqd-card-description {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.sqd-card-content { padding: 1.5rem; }
.sqd-card-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.5rem 1.5rem;
}

/* ---------------------------------------------------------------------------
 * Alert — mirror of alert.tsx (rounded-lg border, tinted per variant).
 * ------------------------------------------------------------------------- */

.sqd-alert {
  position: relative;
  display: grid;
  width: 100%;
  gap: 0.125rem 0.5rem;
  border: 1px solid;
  border-radius: calc(var(--radius) * 0.8);
  padding: 1.5rem;
  text-align: left;
  font-family: var(--font-sans, inherit);
  font-size: 0.875rem;
}
.sqd-alert:has(svg) { grid-template-columns: auto 1fr; }
.sqd-alert svg { width: 1rem; height: 1rem; grid-row: span 2; translate: 0 2px; color: currentColor; }
.sqd-alert-title { font-weight: 500; line-height: 1.4; }
.sqd-alert-description { font-size: 0.875rem; opacity: 0.9; }

.sqd-alert--default {
  border-color: var(--border, var(--input));
  background: color-mix(in oklch, var(--muted), transparent 50%);
  color: var(--foreground);
}
.sqd-alert--brand {
  border-color: color-mix(in oklch, var(--primary), transparent 70%);
  background: color-mix(in oklch, var(--primary), transparent 90%);
  color: var(--primary);
}
.sqd-alert--info {
  border-color: color-mix(in oklch, #0284c7, transparent 70%);
  background: color-mix(in oklch, #0284c7, transparent 90%);
  color: #0284c7;
}
.sqd-alert--success {
  border-color: color-mix(in oklch, #16a34a, transparent 70%);
  background: color-mix(in oklch, #16a34a, transparent 90%);
  color: #16a34a;
}
.sqd-alert--warning {
  border-color: color-mix(in oklch, #d97706, transparent 70%);
  background: color-mix(in oklch, #d97706, transparent 90%);
  color: #d97706;
}
.sqd-alert--destructive {
  border-color: color-mix(in oklch, var(--destructive), transparent 70%);
  background: color-mix(in oklch, var(--destructive), transparent 90%);
  color: var(--destructive);
}

/* ---------------------------------------------------------------------------
 * Dropdown menu — CSS-only via <details>/<summary>. mirror of dropdown-menu.tsx
 *
 *   <details class="sqd-menu">
 *     <summary class="sqd-btn sqd-btn--outline">Menu</summary>
 *     <div class="sqd-menu-content">
 *       <button class="sqd-menu-item">Edit</button>
 *       <button class="sqd-menu-item sqd-menu-item--destructive">Delete</button>
 *     </div>
 *   </details>
 * ------------------------------------------------------------------------- */

.sqd-menu { position: relative; display: inline-block; }
.sqd-menu > summary { list-style: none; cursor: pointer; }
.sqd-menu > summary::-webkit-details-marker { display: none; }
.sqd-menu-content {
  position: absolute;
  z-index: 50;
  margin-top: 0.375rem;
  min-width: 9rem;
  padding: 0.25rem;
  border-radius: calc(var(--radius) * 0.8);
  background: var(--popover, var(--background));
  color: var(--popover-foreground, var(--foreground));
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1),
    0 0 0 1px color-mix(in oklch, var(--foreground), transparent 90%);
}
.sqd-menu-item {
  display: flex;
  width: 100%;
  min-height: 2rem;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.5rem;
  border: 0;
  border-radius: calc(var(--radius) * 0.8);
  background: transparent;
  font-family: var(--font-sans, inherit);
  font-size: 0.875rem;
  color: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: default;
}
.sqd-menu-item:hover,
.sqd-menu-item:focus-visible {
  background: var(--accent);
  color: var(--accent-foreground);
  outline: none;
}
.sqd-menu-item--destructive { color: var(--destructive); }
.sqd-menu-item--destructive:hover {
  background: color-mix(in oklch, var(--destructive), transparent 90%);
  color: var(--destructive);
}

/* ---------------------------------------------------------------------------
 * Radio — native <input type="radio"> styled like radio-group.tsx dot.
 * ------------------------------------------------------------------------- */

.sqd-radio-item { display: flex; align-items: center; gap: 0.625rem; cursor: pointer; }
.sqd-radio {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  border: 1px solid var(--input);
  border-radius: 9999px;
  background: transparent;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.sqd-radio::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--primary-foreground);
  transform: scale(0);
  transition: transform 0.1s ease;
}
.sqd-radio:checked {
  border-color: var(--primary);
  background: var(--primary);
}
.sqd-radio:checked::before { transform: scale(1); }
.sqd-radio:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring), transparent 50%);
}
.sqd-radio-label { font-family: var(--font-sans, inherit); font-size: 0.875rem; color: var(--foreground); }

/* ---------------------------------------------------------------------------
 * Select — native <select> styled like SelectTrigger (h-9, rounded-md).
 * Combobox — native <input list=…> + <datalist> (HTML-only autocomplete).
 * Both reuse .sqd-input's box; select adds a chevron.
 * ------------------------------------------------------------------------- */

.sqd-select {
  appearance: none;
  -webkit-appearance: none;
  height: 2.25rem;
  width: 100%;
  min-width: 0;
  padding: 0 2.25rem 0 1rem;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) * 0.8);
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  font-family: var(--font-sans, inherit);
  font-size: 0.875rem;
  color: var(--foreground);
  outline: none;
  cursor: pointer;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}
.dark .sqd-select { background-color: color-mix(in oklch, var(--input), transparent 70%); }
.sqd-select:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--ring);
}
.sqd-select:disabled { cursor: not-allowed; opacity: 0.5; }

/* <select multiple> — the native multi-select, styled to match the surface. */
.sqd-multiselect {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  padding: 0.25rem;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) * 0.8);
  background: transparent;
  font-family: var(--font-sans, inherit);
  font-size: 0.875rem;
  color: var(--foreground);
  outline: none;
}
.dark .sqd-multiselect { background: color-mix(in oklch, var(--input), transparent 70%); }
.sqd-multiselect:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--ring);
}
.sqd-multiselect option {
  padding: 0.375rem 0.5rem;
  border-radius: calc(var(--radius) * 0.6);
}
.sqd-multiselect option:checked {
  background: color-mix(in oklch, var(--primary), transparent 85%) linear-gradient(0deg, transparent, transparent);
  color: var(--primary);
  font-weight: 500;
}

/* Combobox uses .sqd-input as-is; alias for docs clarity. */
.sqd-combobox { /* see .sqd-input */ }
