/* KAN-32 chat onboarding (templates/onboarding.html). Mobile first. */

:root {
  --chat-navy: #172433;
  --chat-blue: #1e41f9;
  --chat-blue-soft: #e8edff;
  --chat-sky: #9dc8e2;
  --chat-bg: #f4f6fa;
  --chat-bot: #ffffff;
  --chat-text: #1d2733;
  --chat-muted: #66727f;
  --chat-error: #c62828;
  --chat-warn-bg: #fff6e0;
  --chat-warn: #8a5a00;
  --chat-ok: #2e7d32;
}

body {
  background: var(--chat-bg);
  color: var(--chat-text);
}

.chat-app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 32px;
  font-family: GiraSans, sans-serif;
}

/* --- Progress --- */
.chat-progress {
  display: flex;
  gap: 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  counter-reset: none;
}
.chat-progress li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  background: #e3e7ee;
  color: var(--chat-muted);
  font-size: 12px;
  line-height: 1.2;
}
.chat-progress li span {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  font-weight: bold;
}
.chat-progress li.active {
  background: var(--chat-blue);
  color: #fff;
}
.chat-progress li.active span {
  color: var(--chat-blue);
}
.chat-progress li.done {
  background: var(--chat-sky);
  color: var(--chat-navy);
}
@media (max-width: 480px) {
  /* Only the current step keeps its label on small phones. */
  .chat-progress li:not(.active) {
    flex: none;
    font-size: 0;
  }
  .chat-progress li:not(.active) span {
    font-size: 12px;
  }
}

/* --- Messages --- */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.4;
  word-wrap: break-word;
  animation: chat-in 160ms ease-out;
}
.chat-msg.bot {
  align-self: flex-start;
  background: var(--chat-bot);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(23, 36, 51, 0.08);
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--chat-blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.user .chat-edit {
  display: block;
  margin-top: 4px;
  color: #dbe3ff;
  font-size: 12px;
  text-align: right;
  text-decoration: underline;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.chat-msg.user img {
  display: block;
  max-width: 180px;
  max-height: 120px;
  border-radius: 8px;
  margin-bottom: 4px;
}
.chat-msg.warn {
  background: var(--chat-warn-bg);
  color: var(--chat-warn);
}
.chat-msg.error {
  background: #fdecea;
  color: var(--chat-error);
}
.chat-msg.wide {
  max-width: 100%;
  width: 100%;
}
.chat-typing {
  display: inline-flex;
  gap: 4px;
}
.chat-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b5bfcc;
  animation: chat-dot 1s infinite ease-in-out;
}
.chat-typing i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes chat-dot {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-msg, .chat-typing i { animation: none; }
}

/* --- Input area --- */
.chat-input {
  margin-top: 16px;
}
.chat-input form,
.chat-card {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(23, 36, 51, 0.1);
}
.chat-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.chat-row > .chat-field {
  flex: 1;
  min-width: 0;
}
.chat-app input.chat-control,
.chat-app select.chat-control {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid #cdd4de;
  border-radius: 8px;
  background: #fff;
  font-size: 16px; /* keeps iOS from zooming in */
  box-sizing: border-box;
  box-shadow: none;
}
.chat-app input.chat-control:focus {
  border-color: var(--chat-blue);
  box-shadow: 0 0 0 2px var(--chat-blue-soft);
}
.chat-app input.chat-control.invalid {
  border-color: var(--chat-error);
}
.chat-hint {
  display: block;
  margin-top: 4px;
  color: var(--chat-muted);
  font-size: 12px;
}
.chat-error {
  display: block;
  margin-top: 4px;
  color: var(--chat-error);
  font-size: 13px;
}
.chat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 22px;
  background: var(--chat-blue);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.chat-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.chat-btn.secondary {
  background: #fff;
  color: var(--chat-blue);
  border: 1px solid var(--chat-blue);
}
.chat-btn .material-icons {
  font-size: 20px;
}
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chat-chips .chat-btn {
  background: #fff;
  color: var(--chat-blue);
  border: 1px solid var(--chat-blue);
}
.chat-chips .chat-btn:hover,
.chat-chips .chat-btn:focus {
  background: var(--chat-blue-soft);
}

/* --- Document capture --- */
.chat-capture {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chat-capture input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.chat-capture-guide {
  width: 100%;
  margin: 0 0 4px;
  color: var(--chat-muted);
  font-size: 13px;
}

/* --- Review card / summary --- */
.chat-card h6 {
  margin: 0 0 8px;
  font-weight: bold;
}
.chat-card .chat-field {
  margin-bottom: 10px;
}
.chat-card label {
  display: block;
  margin-bottom: 2px;
  color: var(--chat-muted);
  font-size: 13px;
}
.chat-card .chat-field.check label::after {
  content: " · revisa este dato";
  color: var(--chat-warn);
}
.chat-card .chat-field.check input.chat-control {
  border-color: #e0a800;
  background: var(--chat-warn-bg);
}
.chat-card .chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.chat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 12px;
}
@media (min-width: 600px) {
  .chat-grid { grid-template-columns: 1fr 1fr; }
  .chat-grid .full { grid-column: 1 / -1; }
}
.chat-summary dl {
  margin: 0;
}
.chat-summary dt {
  margin-top: 8px;
  color: var(--chat-muted);
  font-size: 12px;
}
.chat-summary dd {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  word-break: break-word;
}
.chat-summary dd button {
  flex: none;
  border: 0;
  background: none;
  color: var(--chat-blue);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.chat-summary h6 {
  margin-top: 16px;
}
.chat-summary h6:first-child {
  margin-top: 0;
}

.chat-terms .authorization {
  max-height: 260px;
  margin-top: 16px;
}
.chat-terms .authorization h5 {
  margin-top: 0;
  font-size: 1.25rem;
  font-weight: bold;
}
.chat-terms label {
  color: var(--chat-text);
}

.chat-turnstile:empty {
  display: none;
}
.chat-turnstile {
  margin-top: 12px;
}

.chat-fallback {
  margin-top: 24px;
  color: var(--chat-muted);
  font-size: 13px;
  text-align: center;
}

.chat-suggestions {
  margin-bottom: 8px;
}
.chat-suggestions .chat-btn {
  min-height: 36px;
  font-size: 14px;
}
.chat-app select.chat-control {
  padding-right: 8px;
}

/* Profession picker (search + up to 2 choices) */
.chat-profesiones .chat-selected:empty {
  display: none;
}
.chat-profesiones .chat-selected {
  margin-bottom: 8px;
}
.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 12px;
  border-radius: 16px;
  background: var(--chat-blue-soft);
  color: var(--chat-navy);
  font-size: 14px;
}
.chat-chip button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--chat-navy);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.chat-results {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
}
.chat-results li button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #eef1f5;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.chat-results li button:hover,
.chat-results li button:focus {
  background: var(--chat-blue-soft);
}
.chat-results small {
  color: var(--chat-muted);
}
.chat-results .chat-result-other strong {
  color: var(--chat-blue);
  font-weight: normal;
}
