/* ═══════════════════════════════════════════════════════════
   SW중심대학사업단 챗봇 위젯 — Paper Lab Design System
   ═══════════════════════════════════════════════════════════ */

/* ───── Design Tokens ───── */
:root {
  --bg-base:       #FAFAFA;
  --bg-sidebar:    #F5F5F5;
  --bg-card:       #FFFFFF;
  --bg-hover-row:  #F2F2F4;
  --border:        #EAEAEA;
  --border-strong: #D4D4D8;

  --text-primary:   #0F0F10;
  --text-secondary: #3F3F46;
  --text-muted:     #737373;
  --text-disabled:  #A1A1AA;

  --accent-blue:        #4F46E5;
  --accent-blue-bg:     rgba(79, 70, 229, 0.08);
  --accent-green:       #16A34A;
  --accent-green-bg:    rgba(22, 163, 74, 0.10);
  --accent-red:         #DC2626;
  --accent-red-bg:      rgba(220, 38, 38, 0.08);

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px;
  --radius-xl: 10px; --radius-pill: 999px;

  --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.04);
  --shadow-ring-focus: 0 0 0 3px rgba(79, 70, 229, 0.16);

  --dur-fast: 120ms; --dur-base: 180ms; --dur-slow: 260ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ───── FAB (closed state) ───── */
#swuniv-chatbot-root, #swuniv-chatbot-root * { box-sizing: border-box; }

.fab {
  position: fixed;
  right: 24px; bottom: 24px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 16px 12px 14px;
  background: var(--accent-blue);
  color: #fff;
  border: 0;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  box-shadow: 0 12px 28px -8px rgba(79, 70, 229, 0.45), 0 4px 8px rgba(15, 23, 42, 0.06);
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
  z-index: 50;
}
.fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px -8px rgba(79, 70, 229, 0.55), 0 4px 8px rgba(15, 23, 42, 0.08);
}
.fab svg { display: inline-flex; opacity: 0.95; }
.fab__label { white-space: nowrap; }

/* ───── Panel shell ───── */
.panel {
  position: fixed;
  right: 24px; bottom: 24px;
  width: 384px;
  height: min(640px, calc(100vh - 48px));
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--text-primary);
  z-index: 50;
  animation: panel-in var(--dur-slow) var(--ease-out);
}
.panel[hidden] { display: none; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ───── Header ───── */
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}
.panel__head-left { display: flex; align-items: center; gap: 10px; }
.panel__logo {
  width: 32px; height: 32px;
  border-radius: var(--radius-lg);
  background: var(--accent-blue);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.panel__title {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  letter-spacing: -0.01em;
}
.panel__status {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
}
.panel__head-right { display: flex; gap: 2px; }

.iconbtn {
  width: 28px; height: 28px;
  border: 0; border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.iconbtn:hover { background: var(--bg-hover-row); color: var(--text-primary); }

/* ───── Body ───── */
.panel__body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  background: var(--bg-base);
}
.panel__body::-webkit-scrollbar { width: 8px; }
.panel__body::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: var(--radius-pill);
}
.panel__body::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ───── Messages ───── */
.messages { padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 14px; }

.msg { display: flex; gap: 8px; }
.msg--user { justify-content: flex-end; }
.msg--bot  { justify-content: flex-start; }
.msg__col  { display: flex; flex-direction: column; gap: 6px; max-width: 86%; }

.bot-avatar {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--accent-blue);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 2px;
}

.bubble {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px; line-height: 1.55;
  letter-spacing: -0.005em;
  word-break: break-word;
  white-space: pre-wrap;
}
.bubble--user {
  background: var(--accent-blue);
  color: #fff;
  border-bottom-right-radius: 4px;
  max-width: 80%;
}
.bubble--bot {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.bubble--typing {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 12px 14px;
}

.quick-faqs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.quick-faq {
  min-height: 30px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  white-space: normal;
  word-break: keep-all;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.quick-faq:hover {
  border-color: var(--accent-blue);
  background: var(--accent-blue-bg);
  color: var(--accent-blue);
}
.quick-faq:focus-visible {
  outline: 0;
  box-shadow: var(--shadow-ring-focus);
}

.dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-muted);
  animation: dot-bounce 1.2s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-3px); opacity: 1; }
}

/* ───── Sources ───── */
.sources { margin-top: 4px; }
.sources__label {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.sources__grid { display: flex; flex-direction: column; gap: 6px; }

.source-card {
  display: block;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none; color: inherit;
  transition: border-color var(--dur-fast), background var(--dur-fast);
  cursor: pointer;
}
.source-card:hover {
  border-color: var(--accent-blue);
  background: var(--accent-blue-bg);
}
.source-card__head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
}
.source-card__num {
  width: 16px; height: 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-blue-bg);
  color: var(--accent-blue);
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.source-card__cat {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  flex: 1;
}
.source-card__ext { color: var(--text-muted); }
.source-card__title {
  font-size: 12.5px; font-weight: 500; color: var(--text-primary);
  line-height: 1.4;
}
.source-card__id {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--text-muted);
  margin-top: 2px;
}

/* ───── Error ───── */
.errstate {
  margin: 8px 14px;
  padding: 10px 12px;
  background: var(--accent-red-bg);
  border: 1px solid var(--accent-red);
  border-radius: var(--radius-lg);
  font-size: 12.5px;
  color: var(--accent-red);
  display: flex; align-items: center; gap: 8px;
}

/* ───── Composer ───── */
.panel__foot {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  padding: 10px 12px;
  flex-shrink: 0;
}
.composer {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 4px 4px 4px 10px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.composer:focus-within {
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-ring-focus);
}
.composer__input {
  flex: 1;
  border: 0; outline: 0; background: transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  padding: 6px 0;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}
.composer__input::placeholder { color: var(--text-muted); }
.composer__send {
  width: 30px; height: 30px;
  border: 0; border-radius: 7px;
  background: var(--accent-blue);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast), opacity var(--dur-fast);
  flex-shrink: 0;
}
.composer__send:disabled { background: var(--text-disabled); cursor: not-allowed; }
.composer__send:not(:disabled):hover { background: #4338CA; }

.panel__legal {
  font-size: 10px; color: var(--text-muted);
  margin-top: 6px; padding: 0 4px;
  text-align: center; letter-spacing: -0.005em;
}

/* ───── Mobile ───── */
@media (max-width: 480px) {
  .panel {
    inset: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    border-radius: 0; border: 0;
  }
  .fab__label { display: none; }
  .fab { padding: 12px; border-radius: 50%; }
}