/* TAT Custom Chat Widget - Tidio-inspired */
:root {
  --tat-chat-primary: #d4882b;
  --tat-chat-button: #3b2415;
  --tat-chat-text: #333333;
  --tat-chat-bg: #ffffff;
  --tat-chat-bot-bubble: #f2f2f2;
  --tat-chat-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  --tat-chat-border: #ececec;
  --tat-chat-radius: 14px;
  --tat-z-index: 999999;
  --tat-font: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.tat-chat-widget-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--tat-z-index);
  font-family: var(--tat-font);
  color: var(--tat-chat-text);
}

.tat-chat-toggle {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--tat-chat-button);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(59, 36, 21, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.tat-chat-toggle:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 28px rgba(59, 36, 21, 0.52);
}

.tat-chat-toggle:active {
  transform: translateY(0) scale(0.98);
}

.tat-chat-toggle svg {
  width: 24px;
  height: 24px;
}

.tat-chat-badge {
  position: absolute;
  top: -4px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #ff2b2b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  padding: 0 5px;
}

.tat-chat-greeting {
  position: absolute;
  right: 4px;
  bottom: 70px;
  width: 260px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--tat-chat-shadow);
  border: 1px solid var(--tat-chat-border);
  padding: 14px 14px 12px;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.26s ease;
}

.tat-chat-greeting.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

.tat-chat-greeting-text {
  margin: 0;
  color: var(--tat-chat-text);
  line-height: 1.45;
  font-size: 14px;
}

.tat-chat-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: min(380px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 110px));
  border-radius: var(--tat-chat-radius);
  background: var(--tat-chat-bg);
  box-shadow: var(--tat-chat-shadow);
  border: 1px solid var(--tat-chat-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-origin: bottom right;
  transform: translateY(12px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.22s ease;
}

.tat-chat-panel.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.tat-chat-header {
  padding: 14px 14px;
  background: var(--tat-chat-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tat-chat-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tat-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.tat-chat-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.tat-chat-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.95;
}

.tat-chat-header-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
}

.tat-chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tat-chat-row {
  display: flex;
}

.tat-chat-row.user {
  justify-content: flex-end;
}

.tat-chat-bubble {
  max-width: 84%;
  border-radius: 16px;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.tat-chat-bubble.bot {
  background: var(--tat-chat-bot-bubble);
  color: var(--tat-chat-text);
  border-bottom-left-radius: 6px;
}

.tat-chat-bubble.user {
  background: var(--tat-chat-primary);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.tat-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
  background: var(--tat-chat-bot-bubble);
  border-radius: 16px;
}

.tat-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9e9e9e;
  animation: tat-bounce 1.2s infinite;
}

.tat-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.tat-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes tat-bounce {
  0%, 80%, 100% { transform: scale(0.75); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.tat-chat-input-wrap {
  border-top: 1px solid var(--tat-chat-border);
  padding: 10px;
  background: #fff;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.tat-chat-input {
  border: 1px solid #d9d9d9;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  font-size: 14px;
}

.tat-chat-input:focus {
  border-color: var(--tat-chat-primary);
  box-shadow: 0 0 0 3px rgba(212, 136, 43, 0.18);
}

.tat-chat-send {
  width: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--tat-chat-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tat-chat-send:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.tat-chat-footer {
  text-align: center;
  font-size: 10px;
  color: #8a8a8a;
  padding: 6px 10px 8px;
  border-top: 1px solid #f3f3f3;
  background: #fff;
}

@media (max-width: 640px) {
  .tat-chat-widget-root {
    right: 12px;
    bottom: 12px;
  }

  .tat-chat-panel {
    width: min(100vw - 12px, 390px);
    height: min(72vh, 560px);
    right: 0;
    bottom: 66px;
  }

  .tat-chat-greeting {
    width: min(280px, calc(100vw - 34px));
  }
}
