﻿/* Minimal floating chat */
.twora-chat {
  position: fixed; z-index: 1200;
  inset-inline-start: 1rem; bottom: 1rem;
  display: flex; flex-direction: column; align-items: flex-start; gap: .45rem;
  font-family: inherit;
}
.twora-chat-fab-wrap {
  display: inline-flex; align-items: center; gap: .55rem;
}
.twora-chat-fab-label {
  font-size: .72rem; font-weight: 700; color: #1A5C4E;
  background: #fff; border: 1px solid rgba(26,92,78,.14);
  border-radius: 999px; padding: .28rem .65rem;
  box-shadow: 0 6px 16px rgba(15,31,28,.08);
  white-space: nowrap; line-height: 1.2;
  pointer-events: none; user-select: none;
}
.twora-chat.is-open .twora-chat-fab-label { display: none; }
.twora-chat-fab {
  width: 52px; height: 52px; border: 0; border-radius: 50%; cursor: pointer;
  color: #fff; background: #E54D1A;
  box-shadow: 0 10px 24px rgba(229,77,26,.28);
  display: grid; place-items: center;
  transition: transform .15s ease, background .15s ease;
}
.twora-chat-fab:hover { background: #d44315; transform: translateY(-1px); }
.twora-chat-fab-close { display: none; }
.twora-chat.is-open .twora-chat-fab-icon { display: none; }
.twora-chat.is-open .twora-chat-fab-close { display: block; }
.twora-chat-fab-pulse { display: none; }

.twora-chat-panel {
  position: absolute; inset-inline-start: 0; bottom: 62px;
  width: min(340px, calc(100vw - 1.5rem));
  height: min(480px, calc(100vh - 6rem));
  display: flex; flex-direction: column;
  background: #fff; border-radius: 16px; overflow: hidden;
  border: 1px solid rgba(15,31,28,.1);
  box-shadow: 0 18px 40px rgba(15,31,28,.14);
}
.twora-chat-head {
  display: flex; align-items: center; gap: .65rem;
  padding: .75rem .85rem; background: #12352e; color: #fff;
}
.twora-chat-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: rgba(255,255,255,.12);
}
.twora-chat-head-text { flex: 1; min-width: 0; }
.twora-chat-head-text strong { display: block; font-size: .92rem; font-weight: 700; }
.twora-chat-head-text small { opacity: .75; font-size: .72rem; font-weight: 500; }
.twora-chat-min {
  border: 0; background: transparent; color: #fff; opacity: .8;
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 1rem; line-height: 1;
}
.twora-chat-min:hover { opacity: 1; background: rgba(255,255,255,.1); }

.twora-chat-body {
  flex: 1; overflow: auto; padding: .85rem .75rem;
  background: #f7f8f8;
  display: flex; flex-direction: column; gap: .5rem;
}
.twora-chat-msg { display: flex; flex-direction: column; gap: .15rem; max-width: 88%; }
.twora-chat-msg.is-me { align-self: flex-start; }
.twora-chat-msg.is-bot, .twora-chat-msg.is-admin { align-self: flex-end; }
.twora-chat-who { display: none; }
.twora-chat-bubble {
  padding: .55rem .75rem; border-radius: 12px;
  line-height: 1.6; font-size: .86rem;
  white-space: pre-wrap; word-break: break-word;
}
.twora-chat-msg.is-me .twora-chat-bubble {
  background: #E54D1A; color: #fff; border-radius: 12px 12px 12px 4px;
}
[dir="rtl"] .twora-chat-msg.is-me .twora-chat-bubble { border-radius: 12px 12px 4px 12px; }
.twora-chat-msg.is-bot .twora-chat-bubble,
.twora-chat-msg.is-admin .twora-chat-bubble {
  background: #fff; color: #1a2a26; border: 1px solid rgba(15,31,28,.08);
  border-radius: 12px 12px 4px 12px;
}
[dir="rtl"] .twora-chat-msg.is-bot .twora-chat-bubble,
[dir="rtl"] .twora-chat-msg.is-admin .twora-chat-bubble { border-radius: 12px 12px 12px 4px; }
.twora-chat-msg.is-admin .twora-chat-bubble { border-color: rgba(229,77,26,.2); }
.twora-chat-msg.is-in { animation: tworaChatIn .2s ease both; }
@keyframes tworaChatIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.twora-chat-topics {
  display: flex; flex-direction: column; gap: .35rem;
  padding: .55rem .65rem .7rem;
  border-top: 1px solid rgba(15,31,28,.08); background: #fff;
  max-height: 40%; overflow: auto;
}
.twora-chat-topic {
  border: 1px solid rgba(15,31,28,.1); background: #fff; color: #1a2a26;
  border-radius: 10px; padding: .5rem .7rem; text-align: start; cursor: pointer;
  font: inherit; font-size: .8rem; font-weight: 600; transition: border-color .15s, background .15s;
}
.twora-chat-topic:hover { border-color: rgba(229,77,26,.35); background: #fffaf7; }
.twora-chat-topic.is-custom {
  border-style: dashed; color: #E54D1A; border-color: rgba(229,77,26,.35);
}

.twora-chat-compose {
  border-top: 1px solid rgba(15,31,28,.08); background: #fff;
  padding: .5rem .6rem .6rem; display: flex; flex-direction: column; gap: .4rem;
}
.twora-chat-compose-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.twora-chat-compose-fields input,
.twora-chat-compose-row textarea {
  width: 100%; border: 1px solid rgba(15,31,28,.12); border-radius: 10px;
  padding: .45rem .6rem; font: inherit; font-size: .82rem; background: #fff;
}
.twora-chat-compose-row { display: flex; gap: .35rem; align-items: flex-end; }
.twora-chat-compose-row textarea {
  resize: none; min-height: 40px; max-height: 96px; flex: 1;
}
.twora-chat-compose-row button {
  width: 40px; height: 40px; border: 0; border-radius: 10px; cursor: pointer;
  color: #fff; flex-shrink: 0; background: #E54D1A; display: grid; place-items: center;
}
.twora-chat-compose-row button:disabled { opacity: .5; cursor: wait; }
.twora-chat-back {
  border: 0; background: transparent; color: #6a7a74; font: inherit;
  font-size: .75rem; font-weight: 600; cursor: pointer; text-align: start; padding: .1rem .15rem;
}
.twora-chat-back:hover { color: #E54D1A; }

@media (max-width: 720px) {
  .twora-chat { inset-inline-start: .75rem; bottom: .75rem; }
  .twora-chat-fab-label { font-size: .68rem; padding: .22rem .55rem; }
  .twora-chat-panel {
    position: fixed; inset-inline: .55rem; bottom: 4.6rem; width: auto;
    height: min(68vh, 500px); border-radius: 14px;
  }
  .twora-chat-compose-fields { grid-template-columns: 1fr; }
}
