/* Jet AI_2 Phase 1 — website chat widget (framework-free).
 * Design doc ch. 5: default 380x560, min 320x420, max 640x800.
 * Chat font scales with panel width: 15px at 380px, clamped 13-18px.
 * No "thinking..." bubble pattern anywhere: only a thin progress bar.
 */

.jetai-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: #1a365d;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  z-index: 2147483000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.jetai-panel {
  --jetai-scale: 1;
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 380px;
  height: 560px;
  min-width: 320px;
  min-height: 420px;
  max-width: min(640px, calc(100vw - 24px));
  max-height: min(800px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #d0d7e3;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  z-index: 2147483001;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}

.jetai-panel.jetai-hidden {
  display: none;
}

.jetai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px * var(--jetai-scale)) calc(12px * var(--jetai-scale));
  background: #1a365d;
  color: #fff;
  cursor: move;
  user-select: none;
  touch-action: none;
  flex-shrink: 0;
}

.jetai-header .jetai-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: calc(15px * var(--jetai-scale));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jetai-header select,
.jetai-header button {
  flex-shrink: 0;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: #fff;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: calc(13px * var(--jetai-scale));
}

.jetai-header select {
  width: auto;
  max-width: 120px;
}

.jetai-header select option {
  color: #000;
}

.jetai-progress {
  height: 2px;
  background: transparent;
  flex-shrink: 0;
}

.jetai-progress.jetai-active {
  background: linear-gradient(90deg, #3182ce, #63b3ed);
  background-size: 40% 100%;
  animation: jetai-slide 1s linear infinite;
}

@keyframes jetai-slide {
  from { background-position: 0 0; }
  to { background-position: 200% 0; }
}

.jetai-messages {
  flex: 1;
  overflow-y: auto;
  padding: calc(12px * var(--jetai-scale));
  display: flex;
  flex-direction: column;
  gap: calc(8px * var(--jetai-scale));
}

.jetai-msg {
  max-width: 85%;
  padding: calc(9px * var(--jetai-scale)) calc(12px * var(--jetai-scale));
  border-radius: 12px;
  font-size: clamp(13px, calc(15px * var(--jetai-scale)), 18px);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.jetai-msg.jetai-assistant {
  background: #edf2f7;
  color: #1a202c;
  align-self: flex-start;
}

.jetai-msg.jetai-user {
  background: #2b6cb0;
  color: #fff;
  align-self: flex-end;
}

.jetai-msg.jetai-system {
  background: #fffbeb;
  color: #744210;
  align-self: center;
  max-width: 95%;
  font-size: calc(13px * var(--jetai-scale));
}

.jetai-msg .jetai-time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.65;
}

.jetai-form {
  padding: calc(12px * var(--jetai-scale));
  display: flex;
  flex-direction: column;
  gap: calc(8px * var(--jetai-scale));
  overflow-y: auto;
  font-size: calc(14px * var(--jetai-scale));
}

.jetai-form label {
  font-weight: 600;
  color: #2d3748;
}

.jetai-form input,
.jetai-form select {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  font-size: calc(14px * var(--jetai-scale));
}

.jetai-form .jetai-row {
  display: flex;
  gap: 8px;
}

.jetai-form .jetai-row select {
  flex: 0 0 110px;
}

.jetai-form .jetai-messenger {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.jetai-form .jetai-messenger button {
  border: 1px solid #cbd5e0;
  background: #fff;
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: calc(13px * var(--jetai-scale));
}

.jetai-form .jetai-messenger button.jetai-selected {
  background: #2b6cb0;
  color: #fff;
  border-color: #2b6cb0;
}

/* First-screen messenger choice is a radio group (WeChat / LINE /
   KakaoTalk / other), styled like the old buttons. */
.jetai-form .jetai-messenger label {
  border: 1px solid #cbd5e0;
  background: #fff;
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: calc(13px * var(--jetai-scale));
}

.jetai-form .jetai-messenger label.jetai-selected {
  background: #2b6cb0;
  color: #fff;
  border-color: #2b6cb0;
}

.jetai-form .jetai-error {
  color: #c53030;
  font-size: calc(12px * var(--jetai-scale));
}

.jetai-form .jetai-consent {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: calc(12px * var(--jetai-scale));
  color: #4a5568;
}

.jetai-form .jetai-consent input {
  width: auto;
  margin-top: 2px;
}

.jetai-primary {
  background: #2b6cb0;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  font-size: calc(14px * var(--jetai-scale));
}

.jetai-inputbar {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: calc(8px * var(--jetai-scale));
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.jetai-inputbar input[type="text"] {
  flex: 1;
  border: 1px solid #cbd5e0;
  border-radius: 20px;
  padding: 8px 12px;
  font-size: calc(14px * var(--jetai-scale));
  min-width: 0;
}

.jetai-iconbtn {
  width: calc(36px * var(--jetai-scale));
  height: calc(36px * var(--jetai-scale));
  min-width: 32px;
  min-height: 32px;
  border: 1px solid #cbd5e0;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

.jetai-iconbtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.jetai-iconbtn.jetai-recording {
  background: #feb2b2;
  border-color: #e53e3e;
}

.jetai-sendbtn {
  background: #2b6cb0;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: calc(14px * var(--jetai-scale));
  flex-shrink: 0;
}

.jetai-phonebar {
  padding: 0 calc(8px * var(--jetai-scale)) calc(8px * var(--jetai-scale));
  flex-shrink: 0;
}

.jetai-phonebtn {
  width: 100%;
  background: #ebf8ff;
  color: #2b6cb0;
  border: 1px solid #bee3f8;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font-size: calc(13px * var(--jetai-scale));
}

/* Resize handles: top edge, left edge, top-left corner (panel is
 * anchored bottom-right, so dragging pulls from the opposite side). */
.jetai-resize {
  position: absolute;
  z-index: 2;
}

.jetai-resize-n {
  top: 0;
  left: 12px;
  right: 12px;
  height: 8px;
  cursor: ns-resize;
  touch-action: none;
}

.jetai-resize-w {
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 8px;
  cursor: ew-resize;
  touch-action: none;
}

.jetai-resize-nw {
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  touch-action: none;
}

/* Mobile: fullscreen, no resize handles (design doc ch. 5.2). */
@media (max-width: 480px) {
  .jetai-panel {
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }

  .jetai-resize {
    display: none;
  }
}
