/* ============================================================
   SR 홈페이지 상담창구 위젯  2026-08-28
   우측 하단 고정. 홈페이지 본문 스타일과 섞이지 않도록 srcw- 접두어만 쓴다.
   ============================================================ */

.srcw {
  --srcw-blue:  #1d4ed8;
  --srcw-blue2: #2563eb;
  --srcw-ink:   #111827;
  --srcw-sub:   #6b7280;
  --srcw-line:  #e5e7eb;
  --srcw-bg:    #f7f8fa;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99000;
  font-family: 'Inter', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
  color: var(--srcw-ink);
}

/* ---------- 버블 ---------- */
.srcw-bubble {
  position: relative;
  width: 60px; height: 60px;
  border: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--srcw-blue2), var(--srcw-blue));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(29, 78, 216, .38);
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
}
.srcw-bubble:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 34px rgba(29, 78, 216, .46); }
.srcw-bubble:active { transform: scale(.97); }
.srcw-bubble svg { width: 26px; height: 26px; }
.srcw-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.srcw-tip {
  position: absolute; right: 74px; bottom: 12px;
  background: #fff; color: var(--srcw-ink);
  padding: 10px 14px; border-radius: 12px;
  font-size: 13px; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  border: 1px solid var(--srcw-line);
  animation: srcw-in .25s ease;
}
.srcw-tip button {
  border: 0; background: none; color: var(--srcw-sub);
  cursor: pointer; margin-left: 8px; font-size: 14px; line-height: 1;
}

