/* ── พี่วิทย์ AI Chat Widget ── */

#pwit-arit-chat-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Sarabun', 'Noto Sans Thai', sans-serif;
}

/* ── FAB Toggle Button ── */
#pwit-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.4), 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

#pwit-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(6, 182, 212, 0.55), 0 2px 12px rgba(0,0,0,0.35);
}

#pwit-chat-fab svg {
  width: 28px;
  height: 28px;
  color: #fff;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#pwit-chat-fab .fab-icon-open  { display: block; }
#pwit-chat-fab .fab-icon-close { display: none; }
#pwit-chat-fab.is-open .fab-icon-open  { display: none; }
#pwit-chat-fab.is-open .fab-icon-close { display: block; }

/* Unread badge */
#pwit-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  display: none;
}

/* ── Chat Panel ── */
#pwit-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 99998;
  background: #0b0f19;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(6,182,212,0.1);
  transform: scale(0.9) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
  transform-origin: bottom right;
}

#pwit-chat-panel.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Panel Header ── */
#pwit-chat-header {
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(6,182,212,0.1));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.pwit-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.pwit-avatar svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pwit-status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #0b0f19;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.pwit-header-info {
  flex: 1;
  min-width: 0;
}

.pwit-header-title {
  font-size: 13px;
  font-weight: 800;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwit-header-subtitle {
  font-size: 10px;
  color: #06b6d4;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1px;
}

/* ── Header Buttons (fullscreen + close) ── */
#pwit-chat-fullscreen-btn,
#pwit-chat-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #94a3b8;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
}

#pwit-chat-fullscreen-btn:hover,
#pwit-chat-close-btn:hover {
  background: rgba(255,255,255,0.06);
  color: #f1f5f9;
}

#pwit-chat-fullscreen-btn svg,
#pwit-chat-close-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* toggle shrink icon */
#pwit-chat-fullscreen-btn .icon-shrink { display: none; }
#pwit-chat-fullscreen-btn.is-fullscreen .icon-expand { display: none; }
#pwit-chat-fullscreen-btn.is-fullscreen .icon-shrink { display: block; }

/* ── Fullscreen panel state ── */
#pwit-chat-panel.is-fullscreen {
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  transform: none !important;
}

/* ── iFrame ── */
#pwit-chat-iframe {
  width: 100%;
  flex: 1;
  border: none;
  display: block;
  background: #0b0f19;
  /* ซ่อน scrollbar ของ iframe ตัวเอง — ให้ Next.js จัดการ scroll ภายใน */
  overflow: hidden;
}

/* ── Mobile responsive ── */
@media (max-width: 480px) {
  #pwit-chat-panel {
    right: 0;
    bottom: 0;
    border-radius: 20px 20px 0 0;
    width: 100vw !important;
    height: 85vh !important;
  }

  #pwit-chat-fab {
    bottom: 16px;
    right: 16px;
  }
}
