/* The order chatbot's view. Uses the tokens and fonts defined in order/index.html. */

/* Cover link, shown next to "Make order request" */
.cover-chat-link {
  display: block; margin: 22px auto 0;
  font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 400;
  color: rgba(250,247,242,0.72); text-decoration: underline; text-underline-offset: 4px;
  text-decoration-color: rgba(196,150,58,0.6); padding: 10px 14px; min-height: 44px;
  transition: color 200ms;
}
.cover-chat-link:hover { color: #FAF7F2; }

/* Fullscreen by default, which is what a phone gets: as tall as the visible part
   of the screen, which is less than the layout viewport once the keyboard is up.
   From 900px up it is a panel bottom right unless the customer has made it full. */
#view-chat {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--chat-vh, 100dvh);
  display: flex; flex-direction: column; background: var(--ivory); z-index: 70;
}
#view-chat[hidden] { display: none; }

.chat-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(28,23,20,0.5); }
.chat-backdrop[hidden] { display: none; }
html.chat-open { overflow: hidden; }

@media (min-width: 900px) {
  #view-chat:not(.chat-full) {
    top: auto; left: auto; right: 24px; bottom: 24px;
    width: 400px; height: min(680px, calc(var(--chat-vh, 100dvh) - 48px));
    border-radius: 10px; overflow: hidden; box-shadow: 0 18px 60px rgba(28,23,20,0.35);
  }
  #view-chat:not(.chat-full) .chat-header { padding: 8px 8px 8px 18px; }
  #view-chat:not(.chat-full) .chat-scroll { padding: 18px 16px; }
  #view-chat:not(.chat-full) .chat-composer { padding-left: 16px; padding-right: 16px; }
  #view-chat:not(.chat-full) .chat-switch-long { display: none; }
  #view-chat:not(.chat-full) .chat-switch-short { display: inline; }
}
/* Under 900px it is always fullscreen, so there is nothing to toggle. */
@media (max-width: 899px) { .chat-icon-btn.chat-size-btn { display: none; } }
#view-chat.chat-full .chat-icon-expand,
#view-chat:not(.chat-full) .chat-icon-shrink { display: none; }

