/* =============================================================================
   CHAT WIDGET STYLES
   =============================================================================
   TO RESKIN FOR A CLIENT: change the variables in the :root block below.
   Everything else derives from them. Nothing further down needs editing.
   Every class is prefixed .rct- so this can drop onto a client site without
   colliding with their existing CSS.
   ========================================================================== */

:root {
  /* --- Brand colors (change these) -------------------------------------- */
  --rct-brand:            #1f4d3d;   /* header, launcher, user bubbles       */
  --rct-brand-hover:      #17392d;   /* darker shade for hover states        */
  --rct-brand-contrast:   #ffffff;   /* text sitting on top of brand color   */
  --rct-accent:           #c2703d;   /* prices, highlights, cart badge       */

  /* --- Neutrals (usually leave alone) ----------------------------------- */
  --rct-bg:               #ffffff;
  --rct-bg-muted:         #f5f4f2;
  --rct-border:           #e2e0dc;
  --rct-text:             #23211e;
  --rct-text-muted:       #6f6a63;

  /* --- Shape & type ------------------------------------------------------ */
  --rct-radius:           14px;
  --rct-radius-sm:        10px;
  --rct-font:             -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                          "Helvetica Neue", Arial, sans-serif;
  --rct-shadow:           0 12px 40px rgba(20, 18, 15, 0.18);

  /* --- Layout ------------------------------------------------------------ */
  --rct-width:            390px;
  --rct-height:           620px;
  --rct-z:                2147483000;  /* sit above almost anything on a page */
}

/* --- Launcher bubble ------------------------------------------------------ */
.rct-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--rct-z);
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: var(--rct-brand);
  color: var(--rct-brand-contrast);
  box-shadow: var(--rct-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, background 0.18s ease;
}
.rct-launcher:hover { background: var(--rct-brand-hover); transform: scale(1.05); }
.rct-launcher:focus-visible { outline: 3px solid var(--rct-accent); outline-offset: 3px; }
.rct-launcher svg { width: 26px; height: 26px; fill: currentColor; }
.rct-launcher.rct-is-hidden { display: none; }

/* Small dot on the launcher when the order has items and chat is closed. */
.rct-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--rct-accent);
  color: #fff;
  font: 600 12px/22px var(--rct-font);
  box-shadow: 0 0 0 2px var(--rct-bg);
}

/* --- Panel ---------------------------------------------------------------- */
.rct-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--rct-z);
  width: var(--rct-width);
  height: var(--rct-height);
  max-height: calc(100vh - 48px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--rct-bg);
  border-radius: var(--rct-radius);
  box-shadow: var(--rct-shadow);
  font-family: var(--rct-font);
  color: var(--rct-text);
  font-size: 15px;
  line-height: 1.5;
}
.rct-panel.rct-is-open { display: flex; animation: rct-rise 0.2s ease-out; }

@keyframes rct-rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes rct-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --- Header --------------------------------------------------------------- */
.rct-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--rct-brand);
  color: var(--rct-brand-contrast);
  flex-shrink: 0;
}
.rct-logo {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  overflow: hidden;
}
.rct-logo img { width: 100%; height: 100%; object-fit: cover; }
.rct-title { flex: 1; min-width: 0; }
.rct-title strong { display: block; font-size: 15px; font-weight: 600; }
.rct-title span {
  display: block;
  font-size: 12px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rct-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  opacity: 0.85;
  line-height: 0;
}
.rct-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.14); }
.rct-close svg { width: 18px; height: 18px; fill: currentColor; }

/* --- Message list --------------------------------------------------------- */
.rct-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--rct-bg-muted);
}
.rct-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: var(--rct-radius-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.rct-msg-bot {
  align-self: flex-start;
  background: var(--rct-bg);
  border: 1px solid var(--rct-border);
  border-bottom-left-radius: 3px;
}
.rct-msg-user {
  align-self: flex-end;
  background: var(--rct-brand);
  color: var(--rct-brand-contrast);
  border-bottom-right-radius: 3px;
}
.rct-msg-error {
  align-self: stretch;
  max-width: 100%;
  background: #fdf2ef;
  border: 1px solid #eccfc4;
  color: #8a3f1d;
  font-size: 14px;
}

/* --- Typing indicator ----------------------------------------------------- */
.rct-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 13px;
  background: var(--rct-bg);
  border: 1px solid var(--rct-border);
  border-radius: var(--rct-radius-sm);
  border-bottom-left-radius: 3px;
}
.rct-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rct-text-muted);
  animation: rct-bounce 1.3s infinite ease-in-out;
}
.rct-typing i:nth-child(2) { animation-delay: 0.16s; }
.rct-typing i:nth-child(3) { animation-delay: 0.32s; }

@keyframes rct-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-4px); }
}