/* ---------- 패널 ---------- */
.srcw-panel {
  position: absolute; right: 0; bottom: 76px;
  width: 380px; height: 560px; max-height: calc(100vh - 120px);
  background: #fff; border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .26);
  border: 1px solid var(--srcw-line);
  display: flex; flex-direction: column; overflow: hidden;
  animation: srcw-in .22s ease;
}
@keyframes srcw-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.srcw-head {
  background: linear-gradient(135deg, var(--srcw-blue2), var(--srcw-blue));
  color: #fff; padding: 16px 18px; flex-shrink: 0;
  display: flex; align-items: flex-start; gap: 10px;
}
.srcw-head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.srcw-head p  { margin: 3px 0 0; font-size: 11.5px; opacity: .85; }
.srcw-head .srcw-x {
  margin-left: auto; background: rgba(255,255,255,.16); border: 0; color: #fff;
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1;
  flex-shrink: 0;
}
.srcw-head .srcw-x:hover { background: rgba(255,255,255,.3); }
.srcw-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #34d399; margin-right: 5px; }
.srcw-dot.off { background: #fbbf24; }

/* ---------- 대화 ---------- */
.srcw-body {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  background: var(--srcw-bg);
  display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain;
}
.srcw-body::-webkit-scrollbar { width: 6px; }
.srcw-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

.srcw-msg { display: flex; flex-direction: column; max-width: 84%; }
.srcw-msg.me { align-self: flex-end; align-items: flex-end; }
.srcw-msg.them { align-self: flex-start; }
.srcw-who { font-size: 11px; color: var(--srcw-sub); margin: 0 4px 3px; }
.srcw-txt {
  padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.62;
  white-space: pre-wrap; word-break: break-word;
}
.srcw-msg.them .srcw-txt { background: #fff; border: 1px solid var(--srcw-line); border-bottom-left-radius: 4px; }
.srcw-msg.bot  .srcw-txt { background: #fff; border: 1px solid #dbeafe; border-bottom-left-radius: 4px; }
.srcw-msg.me   .srcw-txt { background: var(--srcw-blue2); color: #fff; border-bottom-right-radius: 4px; }
.srcw-time { font-size: 10.5px; color: #9ca3af; margin: 3px 4px 0; }

.srcw-sys {
  align-self: center; font-size: 11.5px; color: var(--srcw-sub);
  background: #eef2f7; padding: 5px 12px; border-radius: 999px;
}

/* 빠른질문 */
.srcw-quick { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.srcw-quick button {
  text-align: left; background: #fff; border: 1px solid #c7d7fb; color: var(--srcw-blue);
  padding: 9px 13px; border-radius: 12px; font-size: 12.5px; cursor: pointer;
  transition: background .15s, transform .1s; font-family: inherit;
}
.srcw-quick button:hover { background: #eff5ff; }
.srcw-quick button:active { transform: scale(.985); }

/* 연락처 카드 */
.srcw-card {
  background: #fff; border: 1px solid var(--srcw-line); border-radius: 14px;
  padding: 14px; align-self: stretch;
}
.srcw-card h4 { margin: 0 0 4px; font-size: 13px; font-weight: 700; }
.srcw-card p  { margin: 0 0 10px; font-size: 11.5px; color: var(--srcw-sub); line-height: 1.55; }
.srcw-card input {
  width: 100%; box-sizing: border-box; margin-bottom: 7px;
  padding: 9px 11px; border: 1px solid var(--srcw-line); border-radius: 9px;
  font-size: 13px; font-family: inherit; color: var(--srcw-ink); background: #fff;
}
.srcw-card input:focus { outline: 2px solid #bfdbfe; outline-offset: -1px; border-color: var(--srcw-blue2); }
.srcw-card-btns { display: flex; gap: 6px; margin-top: 3px; }
.srcw-card-btns button { flex: 1; padding: 9px; border-radius: 9px; font-size: 12.5px; cursor: pointer; font-family: inherit; border: 1px solid var(--srcw-line); background: #fff; color: var(--srcw-sub); }
.srcw-card-btns button.p { background: var(--srcw-blue2); border-color: var(--srcw-blue2); color: #fff; font-weight: 600; }
.srcw-card-btns button:disabled { opacity: .6; cursor: default; }

/* 입력줄 */
.srcw-foot {
  border-top: 1px solid var(--srcw-line); background: #fff;
  padding: 10px; flex-shrink: 0;
}
.srcw-inrow { display: flex; align-items: flex-end; gap: 8px; }
.srcw-foot textarea {
  flex: 1; resize: none; border: 1px solid var(--srcw-line); border-radius: 12px;
  padding: 10px 12px; font-size: 13.5px; font-family: inherit; line-height: 1.5;
  max-height: 96px; min-height: 40px; color: var(--srcw-ink); background: #fff;
}
.srcw-foot textarea:focus { outline: 2px solid #bfdbfe; outline-offset: -1px; border-color: var(--srcw-blue2); }
.srcw-send {
  width: 40px; height: 40px; border: 0; border-radius: 12px; flex-shrink: 0;
  background: var(--srcw-blue2); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.srcw-send:disabled { background: #c3cede; cursor: default; }
.srcw-send svg { width: 17px; height: 17px; }
.srcw-note { font-size: 10.5px; color: #9ca3af; text-align: center; margin: 7px 2px 1px; line-height: 1.5; }

/* 진행표시 */
.srcw-spin {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: srcw-rot .7s linear infinite;
}
@keyframes srcw-rot { to { transform: rotate(360deg); } }
.srcw-typing { display: flex; gap: 4px; padding: 12px 14px; background: #fff; border: 1px solid var(--srcw-line); border-radius: 14px; border-bottom-left-radius: 4px; width: fit-content; }
.srcw-typing i { width: 6px; height: 6px; border-radius: 50%; background: #9ca3af; animation: srcw-bounce 1.2s infinite; }
.srcw-typing i:nth-child(2) { animation-delay: .18s; }
.srcw-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes srcw-bounce { 0%,60%,100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* 토스트 (시스템 alert 대체) */
.srcw-toast {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(17,24,39,.94); color: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: 12.5px; white-space: nowrap; box-shadow: 0 8px 22px rgba(0,0,0,.25);
  animation: srcw-in .2s ease; pointer-events: none;
}

/* 모바일 — 화면 전체 */
@media (max-width: 480px) {
  .srcw { right: 16px; bottom: 16px; }
  .srcw-panel {
    position: fixed; inset: 0; width: 100%; height: 100%;
    max-height: none; border-radius: 0; border: 0;
  }
  .srcw-tip { display: none; }
}

@media print { .srcw { display: none !important; } }