.chat-header {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid #EAE2D6; background: rgba(250,247,242,0.96);
}
.chat-brand { font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; font-size: 21px; color: #1C1714; white-space: nowrap; }
.chat-header-actions { display: flex; align-items: center; gap: 4px; }
.chat-switch {
  font-family: 'DM Sans', sans-serif; font-size: 11px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
  color: #5C4F47; border: 1px solid var(--border); border-radius: 2px; padding: 0 16px; min-height: 44px; background: transparent;
  margin-right: 6px; white-space: nowrap; transition: border-color 200ms, color 200ms;
}
.chat-switch:hover { border-color: #1C1714; color: #1C1714; }
.chat-switch-short { display: none; }
.chat-icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  color: #5C4F47; border-radius: 2px; background: transparent; transition: color 200ms, background 200ms;
}
.chat-icon-btn:hover { color: #1C1714; background: #F3EEE4; }
.chat-switch:focus-visible, .chat-icon-btn:focus-visible, .chat-launcher:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.chat-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px 20px; }
.chat-thread { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }

.chat-row { display: flex; }
.chat-row-user { justify-content: flex-end; }
.chat-bubble {
  max-width: 85%; padding: 12px 16px; border-radius: 14px; font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.chat-bubble-assistant { background: #FFFFFF; border: 1px solid #E6DDD0; color: #1C1714; border-bottom-left-radius: 4px; }
.chat-bubble-user { background: #FAF0DC; border: 1px solid #E7D2A6; color: #3B2E08; border-bottom-right-radius: 4px; }

/* Tap-to-answer buttons: in the customer's colours, since a tap becomes their message. */
.chat-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-choice {
  font-family: 'DM Sans', sans-serif; font-size: 14px; line-height: 1.3; color: #3B2E08;
  background: #FFFFFF; border: 1px solid #E7D2A6; border-radius: 999px; padding: 8px 16px; min-height: 44px;
  transition: background 200ms, border-color 200ms;
}
.chat-choice:hover:not(:disabled) { background: #FAF0DC; border-color: var(--gold); }
.chat-choice[aria-pressed="true"] { background: #FAF0DC; border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.chat-choice:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-choice:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.chat-colours { display: flex; flex-direction: column; gap: 6px; }
.chat-choice-done { background: var(--gold); border-color: var(--gold); color: #1C1714; font-weight: 500; }
.chat-choice-done:hover:not(:disabled) { background: #A07824; border-color: #A07824; }
.chat-choice-done:disabled { background: #D4CEC9; border-color: #D4CEC9; color: #6F645C; opacity: 1; }

.chat-typing { display: inline-flex; gap: 5px; align-items: center; padding: 16px 18px; }
.chat-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: chat-dot 1.2s infinite ease-in-out; }
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .chat-typing span { animation: none; opacity: 0.6; } }

.chat-card { background: #FFFFFF; border: 1px solid #E6DDD0; border-radius: 6px; padding: 20px; box-shadow: 0 2px 16px rgba(28,23,20,0.05); }
.chat-card p { font-size: 14px; line-height: 1.65; color: #5C4F47; }
.chat-card-error { background: #FBF1E3; border-color: #E7D2A6; }
.chat-card-error p { color: #7C5C0E; }
.chat-card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.chat-btn {
  display: inline-flex; align-items: center; justify-content: center; font-family: 'DM Sans', sans-serif;
  font-size: 11px; font-weight: 500; letter-spacing: 0.13em; text-transform: uppercase; border-radius: 2px;
  padding: 0 22px; min-height: 44px; cursor: pointer; text-decoration: none;
}
.chat-btn-primary { background: var(--gold); color: #1C1714; border: none; transition: background 200ms; }
.chat-btn-primary:hover:not(:disabled) { background: #A07824; }
.chat-btn-primary:disabled { background: #D4CEC9; color: #6F645C; cursor: not-allowed; }
.chat-btn-ghost { background: transparent; color: #5C4F47; border: 1px solid var(--border); }
.chat-btn-ghost:hover { border-color: #1C1714; color: #1C1714; }

.chat-composer {
  flex: 0 0 auto; display: flex; align-items: flex-end; gap: 10px; max-width: 720px; width: 100%; margin: 0 auto;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid #EAE2D6; background: rgba(250,247,242,0.96);
}
.chat-composer textarea {
  flex: 1; min-width: 0; resize: none; font-family: 'DM Sans', sans-serif; font-size: 16px; line-height: 1.5;
  color: #1C1714; background: #FFFFFF; border: 1px solid var(--border); border-radius: 2px; padding: 11px 14px;
  outline: none; max-height: 140px; transition: border-color 150ms;
}
.chat-composer textarea:focus { border-color: var(--gold); }
.chat-send {
  flex: 0 0 auto; font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500; letter-spacing: 0.13em; text-transform: uppercase;
  background: var(--gold); color: #1C1714; border-radius: 2px; padding: 0 22px; min-height: 46px; transition: background 200ms;
}
.chat-send:hover:not(:disabled) { background: #A07824; }
.chat-send:disabled { background: #D4CEC9; color: #6F645C; cursor: not-allowed; }

@media (max-width: 500px) {
  .chat-header { padding: 10px 14px; }
  .chat-scroll { padding: 16px 14px; }
  .chat-composer { padding-left: 14px; padding-right: 14px; }
  .chat-bubble { max-width: 90%; }
  .chat-brand { font-size: 19px; }
  .chat-switch { padding: 0 12px; margin-right: 2px; }
  .chat-switch-long { display: none; }
  .chat-switch-short { display: inline; }
}

/* Summary card */
.chat-summary-label { font-size: 10px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }
.chat-summary-row { display: flex; justify-content: space-between; gap: 18px; padding: 10px 0; border-bottom: 1px solid #F1EBE0; }
.chat-summary-key { flex: 0 0 auto; max-width: 42%; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: #6F645C; padding-top: 2px; }
.chat-summary-val { font-size: 14px; color: #1C1714; text-align: right; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-consult { margin-top: 18px; padding: 14px 16px; background: #F3EEE4; border: 1px solid #E6DDD0; border-radius: 4px; }
.chat-consult .chat-btn { margin-top: 12px; }
.chat-consult-check { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 14px; color: #1C1714; cursor: pointer; min-height: 44px; }
.chat-consult-check input { width: 20px; height: 20px; accent-color: var(--gold); cursor: pointer; }
.chat-needed { margin-top: 18px; font-size: 13px; color: #7C5C0E; background: #FBF1E3; border: 1px solid #E7D2A6; border-radius: 4px; padding: 12px 16px; }
.chat-needed ul { margin: 6px 0 0 18px; }
.chat-needed li { line-height: 1.6; }
.chat-summary-note { margin-top: 16px; font-size: 12px !important; color: #6F645C !important; }
.chat-submit-error { margin-top: 12px; font-size: 13px; color: #8A3B12; }
.chat-summary-send { width: 100%; margin-top: 16px; min-height: 52px; }

/* Handoff */
.chat-handoff { background: #F3EEE4; }

/* Photos */
.chat-attach {
  flex: 0 0 auto; width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center;
  color: #5C4F47; border: 1px solid var(--border); border-radius: 2px; background: #FFFFFF; transition: border-color 200ms, color 200ms;
}
.chat-attach:hover { border-color: var(--gold); color: #1C1714; }
.chat-photos { flex: 0 0 auto; max-width: 720px; width: 100%; margin: 0 auto; padding: 10px 20px 0; background: rgba(250,247,242,0.96); border-top: 1px solid #EAE2D6; display: flex; flex-direction: column; gap: 10px; max-height: 40vh; overflow-y: auto; }
.chat-photos[hidden] { display: none; }
.chat-photo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.chat-photo-label { font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: #5C4F47; }
.chat-photo-add { font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold-dk); border: 1px solid var(--border); border-radius: 2px; padding: 0 16px; min-height: 44px; background: #FFFFFF; }
.chat-photo-add:hover:not(:disabled) { border-color: var(--gold); }
.chat-photo-add:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-photo-note { font-size: 12px; color: #6F645C; line-height: 1.5; margin-top: 6px; }
.chat-photos .upload-item { width: 64px; height: 64px; }
.chat-photos .upload-item-remove { width: 24px; height: 24px; font-size: 15px; }
@media (max-width: 500px) { .chat-photos { padding-left: 14px; padding-right: 14px; } }

.chat-notice { font-size: 12px; line-height: 1.6; color: #6F645C; text-align: center; padding: 0 8px; }
.chat-notice a { text-decoration: underline; text-underline-offset: 3px; color: #5C4F47; }

/* Launcher, bottom right on the cover and the form. A dot shows while a chat is under way. */
.chat-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 45;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 22px; border-radius: 26px;
  background: var(--gold); color: #1C1714; border: none; box-shadow: 0 6px 24px rgba(28,23,20,0.22);
  font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; transition: background 200ms, transform 200ms;
}
.chat-launcher:hover { background: #A07824; transform: translateY(-1px); }
.chat-launcher[hidden] { display: none; }
.chat-launcher-dot { display: none; position: absolute; top: -3px; right: -3px; width: 14px; height: 14px; border-radius: 50%; background: #1C1714; border: 2px solid var(--ivory); }
.chat-launcher-active .chat-launcher-dot { display: block; }
/* Clear of the form's sticky Continue bar. */
.chat-launcher-above-bar { bottom: 104px; }
@media (max-width: 500px) {
  .chat-launcher { right: 14px; width: 52px; padding: 0; justify-content: center; }
  .chat-launcher span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { .chat-launcher { transition: none; } }
