/* ================================================
   TechByNafa – Live Chat Widget
   ================================================ */

:root {
  --chat-navy:   #0B0F1A;
  --chat-gold:   #D4AF37;
  --chat-orange: #E8952A;
  --chat-white:  #FFFFFF;
  --chat-gray:   #F3F4F6;
  --chat-radius: 18px;
  --chat-w:      360px;
  --chat-h:      500px;
}

/* ── Floating Button ──────────────────────────── */
.chat-widget {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1rem;
}

.chat-btn {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-navy) 0%, #1E2A3A 100%);
  border: 2px solid var(--chat-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.3), 0 0 0 0 rgba(212,175,55,.4);
  animation: chat-pulse 3s infinite;
  transition: transform .2s ease, box-shadow .2s ease;
  flex-shrink: 0;
}

.chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(0,0,0,.4), 0 0 0 8px rgba(212,175,55,.15);
}

.chat-btn i {
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--chat-gold), var(--chat-orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,.3), 0 0 0 0 rgba(212,175,55,.4); }
  50%       { box-shadow: 0 8px 32px rgba(0,0,0,.3), 0 0 0 10px rgba(212,175,55,.0); }
}

.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #EF4444;
  color: #fff;
  border-radius: 50%;
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--chat-white);
  font-family: 'Poppins', sans-serif;
}

.chat-badge.hidden { display: none; }

/* ── Chat Window ──────────────────────────────── */
.chat-window {
  width: var(--chat-w);
  height: var(--chat-h);
  background: var(--chat-white);
  border-radius: var(--chat-radius);
  box-shadow: 0 24px 80px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .25s ease;
  transform-origin: bottom right;
}

.chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ───────────────────────────────────── */
.chat-header {
  background: linear-gradient(135deg, var(--chat-navy) 0%, #1E2A3A 100%);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .85rem;
  flex-shrink: 0;
  position: relative;
}

.chat-avatar {
  position: relative;
  flex-shrink: 0;
}

.chat-av-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-gold), var(--chat-orange));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--chat-navy);
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
}

.chat-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #10B981;
  border-radius: 50%;
  border: 2px solid var(--chat-navy);
}

.chat-agent-info { flex: 1; min-width: 0; }

.chat-agent-name {
  font-family: 'Poppins', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  color: var(--chat-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-agent-status {
  font-size: .72rem;
  color: rgba(255,255,255,.5);
  margin-top: .1rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}

.chat-agent-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #10B981;
  border-radius: 50%;
  flex-shrink: 0;
}

.chat-close-btn {
  background: rgba(255,255,255,.1);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  color: rgba(255,255,255,.7);
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}

.chat-close-btn:hover { background: rgba(255,255,255,.2); color: var(--chat-white); }

.chat-wa-btn {
  background: rgba(37,211,102,.15);
  border: 1px solid rgba(37,211,102,.3);
  border-radius: 999px;
  padding: .25rem .65rem;
  font-size: .7rem;
  font-weight: 600;
  color: #25D366;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .3rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: background .2s;
}
.chat-wa-btn:hover { background: rgba(37,211,102,.25); }

/* ── Messages ─────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  scroll-behavior: smooth;
  background: #F9FAFB;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,.1); border-radius: 2px; }

.chat-msg {
  display: flex;
  gap: .5rem;
  max-width: 88%;
  animation: msgIn .25s ease;
}

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

.chat-msg.bot  { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-gold), var(--chat-orange));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  color: var(--chat-navy);
  font-weight: 700;
  flex-shrink: 0;
  align-self: flex-end;
}

.msg-bubble {
  padding: .65rem .9rem;
  border-radius: 14px;
  font-size: .875rem;
  line-height: 1.55;
  max-width: 100%;
  word-break: break-word;
}

.chat-msg.bot  .msg-bubble {
  background: var(--chat-white);
  color: #1F2937;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border: 1px solid rgba(0,0,0,.05);
}

.chat-msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--chat-navy), #1E2A3A);
  color: var(--chat-white);
  border-bottom-right-radius: 4px;
}

.msg-time {
  font-size: .65rem;
  color: rgba(0,0,0,.3);
  margin-top: .2rem;
  padding: 0 .3rem;
}
.chat-msg.user .msg-time { text-align: right; }

/* ── Typing indicator ─────────────────────────── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: .5rem;
  align-self: flex-start;
  animation: msgIn .2s ease;
}

.typing-bubble {
  background: var(--chat-white);
  border: 1px solid rgba(0,0,0,.05);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: .6rem .9rem;
  display: flex;
  align-items: center;
  gap: .3rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.typing-dot {
  width: 6px; height: 6px;
  background: #9CA3AF;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(1);    opacity: .5; }
  40%           { transform: scale(1.3);  opacity: 1; }
}

/* ── Quick Replies ────────────────────────────── */
.chat-quick-replies {
  padding: .5rem 1rem .75rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  background: #F9FAFB;
  border-top: 1px solid rgba(0,0,0,.05);
}

.chat-quick-replies:empty { display: none; }

.qr-chip {
  padding: .35rem .85rem;
  border-radius: 999px;
  border: 1.5px solid var(--chat-gold);
  background: transparent;
  color: #1F2937;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all .2s;
  white-space: nowrap;
}

.qr-chip:hover {
  background: linear-gradient(135deg, var(--chat-gold), var(--chat-orange));
  border-color: transparent;
  color: var(--chat-navy);
  transform: translateY(-1px);
}

/* ── Input Row ────────────────────────────────── */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid rgba(0,0,0,.06);
  background: var(--chat-white);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: .6rem .9rem;
  border: 1.5px solid rgba(0,0,0,.1);
  border-radius: 999px;
  font-family: 'Inter', sans-serif;
  font-size: .875rem;
  outline: none;
  background: #F9FAFB;
  color: #1F2937;
  transition: border-color .2s;
}

