/* OM Web — Live Chat Widget v3 */
.om-chat {
  --oc-dark: #112d4e;
  --oc-blue: #3f72af;
  --oc-blue2: #2f5a8f;
  --oc-gray: #dbe2ef;
  --oc-bg: #f4f6fa;
  --oc-white: #fff;
  --oc-shadow: 0 12px 40px rgba(17,45,78,.22);
  --oc-radius: 18px;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99999;
  font-family: 'Plus Jakarta Sans','Inter',system-ui,sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
*, *::before, *::after { box-sizing: border-box; }

/* ─── Launcher ─── */
.om-chat__launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 12px 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg,var(--oc-blue),var(--oc-blue2));
  color: var(--oc-white);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 700;
  box-shadow: var(--oc-shadow);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  white-space: nowrap;
}
.om-chat__launcher:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 16px 50px rgba(17,45,78,.28);
}
.om-chat__launcher-icon { font-size: 1.2rem; line-height: 1; }
.om-chat__launcher-icon--close { display: none; }
.om-chat.is-open .om-chat__launcher-icon--open { display: none; }
.om-chat.is-open .om-chat__launcher-icon--close { display: inline; }
.om-chat.is-open .om-chat__launcher-label { display: none; }
.om-chat.is-open .om-chat__launcher { padding: 14px; border-radius: 50%; }
.om-chat__pulse {
  position: absolute; inset: -4px;
  border-radius: 999px;
  border: 2px solid rgba(63,114,175,.4);
  animation: oc-pulse 2s ease-out infinite;
  pointer-events: none;
}
.om-chat.is-open .om-chat__pulse { display: none; }
@keyframes oc-pulse {
  0%   { transform: scale(1); opacity: .7; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ─── Panel ─── */
.om-chat__panel {
  position: fixed;
  right: 20px;
  bottom: 80px;
  width: 370px;
  max-width: calc(100vw - 30px);
  height: 520px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  background: var(--oc-white);
  border-radius: var(--oc-radius);
  box-shadow: var(--oc-shadow);
  overflow: hidden;
  animation: oc-slideUp .3s ease both;
}
.om-chat__panel[hidden] { display: none !important; }
@keyframes oc-slideUp {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ─── Header ─── */
.om-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg,var(--oc-dark),#1a3d66);
  color: var(--oc-white);
  flex-shrink: 0;
}
.om-chat__agent {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.om-chat__avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: contain;
  background: var(--oc-white);
  padding: 3px;
  flex-shrink: 0;
}
.om-chat__agent strong {
  display: block;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.2;
}
.om-chat__status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  opacity: .9;
  margin-top: 1px;
}
.om-chat__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}
.om-chat__status.is-offline .om-chat__dot { background: #fbbf24; }
.om-chat__status.is-typing .om-chat__dot {
  background: #60a5fa;
  animation: oc-dotPulse 1s ease-in-out infinite;
}
@keyframes oc-dotPulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.om-chat__head-actions { display: flex; gap: 2px; flex-shrink: 0; }
.om-chat__icon-btn {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,.1);
  color: var(--oc-white);
  font-size: .85rem;
  cursor: pointer;
  transition: background .15s;
}
.om-chat__icon-btn:hover { background: rgba(255,255,255,.22); }

/* ─── Messages ─── */
.om-chat__messages {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 14px 12px;
  background: var(--oc-bg);
  scroll-behavior: smooth;
}
.om-chat__msg {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  animation: oc-msgIn .25s ease both;
}
.om-chat__msg--user { flex-direction: row-reverse; }
@keyframes oc-msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.om-chat__msg-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: contain;
  background: var(--oc-white);
  padding: 2px;
  flex-shrink: 0;
  align-self: flex-end;
}
.om-chat__bubble {
  max-width: 80%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: .84rem;
  line-height: 1.55;
  word-break: break-word;
}
.om-chat__msg--bot .om-chat__bubble {
  background: var(--oc-white);
  color: var(--oc-dark);
  border: 1px solid rgba(219,226,239,.85);
  border-bottom-left-radius: 4px;
}
.om-chat__msg--user .om-chat__bubble {
  background: linear-gradient(135deg,var(--oc-blue),var(--oc-blue2));
  color: var(--oc-white);
  border-bottom-right-radius: 4px;
}
.om-chat__bubble a {
  color: var(--oc-blue);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.om-chat__msg--user .om-chat__bubble a { color: var(--oc-gray); }
.om-chat__bubble strong { font-weight: 700; }
.om-chat__bubble ul { margin: 6px 0 0; padding-left: 16px; }
.om-chat__bubble li { margin-bottom: 3px; }
.om-chat__bubble p { margin: 6px 0 0; }

/* Date separator */
.om-chat__date {
  text-align: center;
  font-size: .68rem;
  color: #8a99ad;
  margin: 8px 0;
  letter-spacing: .02em;
}

/* Typing indicator */
.om-chat__typing {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  animation: oc-msgIn .25s ease both;
}
.om-chat__typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--oc-white);
  border: 1px solid rgba(219,226,239,.85);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.om-chat__typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--oc-blue);
  opacity: .35;
  animation: oc-bounce 1.2s ease-in-out infinite;
}
.om-chat__typing-dots span:nth-child(2) { animation-delay: .15s; }
.om-chat__typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes oc-bounce {
  0%,60%,100% { transform: translateY(0); opacity: .35; }
  30%          { transform: translateY(-4px); opacity: 1; }
}

