/* =========================================================
   KSTA AI Chatbot — Shared UI (index + admin 양쪽)
   ========================================================= */

.chat-fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00d1ff, #38efc3);
  border: none;
  color: #031923;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 10px 32px rgba(0, 209, 255, 0.35);
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.chat-fab:hover { transform: scale(1.06); box-shadow: 0 14px 36px rgba(0,209,255,0.5); }
.chat-fab:active { transform: scale(0.95); }
.chat-fab.hidden { display: none; }

/* 펄스 애니메이션 (관심 유도) */
.chat-fab::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(0, 209, 255, 0.5);
  animation: chatFabPulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes chatFabPulse {
  0%   { transform: scale(1);    opacity: 0.8; }
  100% { transform: scale(1.5);  opacity: 0; }
}

.chat-panel {
  position: fixed;
  right: 14px;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  width: 360px;
  max-width: calc(100vw - 28px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: #0a192f;
  border: 1px solid rgba(0, 209, 255, 0.2);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.2s ease;
  color: #e6f1ff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
}
.chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(0,209,255,0.15), rgba(56,239,195,0.08));
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.95rem;
}
.chat-header-title .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #38efc3;
  box-shadow: 0 0 8px rgba(56,239,195,0.7);
}
.chat-header-sub {
  font-size: 0.7rem;
  color: rgba(230,241,255,0.55);
  font-weight: 500;
  margin-top: 2px;
}
.chat-header-actions {
  display: flex;
  gap: 4px;
}
.chat-header-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: rgba(230,241,255,0.6);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chat-header-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-welcome {
  text-align: center;
  padding: 12px 8px;
  color: rgba(230,241,255,0.68);
  font-size: 0.84rem;
  line-height: 1.6;
}
.chat-welcome .emoji {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 8px;
}
.chat-welcome .name {
  color: #00d1ff;
  font-weight: 800;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
}
.chat-suggestion {
  appearance: none;
  border: 1px solid rgba(0,209,255,0.28);
  background: rgba(0,209,255,0.08);
  color: #8cf5ff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chat-suggestion:hover {
  background: rgba(0,209,255,0.16);
  border-color: #00d1ff;
  color: #fff;
}

.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 100%;
}
.chat-msg.user { flex-direction: row-reverse; }
.chat-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
}
.chat-msg.assistant .chat-avatar {
  background: linear-gradient(135deg, #00d1ff, #38efc3);
  color: #031923;
}
.chat-msg.user .chat-avatar {
  background: rgba(255,255,255,0.08);
  color: rgba(230,241,255,0.8);
}
.chat-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  max-width: calc(100% - 40px);
}
.chat-msg.assistant .chat-bubble {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-top-left-radius: 4px;
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, rgba(0,209,255,0.25), rgba(56,239,195,0.18));
  border: 1px solid rgba(0,209,255,0.3);
  border-top-right-radius: 4px;
  color: #f0fbff;
}
.chat-bubble.error {
  background: rgba(255,95,95,0.12) !important;
  border-color: rgba(255,95,95,0.3) !important;
  color: #ffb5b5;
}
.chat-bubble code {
  background: rgba(0,0,0,0.28);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}
.chat-bubble a { color: #8cf5ff; }
.chat-bubble strong { color: #fff; }

/* 타이핑 인디케이터 */
.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 13px;
}
.chat-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(230,241,255,0.5);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.chat-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 10px 12px 12px;
}
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: rgba(2,12,27,0.6);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  line-height: 1.5;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s ease;
}
.chat-input:focus {
  border-color: rgba(0,209,255,0.5);
  box-shadow: 0 0 0 3px rgba(0,209,255,0.1);
}
.chat-input::placeholder { color: rgba(230,241,255,0.4); }

.chat-send-btn {
  appearance: none;
  background: linear-gradient(135deg, #00d1ff, #38efc3);
  color: #031923;
  border: none;
  width: 40px; height: 40px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, opacity 0.1s ease;
  flex: 0 0 auto;
}
.chat-send-btn:hover:not(:disabled) { transform: scale(1.05); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-admin-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.chat-admin-tool {
  appearance: none;
  background: rgba(255,184,77,0.1);
  border: 1px solid rgba(255,184,77,0.25);
  color: #ffb84d;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.chat-admin-tool:hover {
  background: rgba(255,184,77,0.2);
  border-color: #ffb84d;
}

.chat-info-text {
  font-size: 0.7rem;
  color: rgba(230,241,255,0.4);
  text-align: center;
  margin-top: 6px;
}

/* 모바일 — 전체 화면에 가깝게 */
@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - 16px);
    right: 8px;
    left: 8px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    height: min(560px, calc(100vh - 100px));
  }
  .chat-fab {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: 50px; height: 50px;
  }
}

/* 스크롤바 */
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 3px; }
.chat-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
