/* ── ONHYM AI Chat Widget ── */
:root {
  --oc-primary:    #0f766e;
  --oc-dark:       #0a4a43;
  --oc-darker:     #0d3530;
  --oc-light:      #d4ede9;
  --oc-gold:       #c9a227;
  --oc-gold-dark:  #a07d1b;
  --oc-off:        #f5f5f3;
  --oc-gray:       #5a5a56;
  --oc-text:       #1a1a18;
  --oc-white:      #ffffff;
  --oc-radius:     16px;
  --oc-ease:       .3s cubic-bezier(.4,0,.2,1);
  --oc-shadow:     0 20px 60px rgba(10,74,67,.22);
}

/* ── FAB Button ── */
#onhym-fab {
  position: fixed;
  z-index: 999998;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(145deg, #12887f 0%, var(--oc-dark) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 6px rgba(10,74,67,.25),
    0 10px 28px rgba(10,74,67,.38),
    inset 0 1px 0 rgba(255,255,255,.12);
  transition: transform var(--oc-ease), box-shadow var(--oc-ease);
  font-family: inherit;
}
#onhym-fab::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid rgba(15,118,110,.35);
  transition: border-color var(--oc-ease), inset var(--oc-ease);
}
#onhym-fab:hover {
  transform: scale(1.06) translateY(-1px);
  box-shadow:
    0 6px 10px rgba(10,74,67,.28),
    0 16px 40px rgba(10,74,67,.45),
    inset 0 1px 0 rgba(255,255,255,.18);
}
#onhym-fab:hover::after { border-color: var(--oc-gold); inset: -5px; }
#onhym-fab svg  { width: 26px; height: 26px; drop-shadow: 0 1px 2px rgba(0,0,0,.2); }
.oc-pos-bottom-right #onhym-fab { bottom: 24px; right: 24px; }
.oc-pos-bottom-left  #onhym-fab { bottom: 24px; left: 24px; }
#onhym-fab-badge {
  position: absolute;
  top: 5px; right: 5px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e4b830, var(--oc-gold) 60%);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 6px rgba(201,162,39,.5);
  animation: oc-pulse 2.2s ease-in-out infinite;
}
@keyframes oc-pulse {
  0%,100% { transform: scale(1); box-shadow: 0 2px 6px rgba(201,162,39,.5); }
  50%      { transform: scale(1.18); box-shadow: 0 2px 10px rgba(201,162,39,.75); }
}

/* ── Chat Window ── */
#onhym-window {
  position: fixed;
  z-index: 999997;
  width: 400px;
  height: 580px;
  border-radius: var(--oc-radius);
  background: var(--oc-white);
  box-shadow: var(--oc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--oc-ease), transform var(--oc-ease);
  transform-origin: bottom right;
  font-family: 'Work Sans', -apple-system, sans-serif;
}
#onhym-window.oc-hidden { opacity: 0; pointer-events: none; transform: scale(.96) translateY(8px); }
.oc-pos-bottom-right #onhym-window { bottom: 96px; right: 24px; }
.oc-pos-bottom-left  #onhym-window { bottom: 96px; left: 24px; }

/* ── Header ── */
#oc-header {
  background: var(--oc-dark);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#oc-header-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--oc-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
#oc-header-info { flex: 1; }
#oc-header-title   { color: #fff; font-size: 14px; font-weight: 700; letter-spacing: .02em; }
#oc-header-subtitle{ color: rgba(255,255,255,.6); font-size: 11px; margin-top: 2px; display: flex; align-items: center; gap: 5px; }
#oc-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--oc-gold);
  animation: oc-pulse 2s infinite;
}
#oc-close-btn {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.75); width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0;
  transition: background var(--oc-ease), color var(--oc-ease), border-color var(--oc-ease);
  flex-shrink: 0;
}
#oc-close-btn:hover { background: rgba(255,255,255,.22); color: #fff; border-color: rgba(255,255,255,.35); }

/* ── Body ── */
#oc-body {
  flex: 1; overflow: hidden; display: flex; flex-direction: column;
  background: var(--oc-off);
}