/* ─── Quick Replies ─── */
.om-chat__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 10px;
  background: var(--oc-bg);
  border-top: 1px solid rgba(219,226,239,.5);
  flex-shrink: 0;
}
.om-chat__quick:empty { display: none; }
.om-chat__chip {
  padding: 6px 12px;
  border: 1px solid rgba(63,114,175,.3);
  border-radius: 999px;
  background: var(--oc-white);
  color: var(--oc-dark);
  font-family: inherit;
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.om-chat__chip:hover {
  background: var(--oc-blue);
  border-color: var(--oc-blue);
  color: var(--oc-white);
}

/* ─── Input ─── */
.om-chat__form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--oc-gray);
  background: var(--oc-white);
  flex-shrink: 0;
}
.om-chat__input {
  flex: 1;
  min-width: 0;
  padding: 9px 14px;
  border: 1px solid var(--oc-gray);
  border-radius: 999px;
  font-family: inherit;
  font-size: .84rem;
  outline: none;
  transition: border-color .15s;
}
.om-chat__input:focus { border-color: var(--oc-blue); }
.om-chat__send {
  width: 38px; height: 38px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg,var(--oc-blue),var(--oc-blue2));
  color: var(--oc-white);
  font-size: .9rem;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s;
}
.om-chat__send:hover { transform: scale(1.06); }

/* ─── Footer ─── */
.om-chat__foot {
  display: flex;
  justify-content: space-around;
  gap: 2px;
  padding: 8px 6px;
  background: var(--oc-gray);
  flex-shrink: 0;
}
.om-chat__foot-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--oc-dark);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.om-chat__foot-link:hover {
  color: var(--oc-blue);
  background: rgba(255,255,255,.55);
}
.om-chat__foot-link .bi-whatsapp { color: #25d366; }

/* ─── Cards inside bot bubbles ─── */
.om-chat__cards {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.om-chat__card-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--oc-bg);
  border: 1px solid var(--oc-gray);
  color: var(--oc-dark);
  text-decoration: none;
  font-size: .78rem;
  font-weight: 600;
  transition: border-color .15s, background .15s;
}
.om-chat__card-link:hover {
  border-color: var(--oc-blue);
  background: rgba(63,114,175,.06);
}
.om-chat__card-link i {
  color: var(--oc-blue);
  font-size: .95rem;
  flex-shrink: 0;
}

/* ─── Lead Form (Quote) ─── */
.om-chat__lead {
  position: fixed;
  right: 20px;
  bottom: 80px;
  width: 370px;
  max-width: calc(100vw - 30px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: var(--oc-white);
  border-radius: var(--oc-radius);
  box-shadow: var(--oc-shadow);
  overflow: hidden;
  animation: oc-slideUp .3s ease both;
  z-index: 1;
}
.om-chat__lead[hidden] { display: none !important; }
.om-chat__lead-inner {
  height: 100%;
  overflow-y: auto;
  padding: 20px 16px 24px;
}
.om-chat__lead-back {
  width: 34px; height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--oc-gray);
  color: var(--oc-dark);
  cursor: pointer;
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
}
.om-chat__lead h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--oc-dark);
  margin: 0 0 4px;
}
.om-chat__lead p {
  font-size: .82rem;
  color: #5a6b7d;
  margin: 0 0 14px;
}
.om-chat__field { margin-bottom: 8px; }
.om-chat__field input,
.om-chat__field select,
.om-chat__field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--oc-gray);
  border-radius: 10px;
  font-family: inherit;
  font-size: .84rem;
  outline: none;
  background: var(--oc-bg);
  transition: border-color .15s, background .15s;
}
.om-chat__field input:focus,
.om-chat__field select:focus,
.om-chat__field textarea:focus {
  border-color: var(--oc-blue);
  background: var(--oc-white);
}
.om-chat__lead-submit {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg,var(--oc-blue),var(--oc-blue2));
  color: var(--oc-white);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.om-chat__lead-submit:disabled { opacity: .55; cursor: wait; }
.om-chat__lead-note {
  margin-top: 8px;
  font-size: .8rem;
  text-align: center;
}
.om-chat__lead-note.is-ok { color: #15803d; }
.om-chat__lead-note.is-err { color: #b91c1c; }

/* ─── Mobile ─── */
@media (max-width: 767.98px) {
  .om-chat {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .om-chat__launcher-label { display: none; }
  .om-chat__launcher {
    padding: 14px 16px;
    border-radius: 50%;
    min-width: 52px;
    min-height: 52px;
    justify-content: center;
  }

  /* Hide floating launcher when chat is open — use header close button */
  .om-chat.is-open .om-chat__launcher { display: none; }

  .om-chat__panel,
  .om-chat__lead {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    z-index: 100000;
  }

  .om-chat__head {
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 12px;
  }

  .om-chat__agent strong {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 46vw;
  }

  .om-chat__messages {
    padding: 12px 10px;
    -webkit-overflow-scrolling: touch;
  }

  .om-chat__bubble {
    max-width: 88%;
    font-size: 0.82rem;
  }

  .om-chat__quick {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 8px 10px;
  }
  .om-chat__quick::-webkit-scrollbar { display: none; }

  .om-chat__chip {
    flex-shrink: 0;
    font-size: 0.74rem;
    padding: 7px 12px;
  }

  .om-chat__form {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .om-chat__input {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .om-chat__foot {
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
    gap: 4px;
  }

  .om-chat__foot-link {
    flex: 1 1 auto;
    justify-content: center;
    font-size: 0.7rem;
    padding: 6px 4px;
  }

  .om-chat__lead-inner {
    padding: calc(16px + env(safe-area-inset-top, 0px)) 14px calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .om-chat__field input,
  .om-chat__field select,
  .om-chat__field textarea {
    font-size: 16px;
  }

  .om-chat__card-link {
    font-size: 0.76rem;
    padding: 9px 10px;
  }
}

@media (max-width: 380px) {
  .om-chat__icon-btn {
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
  }
  .om-chat__head-actions { gap: 1px; }
}
