/* Generic UI components: buttons, cards, forms, lists, tables, badges, banners, toasts. */

/* ---------------------------------------------------------------- Buttons */
.button {
  --button-bg: var(--white);
  --button-fg: var(--ink);
  --button-border: var(--line);
  --button-hover-bg: var(--sand);
  --button-shadow: none;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  padding: 0.55rem 1.25rem;
  border: 1px solid var(--button-border);
  border-radius: var(--radius-pill);
  background: var(--button-bg);
  color: var(--button-fg);
  box-shadow: var(--button-shadow);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.5;
  letter-spacing: 0.01em;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.button:hover {
  background: var(--button-hover-bg);
  color: var(--button-fg);
}

.button:focus-visible {
  outline: 0;
  box-shadow: var(--button-shadow), var(--focus-ring);
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.button--primary {
  --button-bg: var(--cranberry);
  --button-fg: var(--white);
  --button-border: var(--cranberry);
  --button-hover-bg: var(--cranberry-dark);
  --button-shadow: 0 0.35rem 1rem rgb(179 38 58 / 0.25);
}

.button--success {
  --button-bg: var(--pine);
  --button-fg: var(--white);
  --button-border: var(--pine);
  --button-hover-bg: var(--pine-dark);
  --button-shadow: 0 0.35rem 1rem rgb(31 92 70 / 0.25);
}

.button--primary:hover,
.button--success:hover {
  transform: translateY(-1px);
}

.button--outline {
  --button-bg: transparent;
  --button-fg: var(--cranberry);
  --button-border: var(--cranberry);
  --button-hover-bg: rgb(179 38 58 / 0.08);
}

.button--ghost {
  --button-bg: transparent;
  --button-fg: var(--muted);
  --button-border: var(--line);
  --button-hover-bg: var(--white);
}

.button--ghost:hover { --button-fg: var(--ink); }

.button--danger {
  --button-bg: transparent;
  --button-fg: var(--danger);
  --button-border: rgb(192 57 43 / 0.45);
  --button-hover-bg: rgb(192 57 43 / 0.08);
}

/* On dark backgrounds */
.button--light {
  --button-bg: var(--white);
  --button-fg: var(--ink);
  --button-border: var(--white);
  --button-hover-bg: var(--cream);
}

.button--on-dark {
  --button-bg: transparent;
  --button-fg: var(--white);
  --button-border: rgb(255 255 255 / 0.6);
  --button-hover-bg: rgb(255 255 255 / 0.12);
}

.button--link {
  --button-bg: transparent;
  --button-border: transparent;
  --button-hover-bg: transparent;
  --button-fg: var(--muted);
  font-weight: 600;
}

.button--link:hover { --button-fg: var(--cranberry); }

.button--sm { padding: 0.3rem 0.85rem; font-size: 0.875rem; }
.button--lg { padding: 0.75rem 1.75rem; font-size: 1.15rem; }
.button--block { display: flex; width: 100%; }

/* button_to wraps the button in a form */
form.button_to { display: inline-flex; margin: 0; }

.close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
}

.close-button:hover { background: var(--sand); color: var(--ink); }

/* ---------------------------------------------------------------- Cards */
.card {
  position: relative;
  margin-bottom: var(--space-4);
  border: 1px solid rgb(43 35 33 / 0.07);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.card--flat { border: 0; }
.card--raised { border: 0; box-shadow: var(--shadow); }
.card--lift { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.card--lift:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card--fill { height: 100%; margin-bottom: 0; }

.card__body { padding: var(--space-4); }
.card__body--roomy { padding: var(--space-4); }

@media (min-width: 768px) {
  .card__body--roomy { padding: var(--space-5); }
}

.card__header {
  padding: 1.1rem var(--space-4);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
}

.card__title {
  margin-bottom: var(--space-3);
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
}

.card > :last-child,
.card__body > :last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- Forms */
.field { display: flex; flex-direction: column; gap: 0.4rem; }

.label {
  font-size: 0.92rem;
  font-weight: 700;
}

.label__optional {
  font-weight: 400;
  color: var(--muted);
}

.input {
  display: block;
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder { color: #a99b93; }

.input:focus {
  outline: 0;
  border-color: #d97a88;
  box-shadow: var(--focus-ring);
}

textarea.input { min-height: 7rem; resize: vertical; }

select.input {
  appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%237a6a63' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  background-size: 14px 10px;
}

.hint {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
}

/* Icon inside a text field */
.input-icon { position: relative; }

.input-icon > .bi {
  position: absolute;
  top: 50%;
  left: 0.95rem;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.input-icon > .input { padding-left: 2.6rem; }

/* Radio */
.radio {
  appearance: none;
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.2rem 0 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.radio:checked {
  border-color: var(--cranberry);
  box-shadow: inset 0 0 0 3px var(--white);
  background: var(--cranberry);
}

.radio:focus-visible { outline: 0; box-shadow: inset 0 0 0 3px var(--white), var(--focus-ring); }

/* Toggle switch (checkbox) */
.switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-weight: 700;
}

.switch input {
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 2.6rem;
  height: 1.5rem;
  margin: 0;
  border-radius: var(--radius-pill);
  background: var(--line);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(1.5rem - 6px);
  height: calc(1.5rem - 6px);
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.2);
  transition: transform 0.2s ease;
}

.switch input:checked { background: var(--pine); }
.switch input:checked::after { transform: translateX(1.1rem); }
.switch input:focus-visible { outline: 0; box-shadow: var(--focus-ring); }

/* Large selectable option (radio stays a real input) */
.option-card {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  height: 100%;
  padding: 1.1rem 1.25rem;
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.option-card:hover { border-color: rgb(179 38 58 / 0.4); }

.option-card:has(:checked) {
  border-color: var(--cranberry);
  background: rgb(179 38 58 / 0.03);
  box-shadow: 0 0 0 4px rgb(179 38 58 / 0.1);
}

.option-card__title {
  display: block;
  font-weight: 800;
}

.form-panel {
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--sand);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--line);
}

.form-actions--end { justify-content: flex-end; }

/* ---------------------------------------------------------------- Lists & tables */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: 0.85rem 0;
  border-bottom: 1px solid rgb(43 35 33 / 0.06);
}

.list__item:last-child { border-bottom: 0; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  margin-bottom: var(--space-3);
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table th {
  border-bottom-width: 2px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.table tbody tr:hover { background: rgb(243 235 223 / 0.5); }

/* ---------------------------------------------------------------- Badges */
.badge {
  display: inline-block;
  padding: 0.3em 0.75em;
  border-radius: var(--radius-pill);
  background: var(--sand);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  vertical-align: middle;
}

.badge--success { background: var(--pine); color: var(--white); }

/* ---------------------------------------------------------------- Banners */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3) 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--sand);
}

.banner > .bi { font-size: 1.5rem; line-height: 1.2; }

.banner--success {
  background: rgb(31 92 70 / 0.1);
  color: var(--pine-dark);
}

/* ---------------------------------------------------------------- Toasts */
.toast-stack {
  position: fixed;
  top: 5rem;
  left: 50%;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(92vw, 380px);
  transform: translateX(-50%);
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-left: 5px solid var(--pine);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.toast > .bi { font-size: 1.25rem; color: var(--pine); }

.toast--danger { border-left-color: var(--danger); }
.toast--danger > .bi { color: var(--danger); }

.toast.is-leaving { animation: toast-out 0.25s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-12px); }
}

/* ---------------------------------------------------------------- Icon circle */
.icon-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: rgb(179 38 58 / 0.1);
  color: var(--cranberry);
  font-size: 1.35rem;
}

.icon-circle--pine { background: rgb(31 92 70 / 0.1); color: var(--pine); }
.icon-circle--gold { background: rgb(217 164 65 / 0.2); color: var(--gold-dark); }
.icon-circle--lg { width: 4rem; height: 4rem; font-size: 1.75rem; }

/* ---------------------------------------------------------------- Empty state */
.empty-state {
  padding: var(--space-4) 0;
  text-align: center;
  color: var(--muted);
}

.empty-state .icon-circle { margin-bottom: var(--space-2); }