/* ── Lead Form ── */
#oc-form-step {
  flex: 1; padding: 24px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px;
}
.oc-form-intro h3 { font-size: 17px; font-weight: 700; color: var(--oc-text); margin: 0 0 6px; }
.oc-form-intro p  { font-size: 13px; color: var(--oc-gray); margin: 0; line-height: 1.5; }
.oc-field label   { display: block; font-size: 11px; font-weight: 700; color: var(--oc-gray); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px; }
.oc-field input   {
  width: 100%; padding: 10px 14px; border: 1.5px solid #e0e0de; border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--oc-text);
  transition: border-color var(--oc-ease), box-shadow var(--oc-ease);
  box-sizing: border-box;
}
.oc-field input:focus { outline: none; border-color: var(--oc-gold); box-shadow: 0 0 0 3px rgba(201,162,39,.15); }
.oc-field input.oc-error { border-color: #e74c3c; }
.oc-field-error   { font-size: 11px; color: #e74c3c; margin-top: 4px; }
.oc-optional      { font-size: 10px; color: #aaa; font-weight: 400; text-transform: none; letter-spacing: 0; }
#oc-start-btn {
  width: 100%; padding: 13px; border-radius: 50px; border: none;
  background: var(--oc-gold); color: var(--oc-dark);
  font-size: 14px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: background var(--oc-ease), transform var(--oc-ease);
  margin-top: 4px;
}
#oc-start-btn:hover   { background: var(--oc-gold-dark); transform: translateY(-1px); }
#oc-start-btn:disabled{ opacity: .6; cursor: not-allowed; transform: none; }

/* ── Chat Step ── */
#oc-chat-step { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#oc-messages  { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
#oc-messages::-webkit-scrollbar { width: 4px; }
#oc-messages::-webkit-scrollbar-track { background: transparent; }
#oc-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* ── Bubbles ── */
.oc-bubble { max-width: 82%; display: flex; flex-direction: column; }
.oc-bubble.oc-user { align-self: flex-end; align-items: flex-end; }
.oc-bubble.oc-ai   { align-self: flex-start; align-items: flex-start; }

.oc-bubble-text {
  padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.6;
  word-break: break-word; white-space: pre-wrap;
}
.oc-bubble.oc-ai .oc-bubble-text {
  background: #fff; color: var(--oc-text);
  border: 1px solid #e8e8e6; border-radius: 4px 12px 12px 12px;
}
.oc-bubble.oc-user .oc-bubble-text {
  background: var(--oc-primary); color: #fff;
  border-radius: 12px 4px 12px 12px;
}
.oc-bubble-time { font-size: 10px; color: #bbb; margin-top: 4px; padding: 0 4px; }

/* ── Suggested questions ── */
#oc-suggestions {
  padding: 8px 14px 10px;
  background: var(--oc-off);
  border-top: 1px solid #ebebea;
}
.oc-sugg-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--oc-gray);
  margin: 0 0 8px;
  padding: 0;
}
.oc-sugg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.oc-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #e4e4e0;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color var(--oc-ease), background var(--oc-ease), transform var(--oc-ease);
}
.oc-suggestion:hover {
  border-color: var(--oc-primary);
  background: var(--oc-light);
  transform: translateY(-1px);
}
.oc-sugg-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--oc-dark);
  line-height: 1.3;
}
.oc-sugg-arrow {
  font-size: 16px;
  color: var(--oc-primary);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--oc-ease);
  line-height: 1;
}
.oc-suggestion:hover .oc-sugg-arrow { opacity: 1; }

/* ── Typing indicator ── */
.oc-typing { display: flex; gap: 4px; align-items: center; padding: 12px 14px; }
.oc-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--oc-primary);
  animation: oc-bounce .9s infinite;
}
.oc-typing span:nth-child(2) { animation-delay: .15s; }
.oc-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes oc-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-6px); }
}

/* ── Input bar ── */
#oc-input-bar {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
#oc-input {
  flex: 1; border: 1.5px solid #e0e0de; border-radius: 20px;
  padding: 10px 16px; font-size: 14px; font-family: inherit; resize: none;
  max-height: 100px; overflow-y: auto; line-height: 1.5;
  transition: border-color var(--oc-ease);
  background: var(--oc-off);
}
#oc-input:focus { outline: none; border-color: var(--oc-gold); background: #fff; }
#oc-send-btn {
  width: 42px; height: 42px;
  border-radius: 20px;
  border: none;
  background: linear-gradient(145deg, #12887f, var(--oc-dark));
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(10,74,67,.35), inset 0 1px 0 rgba(255,255,255,.1);
  transition: background var(--oc-ease), transform var(--oc-ease), box-shadow var(--oc-ease);
}
#oc-send-btn:hover   {
  background: linear-gradient(145deg, var(--oc-gold), var(--oc-gold-dark));
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(201,162,39,.4), inset 0 1px 0 rgba(255,255,255,.15);
}
#oc-send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
#oc-send-btn svg { width: 18px; height: 18px; display: block; flex-shrink: 0; }

