/* ============================================================
   TSU Chat Widget
   ============================================================ */

/* ── Root container — fixed bottom-right, above WhatsApp CTA */
.cw-root {
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── FAB toggle button */
.cw-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0E7A4B;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(14,122,75,.45);
  transition: transform .2s, background .2s;
  position: relative;
}

.cw-fab:hover {
  background: #0a6040;
  transform: scale(1.06);
}

.cw-fab--open {
  background: #555;
}

.cw-fab--open:hover {
  background: #444;
}

.cw-fab__icon {
  font-size: 1.4rem;
  line-height: 1;
}

.cw-fab__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #C9A861;
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* ── Chat panel */
.cw-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 340px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cwSlideUp .22s ease-out;
}

@keyframes cwSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header */
.cw-header {
  background: #0E7A4B;
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cw-header__info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cw-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.cw-header__name {
  font-weight: 700;
  font-size: .92rem;
}

.cw-header__sub {
  font-size: .72rem;
  opacity: .8;
  margin-top: 1px;
}

.cw-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: .9rem;
  opacity: .7;
  padding: 4px;
  transition: opacity .15s;
}

.cw-close:hover { opacity: 1; }

/* ── Message area */
.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}

.cw-messages::-webkit-scrollbar { width: 4px; }
.cw-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.cw-msg {
  display: flex;
}

.cw-msg--bot  { justify-content: flex-start; }
.cw-msg--user { justify-content: flex-end; }

.cw-bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: .83rem;
  line-height: 1.45;
}

.cw-bubble--bot {
  background: #f0f4f2;
  color: #1a2e25;
  border-bottom-left-radius: 4px;
}

.cw-bubble--user {
  background: #0E7A4B;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator */
.cw-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}

.cw-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0E7A4B;
  opacity: .5;
  animation: cwDot 1s ease-in-out infinite;
}

.cw-typing span:nth-child(2) { animation-delay: .18s; }
.cw-typing span:nth-child(3) { animation-delay: .36s; }

@keyframes cwDot {
  0%, 80%, 100% { transform: scale(.6); opacity: .3; }
  40%           { transform: scale(1);  opacity: 1; }
}

/* ── Quick replies */
.cw-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.cw-qr {
  background: #f0f4f2;
  border: 1px solid #c8ddd4;
  border-radius: 20px;
  color: #0E7A4B;
  font-size: .73rem;
  font-weight: 500;
  padding: 4px 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.cw-qr:hover {
  background: #0E7A4B;
  color: #fff;
  border-color: #0E7A4B;
}

/* ── Input row */
.cw-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

.cw-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: .83rem;
  line-height: 1.4;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 80px;
  overflow-y: auto;
  transition: border-color .15s;
}

.cw-input:focus {
  border-color: #0E7A4B;
}

.cw-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #0E7A4B;
  border: none;
  color: #fff;
  font-size: .85rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cw-send:hover:not(:disabled) {
  background: #0a6040;
}

.cw-send:disabled {
  background: #c4d9cf;
  cursor: default;
}

.cw-send:active:not(:disabled) {
  transform: scale(.9);
}

/* ── WhatsApp footer */
.cw-footer {
  padding: 8px 12px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.cw-wa-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #128C7E;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  padding: 6px;
  border-radius: 8px;
  transition: background .15s;
}

.cw-wa-link:hover {
  background: #f0faf8;
}

.cw-wa-icon { font-size: 1rem; }

/* ── Mobile adjustments */
@media (max-width: 480px) {
  .cw-root {
    bottom: 80px;
    right: 12px;
  }

  .cw-panel {
    width: calc(100vw - 24px);
    right: 0;
    bottom: 64px;
    max-height: 70vh;
  }
}