/* --- Confirmation cards (reservation / order) ----------------------------- */
.rct-card {
  align-self: stretch;
  background: var(--rct-bg);
  border: 1px solid var(--rct-border);
  border-left: 4px solid var(--rct-accent);
  border-radius: var(--rct-radius-sm);
  padding: 14px;
  font-size: 14px;
}
.rct-card h4 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rct-text-muted);
}
.rct-card-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}
.rct-card-row dt { color: var(--rct-text-muted); }
.rct-card-row dd { margin: 0; text-align: right; font-weight: 500; }
.rct-card-total {
  border-top: 1px solid var(--rct-border);
  margin-top: 8px;
  padding-top: 8px;
  font-weight: 700;
}
.rct-card-total dd { color: var(--rct-accent); }
.rct-card-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--rct-text-muted);
  line-height: 1.45;
}

/* --- Quick replies -------------------------------------------------------- */
.rct-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  background: var(--rct-bg-muted);
}
.rct-quick:empty { display: none; }
.rct-quick button {
  border: 1px solid var(--rct-brand);
  background: var(--rct-bg);
  color: var(--rct-brand);
  border-radius: 999px;
  padding: 7px 14px;
  font: 500 13px var(--rct-font);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.rct-quick button:hover { background: var(--rct-brand); color: var(--rct-brand-contrast); }

/* --- Order drawer --------------------------------------------------------- */
.rct-order {
  border-top: 1px solid var(--rct-border);
  background: var(--rct-bg);
  flex-shrink: 0;
  display: none;
}
.rct-order.rct-is-visible { display: block; }
.rct-order-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  background: none;
  border: none;
  font: 600 14px var(--rct-font);
  color: var(--rct-text);
  cursor: pointer;
  text-align: left;
}
.rct-order-toggle:hover { background: var(--rct-bg-muted); }
.rct-order-count {
  background: var(--rct-accent);
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
}
.rct-order-sum { margin-left: auto; color: var(--rct-accent); font-weight: 700; }
.rct-order-caret { transition: transform 0.2s ease; font-size: 11px; color: var(--rct-text-muted); }
.rct-order.rct-is-expanded .rct-order-caret { transform: rotate(180deg); }

.rct-order-body { display: none; padding: 0 16px 14px; }
.rct-order.rct-is-expanded .rct-order-body { display: block; }
.rct-order-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rct-border);
  font-size: 14px;
}
.rct-order-line:last-of-type { border-bottom: none; }
.rct-order-line-name { flex: 1; }
.rct-order-line-mods {
  display: block;
  font-size: 12px;
  color: var(--rct-text-muted);
  font-style: italic;
}
.rct-order-line-price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rct-order-totals {
  border-top: 1px solid var(--rct-border);
  margin-top: 6px;
  padding-top: 8px;
  font-size: 14px;
}
.rct-order-totals .rct-card-row { padding: 2px 0; }

/* --- Composer ------------------------------------------------------------- */
.rct-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--rct-border);
  background: var(--rct-bg);
  flex-shrink: 0;
}
.rct-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--rct-border);
  border-radius: var(--rct-radius-sm);
  padding: 10px 12px;
  font: 15px/1.4 var(--rct-font);
  color: var(--rct-text);
  max-height: 110px;
  background: var(--rct-bg);
}
.rct-composer textarea:focus {
  outline: none;
  border-color: var(--rct-brand);
  box-shadow: 0 0 0 3px rgba(31, 77, 61, 0.12);
}
.rct-send {
  border: none;
  background: var(--rct-brand);
  color: var(--rct-brand-contrast);
  width: 42px;
  height: 42px;
  border-radius: var(--rct-radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.rct-send:hover:not(:disabled) { background: var(--rct-brand-hover); }
.rct-send:disabled { opacity: 0.4; cursor: not-allowed; }
.rct-send svg { width: 19px; height: 19px; fill: currentColor; }

.rct-footnote {
  padding: 0 12px 10px;
  margin: 0;
  font-size: 11px;
  color: var(--rct-text-muted);
  text-align: center;
  background: var(--rct-bg);
  flex-shrink: 0;
}

/* --- Mobile --------------------------------------------------------------- */
@media (max-width: 560px) {
  .rct-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;        /* accounts for mobile browser chrome; ignored if unsupported */
    max-height: 100dvh;
    border-radius: 0;
  }
  /* Fade rather than slide: a translate on a full-bleed panel can push the
     composer below the fold if the animation is interrupted. */
  .rct-panel.rct-is-open { animation: rct-fade 0.18s ease-out; }
  .rct-launcher { right: 16px; bottom: 16px; }
  .rct-msg { max-width: 88%; }
}

/* Respect users who ask for reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .rct-panel.rct-is-open { animation: none; }
  .rct-typing i { animation: none; opacity: 0.5; }
  .rct-launcher { transition: none; }
}
