/* ============ AI CHAT WIDGET ============ */
.chat-widget { position: fixed; bottom: 24px; right: 24px; z-index: 9999; }

.chat-toggle {
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #138BC1, #213F8E); color: #fff;
  box-shadow: 0 8px 26px rgba(19,139,193,0.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.3s, box-shadow 0.3s; position: relative;
}
.chat-toggle::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(19,139,193,0.45); animation: chatRing 2.6s infinite;
}
@keyframes chatRing { 0% { box-shadow: 0 0 0 0 rgba(19,139,193,0.45); } 70%, 100% { box-shadow: 0 0 0 16px rgba(19,139,193,0); } }
.chat-toggle:hover { transform: scale(1.08); box-shadow: 0 10px 34px rgba(19,139,193,0.55); }
.chat-toggle.open { background: linear-gradient(135deg, #213F8E, #161829); }
.chat-toggle.open::before { animation: none; }
.chat-toggle.open .chat-icon-open { display: none; }
.chat-toggle.open .chat-icon-close { display: block !important; }
.chat-toggle svg { position: relative; z-index: 1; }

.chat-window {
  position: absolute; bottom: 78px; right: 0; width: 408px;
  height: 640px; max-height: calc(100vh - 110px);
  background: #ffffff; border: 1px solid #E2E6EC; border-radius: 20px;
  box-shadow: 0 28px 70px rgba(22,24,41,0.28); display: none; flex-direction: column;
  overflow: hidden; animation: chatSlideUp 0.32s cubic-bezier(0.16,1,0.3,1);
}
.chat-window.open { display: flex; }
@keyframes chatSlideUp { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Branded gradient header with the NEC logo mark */
.chat-header {
  padding: 1.15rem 1.35rem;
  background: linear-gradient(135deg, #161829 0%, #213F8E 58%, #138BC1 100%);
  position: relative; overflow: hidden;
}
.chat-header::after {
  content: ''; position: absolute; top: -55%; right: -12%;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37,195,94,0.30), transparent 68%);
}
.chat-header-info { display: flex; align-items: center; gap: 0.85rem; position: relative; z-index: 1; }
.chat-avatar {
  width: 46px; height: 46px; border-radius: 14px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  position: relative; flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(0,0,0,0.22);
}
.chat-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; display: block; }
.chat-avatar-dot {
  position: absolute; bottom: -2px; right: -2px; width: 13px; height: 13px;
  background: #25C35E; border-radius: 50%; border: 2.5px solid #fff; z-index: 1;
}
.chat-header-title { font-size: 1.02rem; font-weight: 700; color: #fff; line-height: 1.2; }
.chat-header-brand { font-weight: 500; color: rgba(255,255,255,0.6); }
.chat-header-status { font-size: 0.74rem; color: rgba(255,255,255,0.82); margin-top: 3px; display: flex; align-items: center; gap: 0.4rem; }
.chat-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #25C35E; box-shadow: 0 0 0 0 rgba(37,195,94,0.6); animation: chatPulse 2s infinite; flex-shrink: 0; }
@keyframes chatPulse { 0% { box-shadow: 0 0 0 0 rgba(37,195,94,0.6); } 70%, 100% { box-shadow: 0 0 0 6px rgba(37,195,94,0); } }

.chat-messages {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 1.25rem 1.35rem;
  display: flex; flex-direction: column; gap: 0.85rem;
  background: linear-gradient(180deg, #fbfdff, #ffffff);
}
.chat-bubble {
  max-width: 84%; padding: 0.8rem 1.05rem; border-radius: 16px;
  font-size: 0.92rem; line-height: 1.6; word-wrap: break-word;
}
.chat-bubble p { margin: 0; color: inherit; font-size: inherit; }
.chat-link { color: #138BC1; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.chat-link:hover { color: #0f6f9c; }
.chat-bubble-user .chat-link { color: #fff; }
.chat-bubble-user {
  background: linear-gradient(135deg, #138BC1, #213F8E); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 5px;
  box-shadow: 0 4px 14px rgba(19,139,193,0.25);
}
.chat-bubble-assistant {
  background: #fff; color: #5c5f6e; border: 1px solid #E2E6EC;
  align-self: flex-start; border-bottom-left-radius: 5px;
  box-shadow: 0 2px 10px rgba(22,24,41,0.05);
}
.chat-typing { display: flex; gap: 4px; padding: 0.8rem 1.05rem; align-self: flex-start; }
.chat-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #8b8e9c;
  animation: chatDot 1.4s infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDot { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.chat-input-area {
  padding: 0.85rem 1rem; border-top: 1px solid #E2E6EC;
  display: flex; gap: 0.6rem; align-items: center; background: #fff;
}
.chat-input {
  flex: 1; padding: 0.75rem 1.1rem; background: #F6FBFD;
  border: 1.5px solid #E2E6EC; border-radius: 50px;
  color: #161829; font-size: 0.92rem; outline: none; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.chat-input:focus { border-color: #138BC1; background: #fff; box-shadow: 0 0 0 3px rgba(19,139,193,0.12); }
.chat-input::placeholder { color: #8b8e9c; }
.chat-send {
  width: 42px; height: 42px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #138BC1, #213F8E); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(19,139,193,0.3);
}
.chat-send:hover { transform: scale(1.08); box-shadow: 0 6px 18px rgba(19,139,193,0.4); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* iOS Safari auto-zoom guard (portrait + landscape touch) */
@media (max-width: 768px) { .chat-input { font-size: 16px; } }
@media (hover: none) and (pointer: coarse) { .chat-input { font-size: 16px; } }

@media (max-width: 480px) {
  .chat-window { width: calc(100vw - 28px); right: -4px; bottom: 74px; height: 78vh; height: 78dvh; max-height: 78dvh; }
}
