/* ==========================================================================
   Widgets — chat assistant, purchase wizard, form controls.
   These were part of the old theme.css; the class names are unchanged so
   chat.js and purchase.js keep working, but they now use the glass tokens
   from theme.css and follow the light/dark theme automatically.
   ========================================================================== */

/* --- Form controls ----------------------------------------------------------- */

.form-label {
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.form-control,
.form-select {
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background-color: var(--glass-strong);
  color: var(--ink);
}
.form-control::placeholder {
  color: var(--ink-subtle);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  background-color: var(--glass-strong);
  color: var(--ink);
  box-shadow: 0 0 0 4px var(--primary-line);
}

.form-text {
  font-size: 0.8rem;
  color: var(--ink-subtle);
}

.form-feedback {
  display: block;
  min-height: 1.2em;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}
.form-feedback.is-success {
  color: #15803d;
}
.form-feedback.is-error {
  color: #b91c1c;
}
:root[data-theme="dark"] .form-feedback.is-success {
  color: #6ee7b7;
}
:root[data-theme="dark"] .form-feedback.is-error {
  color: #fca5a5;
}

/* --- Chat assistant ----------------------------------------------------------- */

.chat-panel {
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: calc(max(1.25rem, env(safe-area-inset-bottom)) + 8.5rem);
  z-index: 1045;
  display: none;
  flex-direction: column;
  width: min(23rem, calc(100% - 2rem));
  max-height: min(31rem, calc(100vh - 12rem));
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
  backdrop-filter: blur(var(--blur)) saturate(170%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-hi), var(--shadow-2), 0 0 0 1px var(--glass-edge);
}
.chat-panel.is-open {
  display: flex;
  animation: chat-in 0.25s var(--ease-out);
}
@keyframes chat-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem) scale(0.98);
  }
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--cta-bg);
  color: #ffffff;
}
.chat-header .chat-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}
.chat-header .chat-status {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.82);
}
.chat-close {
  margin-left: auto;
  padding: 0.25rem;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: #ffffff;
  line-height: 0;
  cursor: pointer;
}
.chat-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.chat-log {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-msg {
  max-width: 85%;
  padding: 0.7rem 1rem;
  border-radius: var(--r);
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.chat-msg-bot {
  align-self: flex-start;
  background: var(--glass);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  color: var(--ink);
}
.chat-msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--on-primary);
  border-bottom-right-radius: 6px;
}
.chat-msg-error {
  align-self: flex-start;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-bottom-left-radius: 6px;
  color: #b91c1c;
}
:root[data-theme="dark"] .chat-msg-error {
  color: #fca5a5;
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.chat-typing span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--ink-subtle);
  animation: typing 1.2s var(--ease) infinite;
}
.chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-0.2rem);
  }
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--line);
}
.chat-form .form-control {
  border-radius: 999px;
  font-size: 0.92rem;
}
.chat-send {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  cursor: pointer;
  transition: background-color 0.25s var(--ease), transform 0.2s var(--ease-out);
}
.chat-send:hover:not(:disabled) {
  background: var(--primary-strong);
  transform: scale(1.05);
}
.chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.chat-disclaimer {
  margin: 0;
  padding: 0 0.75rem 0.75rem;
  font-size: 0.72rem;
  text-align: center;
  color: var(--ink-subtle);
}

@media (max-width: 575.98px) {
  .chat-panel {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    bottom: calc(max(1.25rem, env(safe-area-inset-bottom)) + 7.75rem);
  }
}

/* --- Purchase wizard ------------------------------------------------------------ */

.wizard-modal .modal-content {
  --bs-modal-bg: var(--glass-strong);
  --bs-modal-color: var(--ink);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
  backdrop-filter: blur(var(--blur)) saturate(170%);
  box-shadow: var(--glass-hi), var(--shadow-2);
}
.wizard-modal .modal-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--line);
}
.wizard-modal .modal-body {
  padding: 1.5rem;
}
.wizard-modal .modal-footer {
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
}

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
}
.wizard-steps li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--ink-subtle);
}
.wizard-steps li::before {
  content: attr(data-step);
  display: inline-grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--hover);
  color: var(--ink-subtle);
  font-weight: 700;
}
.wizard-steps li:not(:last-child)::after {
  content: "";
  width: clamp(1rem, 5vw, 2.5rem);
  height: 2px;
  border-radius: 2px;
  background: var(--line-strong);
}
.wizard-steps li.is-active {
  color: var(--primary);
}
.wizard-steps li.is-active::before {
  background: var(--primary);
  color: var(--on-primary);
}
.wizard-steps li.is-done::before {
  content: "\2713";
  background: var(--primary-soft);
  color: var(--primary);
}
.wizard-step[hidden] {
  display: none;
}

/* Selectable option tiles (package choice, self vs other). */
.option-tile {
  display: block;
  height: 100%;
  cursor: pointer;
}
.option-tile input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}
.option-tile .option-body {
  height: 100%;
  padding: 1rem;
  border: 2px solid var(--line);
  border-radius: var(--r);
  background: var(--glass);
  transition: border-color 0.25s var(--ease), background-color 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}
.option-tile:hover .option-body {
  border-color: var(--line-strong);
  background: var(--glass-strong);
}
.option-tile input:checked + .option-body {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 4px var(--primary-line);
}
/* The input is visually hidden, so mirror its focus ring onto the tile. */
.option-tile input:focus-visible + .option-body {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.option-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
  font-weight: 700;
  color: var(--ink);
}
.option-title .option-price {
  color: var(--primary);
  white-space: nowrap;
}
.option-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}
.option-pill {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
}

.summary-list {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--glass);
}
.summary-list > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.5rem;
}
.summary-list > div + div {
  border-top: 1px dashed var(--line-strong);
}
.summary-list dt {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-subtle);
}
.summary-list dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.summary-list .summary-total dd {
  font-size: 1.15rem;
  color: var(--primary);
}
