/* ORCA Agent Chat Widget */
/* RTL Hebrew support */
/* UB-858 #26: re-skinned to the v2 brand tokens. The prior --orca-teal (#4a9a9a) was the
   off-brand hue orca-web flags for sweep; the accent is now the exact v2 gold (#d4af55 /
   rgba(212,175,85,...)). Per v2 convention, gold-background elements carry NAVY text
   (gold + navy), never white-on-gold (which fails contrast). Header stays navy + white. */

.orca-widget-container {
  --orca-navy: #0a192f;
  --orca-gold: #d4af55;
  --orca-cream: #faf9f7;
  --orca-error: #ef4444;
  --orca-success: #10b981;

  position: fixed;
  /* UB-4264: lifted clear of the cookie notice (cookie-consent.js publishes its
     height as --cookie-notice-h on <html>; absent when no notice is showing).
     The launcher's z-index is above the notice's, so without the lift it sat on
     the notice's controls. */
  bottom: calc(20px + var(--cookie-notice-h, 0px));
  left: 20px;
  z-index: 10000;
  font-family: 'Heebo', 'Segoe UI', Tahoma, sans-serif;
  direction: rtl;
}

/* Floating Button */
.orca-widget-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--orca-gold);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

/* UB-4874: the wizard marks the page locked until the lawyer attestation is ticked */
.orca-assistant-locked .orca-widget-button {
  display: none !important;
}

.orca-widget-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.orca-widget-button svg {
  width: 28px;
  height: 28px;
  fill: var(--orca-navy);
}

/* Chat Modal */
.orca-chat-modal {
  display: none;
  position: fixed;
  bottom: calc(90px + var(--cookie-notice-h, 0px));
  left: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 120px - var(--cookie-notice-h, 0px));
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  flex-direction: column;
  overflow: hidden;
}

.orca-chat-modal.open {
  display: flex;
}

/* Header */
.orca-chat-header {
  background: var(--orca-navy);
  color: white;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.orca-chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.orca-close-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  opacity: 0.8;
}

.orca-close-btn:hover {
  opacity: 1;
}

/* Messages Area */
.orca-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--orca-cream);
}

.orca-message {
  max-width: 85%;
  margin-bottom: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.orca-message.user {
  background: var(--orca-gold);
  color: var(--orca-navy);
  margin-right: auto;
  margin-left: 0;
  border-bottom-right-radius: 4px;
}

.orca-message.assistant {
  background: white;
  color: var(--orca-navy);
  margin-left: auto;
  margin-right: 0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.orca-message.error {
  background: #fee;
  color: var(--orca-error);
}

/* Loading */
.orca-loading {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.orca-loading span {
  width: 8px;
  height: 8px;
  background: var(--orca-gold);
  border-radius: 50%;
  animation: orca-bounce 1.4s ease-in-out infinite;
}

.orca-loading span:nth-child(1) { animation-delay: 0s; }
.orca-loading span:nth-child(2) { animation-delay: 0.2s; }
.orca-loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes orca-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Area */
.orca-input-area {
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
}

.orca-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  resize: none;
  direction: rtl;
  font-family: inherit;
}

.orca-input:focus {
  outline: none;
  border-color: var(--orca-gold);
}

.orca-send-btn {
  background: var(--orca-gold);
  color: var(--orca-navy);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.orca-send-btn:hover {
  background: #c49f45;
}

.orca-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Domain Selection */
.orca-domain-select {
  padding: 12px;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
}

.orca-domain-select label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
}

.orca-domain-select select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  direction: rtl;
}

/* Intake Preview */
.orca-preview-toggle {
  background: none;
  border: none;
  color: var(--orca-gold);
  cursor: pointer;
  font-size: 13px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.orca-intake-preview {
  display: none;
  padding: 12px 16px;
  background: #f8f9fa;
  font-size: 13px;
  max-height: 200px;
  overflow-y: auto;
}

.orca-intake-preview.open {
  display: block;
}

.orca-missing-field {
  color: var(--orca-error);
  font-size: 12px;
}

/* Questions */
.orca-questions {
  margin-bottom: 12px;
  padding: 8px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.orca-questions-header {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
}

.orca-question-btn {
  display: block;
  width: 100%;
  text-align: right;
  background: rgba(212, 175, 85, 0.06);
  border: 1px solid rgba(212, 175, 85, 0.25);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--orca-navy);
  transition: background 0.2s, border-color 0.2s;
}

.orca-question-btn:last-child {
  margin-bottom: 0;
}

.orca-question-btn:hover {
  background: rgba(212, 175, 85, 0.12);
  border-color: var(--orca-gold);
}

/* Intake complete indicator (extracted from inline style) */
.orca-intake-complete {
  color: var(--orca-success);
}

/* Mobile */
@media (max-width: 480px) {
  .orca-chat-modal {
    left: 10px;
    right: 10px;
    bottom: calc(80px + var(--cookie-notice-h, 0px));
    width: auto;
    height: calc(100vh - 100px - var(--cookie-notice-h, 0px));
  }

  .orca-widget-container {
    left: 10px;
    bottom: calc(10px + var(--cookie-notice-h, 0px));
  }
}

/* UB-4264: the launcher floats over the foot of the page; reserve room for it
   (plus the notice, when showing) so the last control on a page can be scrolled
   clear of it. This sheet is linked only on pages that carry the widget. */
html { scroll-padding-bottom: calc(var(--cookie-notice-h, 0px) + 90px); }
body { padding-bottom: calc(var(--cookie-notice-h, 0px) + 90px); }

/* UB-4322: the rules above are written for the Hebrew page; the English site lays the widget out left-to-right. */
html[lang="en"] .orca-widget-container,
html[lang="en"] .orca-input,
html[lang="en"] .orca-domain-select select {
  direction: ltr;
}

/* UB-4323: the English site's note that server-written text is Hebrew */
.hebrew-data-note { font-size: 0.85em; opacity: 0.75; margin: 0.4em 0; }
