/* AI 상담 챗봇 위젯 (신규, chat-server-v2 전용) */
#aichat-widget * { box-sizing: border-box; }
#aichat-widget {
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Malgun Gothic", sans-serif;
}

#aichat-toggle-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5b8bff 0%, #2f5fe0 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(47, 95, 224, 0.45);
  z-index: 9998;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
#aichat-toggle-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 26px rgba(47, 95, 224, 0.55);
}
#aichat-toggle-btn:active { transform: scale(0.96); }
#aichat-toggle-btn.aichat-hidden {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

#aichat-unread-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #ff4757;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(255,71,87,0.5);
}

#aichat-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(20, 30, 60, 0.25), 0 2px 8px rgba(20,30,60,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
#aichat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.aichat-header {
  background: linear-gradient(135deg, #5b8bff 0%, #2f5fe0 100%);
  color: #fff;
  padding: 18px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.aichat-header .aichat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.aichat-header .aichat-title-wrap { flex: 1; min-width: 0; }
.aichat-header .aichat-title { font-weight: 700; font-size: 15px; }
.aichat-header .aichat-subtitle { font-size: 12px; opacity: 0.85; margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.aichat-header .aichat-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 3px rgba(61,220,132,0.25); flex-shrink: 0; }
.aichat-header button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 18px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s ease;
}
.aichat-header button:hover { background: rgba(255,255,255,0.28); }

#aichat-login-screen {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: #667;
  background: #f8f9fc;
}
#aichat-login-screen .aichat-login-icon { font-size: 40px; }
#aichat-login-screen a {
  background: linear-gradient(135deg, #5b8bff 0%, #2f5fe0 100%);
  color: #fff;
  padding: 10px 24px;
  border-radius: 24px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(47,95,224,0.35);
}

#aichat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#aichat-messages::-webkit-scrollbar { width: 6px; }
#aichat-messages::-webkit-scrollbar-thumb { background: #d8dde8; border-radius: 3px; }

.aichat-msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 88%; }
.aichat-msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.aichat-msg-row.ai, .aichat-msg-row.admin { align-self: flex-start; }