/* ── Responsive mobile ── */
@media (max-width: 600px) {
  #onhym-window {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100dvh !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    transform-origin: bottom center;
  }
  .oc-pos-bottom-right #onhym-window,
  .oc-pos-bottom-left  #onhym-window {
    bottom: 0; right: 0; left: 0; top: 0;
  }
  #onhym-window.oc-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(100%);
  }
  #oc-form-step { padding: 28px 20px 20px; }
  #onhym-fab { bottom: 20px; right: 20px; }
  .oc-pos-bottom-left #onhym-fab { left: 20px; right: auto; }
}

/* Hide FAB on mobile only when window is open */
@media (max-width: 600px) {
  #onhym-chat-root:not(.oc-window-hidden) #onhym-fab { display: none; }
}

/* ── Markdown rendering inside AI bubbles ── */
.oc-bubble.oc-ai .oc-bubble-text h2 {
  font-size: 14px; font-weight: 800; color: var(--oc-dark);
  margin: 10px 0 5px; padding-bottom: 4px;
  border-bottom: 1.5px solid var(--oc-light);
  letter-spacing: -.01em;
}
.oc-bubble.oc-ai .oc-bubble-text h3 {
  font-size: 13px; font-weight: 700; color: var(--oc-dark);
  margin: 8px 0 4px;
}
.oc-bubble.oc-ai .oc-bubble-text h4 {
  font-size: 12px; font-weight: 700; color: var(--oc-primary);
  margin: 6px 0 3px; text-transform: uppercase; letter-spacing: .05em;
}
.oc-bubble.oc-ai .oc-bubble-text p {
  margin: 0 0 5px; line-height: 1.6;
}
.oc-bubble.oc-ai .oc-bubble-text p:last-child { margin-bottom: 0; }
.oc-bubble.oc-ai .oc-bubble-text strong {
  font-weight: 700; color: var(--oc-darker);
}
.oc-bubble.oc-ai .oc-bubble-text em { font-style: italic; color: var(--oc-gray); }
.oc-bubble.oc-ai .oc-bubble-text ul,
.oc-bubble.oc-ai .oc-bubble-text ol {
  padding-left: 16px; margin: 4px 0 6px;
}
.oc-bubble.oc-ai .oc-bubble-text li { margin: 3px 0; line-height: 1.55; }
.oc-bubble.oc-ai .oc-bubble-text ul li::marker { color: var(--oc-gold); }
.oc-bubble.oc-ai .oc-bubble-text ol li::marker { color: var(--oc-primary); font-weight: 700; }
.oc-bubble.oc-ai .oc-bubble-text code {
  background: var(--oc-light); color: var(--oc-darker);
  padding: 1px 5px; border-radius: 4px;
  font-size: 11px; font-family: 'Courier New', monospace;
}
.oc-bubble.oc-ai .oc-bubble-text hr {
  border: none; border-top: 1px solid var(--oc-light); margin: 8px 0;
}

/* ── Sources ── */
.oc-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--oc-light);
}
.oc-sources-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--oc-gray);
  flex-shrink: 0;
}
.oc-source-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 50px;
  border: 1px solid var(--oc-light);
  background: var(--oc-off);
  color: var(--oc-primary);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  transition: background var(--oc-ease), border-color var(--oc-ease);
}
.oc-source-chip:hover {
  background: var(--oc-light);
  border-color: var(--oc-primary);
}

/* ── Markdown tables ── */
.oc-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--oc-light);
}
.oc-md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.4;
}
.oc-md-table th {
  background: var(--oc-dark);
  color: #fff;
  padding: 7px 10px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .04em;
  white-space: nowrap;
}
.oc-md-table th:first-child { border-radius: 8px 0 0 0; }
.oc-md-table th:last-child  { border-radius: 0 8px 0 0; }
.oc-md-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--oc-light);
  vertical-align: top;
  color: var(--oc-text);
}
.oc-md-table tbody tr:last-child td { border-bottom: none; }
.oc-md-table tbody tr:nth-child(even) td { background: rgba(212,237,233,.25); }
.oc-md-table tbody tr:hover td { background: var(--oc-light); }
.oc-bubble.oc-ai .oc-bubble-text a {
  color: var(--oc-primary);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(15,118,110,.35);
  text-underline-offset: 2px;
  transition: color var(--oc-ease);
}
.oc-bubble.oc-ai .oc-bubble-text a:hover {
  color: var(--oc-gold);
  text-decoration-color: var(--oc-gold);
}

@media (prefers-reduced-motion: reduce) {
  #onhym-fab-badge, #oc-status-dot, .oc-typing span { animation: none; }
  #onhym-window, #onhym-fab { transition: none; }
}