.chat-input:focus { border-color: var(--chat-gold); background: #fff; }
.chat-input::placeholder { color: #9CA3AF; }

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-gold), var(--chat-orange));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-navy);
  font-size: .9rem;
  flex-shrink: 0;
  transition: transform .2s, box-shadow .2s;
}

.chat-send-btn:hover { transform: scale(1.08); box-shadow: 0 4px 16px rgba(212,175,55,.4); }
.chat-send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ── WA redirect bar ──────────────────────────── */
.chat-wa-bar {
  background: rgba(37,211,102,.08);
  border-top: 1px solid rgba(37,211,102,.15);
  padding: .5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-size: .75rem;
  color: #065F46;
}

.chat-wa-bar a {
  color: #059669;
  font-weight: 600;
  text-decoration: underline;
}

/* ── Scroll-to-bottom button ──────────────────── */
.scroll-down-btn {
  position: absolute;
  bottom: 80px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--chat-navy);
  color: #fff;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

/* ── Admin notice ─────────────────────────────── */
.chat-admin-notice {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: rgba(212,175,55,.06);
  border: 1px solid rgba(212,175,55,.2);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  font-size: .875rem;
  color: #4B5563;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.chat-admin-notice i { margin-top: .15rem; flex-shrink: 0; }

.field-hint {
  font-size: .75rem;
  color: #9CA3AF;
  margin-top: .25rem;
  display: block;
}

/* ── Live agent link ──────────────────────────── */
.chat-live-link {
  padding: .5rem 1rem .6rem;
  background: #F9FAFB;
  border-top: 1px solid rgba(0,0,0,.05);
  text-align: center;
}

.lc-connect-btn {
  background: none;
  border: 1.5px solid rgba(212,175,55,.5);
  color: #6B7280;
  font-size: .75rem;
  font-weight: 600;
  padding: .3rem .9rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.lc-connect-btn:hover {
  background: linear-gradient(135deg, #D4AF37, #E8952A);
  border-color: transparent;
  color: #0B0F1A;
}

/* ── Live chat system messages ────────────────── */
.lc-sys-msg {
  align-self: center;
  text-align: center;
  animation: msgIn .25s ease;
}
.lc-sys-msg span {
  display: inline-block;
  background: rgba(0,0,0,.05);
  color: #6B7280;
  font-size: .72rem;
  padding: .25rem .75rem;
  border-radius: 999px;
}

/* ── Name prompt bubble ───────────────────────── */
.lc-name-bubble {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.lc-name-hint {
  display: block;
  color: rgba(0,0,0,.4);
  font-size: .75rem;
}
.lc-name-input {
  width: 100%;
  padding: .4rem .7rem;
  border: 1.5px solid rgba(0,0,0,.12);
  border-radius: 8px;
  font-size: .85rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  background: #fff;
  color: #1F2937;
  transition: border-color .2s;
}
.lc-name-input:focus { border-color: #D4AF37; }
.lc-start-btn {
  width: 100%;
  padding: .45rem .9rem;
  background: linear-gradient(135deg, #D4AF37, #E8952A);
  color: #0B0F1A;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: .85rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity .2s;
}
.lc-start-btn:hover { opacity: .9; }

/* ── Mobile ───────────────────────────────────── */
@media (max-width: 480px) {
  .chat-widget { bottom: 1.25rem; right: 1.25rem; }
  :root { --chat-w: calc(100vw - 2.5rem); --chat-h: 80vh; }
  .chat-window { border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
}