.aichat-avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e8edff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.aichat-msg-row.admin .aichat-avatar-sm { background: #fff3e0; }

.aichat-msg {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(20,30,60,0.06);
}
.aichat-msg.user { background: linear-gradient(135deg, #5b8bff 0%, #2f5fe0 100%); color: #fff; border-bottom-right-radius: 4px; }
.aichat-msg.ai, .aichat-msg.admin { background: #fff; border: 1px solid #ececf3; border-bottom-left-radius: 4px; }
.aichat-msg.admin { border-color: #ffd9a0; }
.aichat-msg-sender { font-size: 11px; color: #9aa0ac; margin-bottom: 3px; font-weight: 600; }
.aichat-msg a { color: inherit; text-decoration: underline; }

#aichat-typing {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 16px 6px;
  color: #9aa0ac;
  font-size: 12px;
}
#aichat-typing .aichat-dots { display: inline-flex; gap: 3px; }
#aichat-typing .aichat-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: #b7bccb;
  animation: aichat-bounce 1.2s infinite ease-in-out;
}
#aichat-typing .aichat-dots span:nth-child(2) { animation-delay: 0.15s; }
#aichat-typing .aichat-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aichat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

#aichat-inquiry-confirm {
  display: none;
  margin: 8px 16px 0;
  padding: 8px 12px;
  background: #eafaf0;
  color: #1c8a4b;
  border: 1px solid #bfe9cf;
  border-radius: 10px;
  font-size: 12.5px;
  text-align: center;
  flex-shrink: 0;
}

#aichat-inquiry-bar {
  padding: 8px 16px;
  border-top: 1px solid #eef0f5;
  text-align: center;
  flex-shrink: 0;
}
#aichat-inquiry-bar button {
  background: none;
  border: none;
  color: #2f5fe0;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
#aichat-inquiry-bar button:hover { text-decoration: underline; }
#aichat-inquiry-bar button + button { margin-left: 14px; }

#aichat-inquiry-list {
  display: none;
  max-height: 240px;
  overflow-y: auto;
  padding: 10px 16px;
  border-top: 1px solid #eef0f5;
  background: #fbfbfe;
  flex-shrink: 0;
}
#aichat-inquiry-list.open { display: block; }
#aichat-inquiry-list-toggle.open { color: #1c3fa0; }
#aichat-inquiry-list-toggle .aichat-chevron { display: inline-block; transition: transform 0.15s ease; margin-left: 3px; }
#aichat-inquiry-list-toggle.open .aichat-chevron { transform: rotate(180deg); }
.aichat-inquiry-list-loading, .aichat-inquiry-list-empty {
  text-align: center;
  color: #9aa0ac;
  font-size: 12.5px;
  padding: 12px 0;
}
.aichat-inquiry-card {
  background: #fff;
  border: 1px solid #ececf3;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 12.5px;
}
.aichat-inquiry-card:last-child { margin-bottom: 0; }
.aichat-inquiry-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.aichat-inquiry-status { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.aichat-inquiry-status.pending { background: #fff2e0; color: #c77700; }
.aichat-inquiry-status.answered { background: #e0f7e9; color: #1c8a4b; }
.aichat-inquiry-date { color: #b0b5c0; font-size: 11px; }
.aichat-inquiry-q { color: #333; line-height: 1.5; }
.aichat-inquiry-a {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e5e8f0;
  color: #2f5fe0;
  line-height: 1.5;
  display: flex;
  gap: 6px;
}
.aichat-inquiry-a i { margin-top: 2px; flex-shrink: 0; }
.aichat-inquiry-delete-btn {
  margin-top: 8px;
  background: none;
  border: none;
  color: #c94f4f;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  opacity: 0.75;
}
.aichat-inquiry-delete-btn:hover { opacity: 1; text-decoration: underline; }

#aichat-inquiry-form {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid #eef0f5;
  background: #fbfbfe;
  flex-shrink: 0;
}
#aichat-inquiry-form textarea {
  resize: none; height: 70px; padding: 10px; border: 1px solid #e0e3ec; border-radius: 10px; font-size: 13px;
}
#aichat-inquiry-form textarea:focus { outline: none; border-color: #5b8bff; }

.aichat-file-row { display: flex; align-items: center; gap: 10px; }
#aichat-inquiry-form #aichat-file-pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 16px;
  border: 1px solid #d9dfef;
  background: #fff;
  color: #445;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  flex: none;
  width: auto;
  transition: border-color 0.15s ease, color 0.15s ease;
}
#aichat-inquiry-form #aichat-file-pick-btn:hover { border-color: #5b8bff; color: #2f5fe0; }
#aichat-file-selected { font-size: 12px; color: #8a90a0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#aichat-inquiry-form .row { display: flex; gap: 8px; }
#aichat-inquiry-form button { flex: 1; padding: 9px; border-radius: 10px; border: none; cursor: pointer; font-weight: 600; font-size: 13px; }
#aichat-inquiry-submit { background: linear-gradient(135deg, #5b8bff 0%, #2f5fe0 100%); color: #fff; }
#aichat-inquiry-cancel { background: #eceef4; color: #555; }

#aichat-banner-area {
  display: none;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 1;
  overflow: hidden;
  flex-shrink: 0;
  background: #eef1f7;
}
.aichat-banner-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  display: block;
}
.aichat-banner-slide.active { opacity: 1; }
.aichat-banner-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.aichat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid #eef0f5;
  flex-shrink: 0;
  background: #fff;
}
.aichat-input-area textarea {
  flex: 1;
  resize: none;
  height: 42px;
  max-height: 90px;
  padding: 10px 14px;
  border: 1px solid #e0e3ec;
  border-radius: 20px;
  font-size: 14px;
  background: #f4f5f9;
}
.aichat-input-area textarea:focus { outline: none; border-color: #5b8bff; background: #fff; }
.aichat-input-area button {
  background: linear-gradient(135deg, #5b8bff 0%, #2f5fe0 100%);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 16px;
  box-shadow: 0 3px 10px rgba(47,95,224,0.35);
  transition: transform 0.15s ease;
}
.aichat-input-area button:hover { transform: scale(1.06); }
.aichat-input-area button:active { transform: scale(0.94); }

#aichat-closed-msg { text-align: center; padding: 16px; color: #9aa0ac; font-size: 13px; display: none; flex-shrink: 0; }

@media (max-width: 480px) {
  #aichat-panel { right: 12px; left: 12px; width: auto; bottom: 88px; }
  #aichat-toggle-btn { right: 16px; bottom: 16px; }
}
