/* Grade A Rescue — website chat widget.
   Brand contract (DESIGN.md): #003399 primary, #071E4C navy, #F3F6FC pale,
   #EAF0FC wash, #59677E secondary, #CFD9EB rules. Inter for UI. No pills,
   no gradients, no heavy shadows. */

:root {
  --gwc-blue: #003399;
  --gwc-navy: #071E4C;
  --gwc-pale: #F3F6FC;
  --gwc-wash: #EAF0FC;
  --gwc-secondary: #59677E;
  --gwc-rule: #CFD9EB;
  --gwc-white: #FFFFFF;
  --gwc-error: #B3261E;
}

/* ── Launcher ── */
.gwc-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9990;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  background: var(--gwc-blue);
  color: var(--gwc-white);
  border: 1px solid var(--gwc-blue);
  border-radius: 6px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(7, 30, 76, 0.18);
}
.gwc-launcher:hover { background: #002a80; }
.gwc-launcher:focus-visible { outline: 3px solid var(--gwc-navy); outline-offset: 2px; }
.gwc-launcher .gwc-unread {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--gwc-white);
  color: var(--gwc-blue);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  font-weight: 700;
}
.gwc-hidden { display: none !important; }

/* ── Panel ── */
.gwc-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9991;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: min(78dvh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--gwc-white);
  border: 1px solid var(--gwc-rule);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(7, 30, 76, 0.16);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.gwc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--gwc-navy);
  color: var(--gwc-white);
  flex: 0 0 auto;
}
.gwc-header img { width: 34px; height: 34px; object-fit: contain; background: var(--gwc-white); border-radius: 4px; padding: 2px; }
.gwc-title { flex: 1 1 auto; min-width: 0; }
.gwc-title .gwc-name { font-size: 14px; font-weight: 700; letter-spacing: 0.06em; }
.gwc-title .gwc-sub { font-size: 12px; color: #B9C6E4; }
.gwc-hbtn {
  background: none;
  border: none;
  color: var(--gwc-white);
  width: 34px;
  height: 34px;
  border-radius: 4px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.gwc-hbtn:hover { background: rgba(255, 255, 255, 0.12); }
.gwc-hbtn:focus-visible { outline: 2px solid var(--gwc-white); outline-offset: 1px; }

/* ── Messages ── */
.gwc-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: var(--gwc-pale);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gwc-msg { max-width: 85%; display: flex; flex-direction: column; gap: 3px; }
.gwc-msg .gwc-bubble {
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.gwc-msg .gwc-meta { font-size: 11px; color: var(--gwc-secondary); padding: 0 2px; }
.gwc-msg-visitor { align-self: flex-end; align-items: flex-end; }
.gwc-msg-visitor .gwc-bubble { background: var(--gwc-blue); color: var(--gwc-white); border-bottom-right-radius: 3px; }
.gwc-msg-assistant, .gwc-msg-agent, .gwc-msg-system { align-self: flex-start; align-items: flex-start; }
.gwc-msg-assistant .gwc-bubble, .gwc-msg-agent .gwc-bubble {
  background: var(--gwc-white);
  border: 1px solid var(--gwc-rule);
  color: var(--gwc-navy);
  border-bottom-left-radius: 3px;
}
.gwc-msg-system .gwc-bubble { background: var(--gwc-wash); color: var(--gwc-secondary); font-size: 13px; }
.gwc-msg-error .gwc-bubble { border-color: var(--gwc-error); }
.gwc-msg .gwc-bubble a { color: inherit; text-decoration: underline; }
.gwc-retry {
  background: none;
  border: none;
  color: var(--gwc-error);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0 2px;
  text-align: right;
}

/* ── Shortcuts ── */
.gwc-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 4px; }
.gwc-shortcut {
  background: var(--gwc-white);
  border: 1px solid var(--gwc-blue);
  color: var(--gwc-blue);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.gwc-shortcut:hover { background: var(--gwc-wash); }
.gwc-shortcut:focus-visible { outline: 2px solid var(--gwc-navy); outline-offset: 1px; }

/* ── Status line ── */
.gwc-status {
  flex: 0 0 auto;
  padding: 4px 16px;
  font-size: 12px;
  color: var(--gwc-secondary);
  background: var(--gwc-pale);
  min-height: 20px;
}
.gwc-status[data-kind="error"] { color: var(--gwc-error); }

/* ── Composer ── */
.gwc-composer {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--gwc-rule);
  background: var(--gwc-white);
}
.gwc-input {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--gwc-rule);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.4;
  color: var(--gwc-navy);
  max-height: 110px;
}
.gwc-input:focus-visible { outline: 2px solid var(--gwc-blue); outline-offset: 0; border-color: var(--gwc-blue); }
.gwc-send {
  flex: 0 0 auto;
  align-self: flex-end;
  background: var(--gwc-blue);
  color: var(--gwc-white);
  border: 1px solid var(--gwc-blue);
  border-radius: 6px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.gwc-send:disabled { opacity: 0.55; cursor: default; }
.gwc-send:focus-visible { outline: 2px solid var(--gwc-navy); outline-offset: 1px; }

/* ── Alternatives footer ── */
.gwc-alts {
  flex: 0 0 auto;
  display: flex;
  gap: 14px;
  justify-content: center;
  padding: 8px 12px 12px;
  background: var(--gwc-white);
  font-size: 12px;
}
.gwc-alts a { color: var(--gwc-secondary); text-decoration: underline; }
.gwc-alts a:hover { color: var(--gwc-blue); }

/* ── Mobile ── */
@media (max-width: 640px) {
  .gwc-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .gwc-launcher { right: 14px; bottom: 14px; }
}

/* ── Reduced motion: nothing animates anyway; guard future additions ── */
@media (prefers-reduced-motion: reduce) {
  .gwc-panel, .gwc-launcher, .gwc-msg { transition: none !important; animation: none !important; }
}
