/* EVERIS Chatbot — website widget styles.
   All classnames are prefixed `everis-` to avoid clashes with the Tilda page.
   All fonts use system-ui — no external font downloads.
*/

.everis-chat-root,
.everis-chat-root * {
  box-sizing: border-box;
}

.everis-chat-root {
  --everis-teal: #01696F;
  --everis-teal-hover: #015158;
  --everis-bg: #F9F8F5;
  --everis-bubble-jarvis: #F0EDE7;
  --everis-text: #1A1A1A;
  --everis-muted: #6B7280;
  --everis-line: #E5E1D8;
  --everis-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  --everis-radius: 16px;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000; /* above Tilda popups */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--everis-text);
}

/* ---------- Collapsed bubble ---------- */
.everis-chat-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--everis-teal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--everis-shadow);
  border: none;
  outline: none;
  transition: transform .15s ease-out, background .15s;
}
.everis-chat-bubble:hover {
  background: var(--everis-teal-hover);
  transform: translateY(-2px);
}
.everis-chat-bubble svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Panel ---------- */
.everis-chat-panel {
  width: 380px;
  height: 560px;
  background: var(--everis-bg);
  border-radius: var(--everis-radius);
  box-shadow: var(--everis-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: everis-open .2s ease-out;
}
.everis-chat-root.everis-open .everis-chat-panel { display: flex; }
.everis-chat-root.everis-open .everis-chat-bubble { display: none; }

@keyframes everis-open {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ---------- Header ---------- */
.everis-chat-header {
  background: var(--everis-teal);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.everis-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.everis-chat-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.everis-chat-title { flex: 1; line-height: 1.25; }
.everis-chat-title strong { font-size: 15px; font-weight: 600; display: block; }
.everis-chat-title span { font-size: 12px; opacity: .85; display: block; }
.everis-chat-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: .8;
  transition: opacity .15s, background .15s;
}
.everis-chat-close:hover { opacity: 1; background: rgba(255,255,255,.15); }

/* ---------- Messages ---------- */
.everis-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--everis-bg);
}
.everis-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: everis-fadein .15s ease-out;
}
@keyframes everis-fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.everis-msg-jarvis {
  background: var(--everis-bubble-jarvis);
  color: var(--everis-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.everis-msg-user {
  background: var(--everis-teal);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.everis-msg-error {
  background: #FEF2F2;
  color: #991B1B;
  align-self: center;
  font-size: 13px;
  max-width: 90%;
  text-align: center;
}

/* ---------- Typing indicator ---------- */
.everis-typing {
  align-self: flex-start;
  padding: 12px 14px;
  background: var(--everis-bubble-jarvis);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: none;
}
.everis-typing.everis-visible { display: flex; gap: 4px; }
.everis-typing span {
  width: 6px;
  height: 6px;
  background: var(--everis-muted);
  border-radius: 50%;
  animation: everis-bounce 1.2s infinite;
}
.everis-typing span:nth-child(2) { animation-delay: .15s; }
.everis-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes everis-bounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: .4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Input ---------- */
.everis-chat-input {
  border-top: 1px solid var(--everis-line);
  padding: 10px 12px;
  /* iOS safe-areas (Dynamic Island, home indicator) */
  padding-left: calc(12px + env(safe-area-inset-left, 0px));
  padding-right: calc(12px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: 1fr 38px;
  align-items: end;
  gap: 8px;
  background: #fff;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}
.everis-chat-input textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--everis-line);
  border-radius: 10px;
  padding: 9px 12px;
  /* iOS Safari zooms in when font-size < 16px on input focus — prevent */
  font-size: 16px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.4;
  color: var(--everis-text);
  background: #fff;
  transition: border-color .15s;
}
.everis-chat-input textarea:focus { border-color: var(--everis-teal); }
.everis-chat-input textarea:disabled { background: #F5F5F5; cursor: not-allowed; }
.everis-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--everis-teal);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.everis-chat-send:hover:not(:disabled) { background: var(--everis-teal-hover); }
.everis-chat-send:disabled { background: #A8B0B2; cursor: not-allowed; }
.everis-chat-send svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Mobile & landscape: full-screen ---------- */
/* Portrait phones + all landscape phones (short viewport height) */
@media (max-width: 767px), (max-height: 600px) {
  .everis-chat-root { right: 12px; bottom: 12px; }
  .everis-chat-root.everis-open {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
  }
  .everis-chat-root.everis-open .everis-chat-panel {
    width: 100vw;
    /* iOS Safari 100vh includes URL bar area and hides input; use dvh + fallback */
    height: 100vh;
    height: -webkit-fill-available;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    animation: none;
  }
}

/* ---------- Scrollbar ---------- */
.everis-chat-messages::-webkit-scrollbar { width: 6px; }
.everis-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.15);
  border-radius: 3px;
}
