/* agent-on.css — V5.8 사용자 AI 비서 ON 위젯 전용 CSS.
   admin.css 디자인 토큰(--green·--line·--panel·--ink·--muted·--shadow-lg 등) 재사용.
   index.html이 admin.css·app.css와 함께 로드(별도 파일 — 회귀 격리).
   클래스 prefix: .aon-  (사용자 위젯 전용. 운영자 위젯은 admin/css/agent-on.css). */

/* 우하단 플로팅 버튼 — 하단 탭바 위(16px 간격)·safe-area 대응 */
.aon-fab {
  position: fixed;
  right: 16px;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  z-index: 1400;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--green, #1a8b46);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(26, 139, 70, .38), 0 2px 6px rgba(15, 23, 42, .18);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, box-shadow .15s ease;
}
.aon-fab:hover { transform: translateY(-2px) scale(1.04); }
.aon-fab:active { transform: scale(.96); }
.aon-fab.hidden { display: none; }
/* 안읽음/신규 응답 점 */
.aon-fab .aon-dot {
  position: absolute; top: 4px; right: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--danger, #dc2626); border: 2px solid #fff;
}

/* 채팅 모달 — 데스크탑 420×70vh, 모바일 전체화면 */
.aon-modal {
  position: fixed;
  right: 16px;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  z-index: 1401;
  width: 420px; max-width: calc(100vw - 32px);
  height: 70vh; max-height: 640px;
  background: var(--panel, #fff);
  border: 1px solid var(--line, #e6e9ee);
  border-radius: 16px;
  box-shadow: var(--shadow-lg, 0 18px 48px rgba(15, 23, 42, .20));
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: aon-pop .18s ease;
}
@keyframes aon-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ★ 모바일 (≤520px): 전체화면 / 탭바 위 FAB */
@media (max-width: 520px) {
  .aon-modal {
    right: 0; left: 0; bottom: 0; top: 0;
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: none;
    border-radius: 0; border: none;
  }
}

/* ★ 데스크탑 (>520px): app-shell(max-width:520px, centered) 기준 우하단 고정.
   app-shell 우측 끝 = 50vw + 260px → FAB/모달은 그 기준 16px 안쪽에 위치.
   right: calc(50% - 260px + 16px) = calc(50% - 244px) */
@media (min-width: 521px) {
  .aon-fab {
    right: calc(50% - 244px);
  }
  .aon-modal {
    right: calc(50% - 260px);
    max-width: 420px;
  }
}

.aon-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--green, #1a8b46) 0%, var(--green-d, #157038) 100%);
  color: #fff;
  flex: 0 0 auto;
}
.aon-head .aon-title { font-weight: 800; font-size: 15px; letter-spacing: -.2px; }
.aon-head .aon-sub { font-size: 11.5px; opacity: .85; }
.aon-head .aon-x {
  margin-left: auto; background: rgba(255, 255, 255, .16); border: none; color: #fff;
  width: 30px; height: 30px; border-radius: 8px; font-size: 18px; cursor: pointer; line-height: 1;
}
.aon-head .aon-x:hover { background: rgba(255, 255, 255, .28); }

.aon-msgs {
  flex: 1 1 auto; overflow-y: auto;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
  background: var(--bg, #f8fafc);
}
.aon-msg { max-width: 84%; padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.aon-msg.user { align-self: flex-end; background: var(--green, #1a8b46); color: #fff; border-bottom-right-radius: 4px; }
.aon-msg.assistant { align-self: flex-start; background: var(--panel, #fff); color: var(--ink, #1e293b); border: 1px solid var(--line, #e6e9ee); border-bottom-left-radius: 4px; }
.aon-msg.typing { color: var(--muted, #64748b); font-style: italic; }
/* 시스템 안내(인계 등) */
.aon-sys {
  align-self: center; max-width: 92%;
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
  border-radius: 10px; padding: 10px 12px; font-size: 12.5px; line-height: 1.55;
  text-align: center;
}
.aon-sys .aon-sys-btn { margin-top: 8px; }

/* function call 결과 카드(견적·내정보) */
.aon-card {
  align-self: flex-start; max-width: 92%;
  background: var(--panel, #fff); border: 1px solid var(--line, #e6e9ee);
  border-radius: 12px; padding: 12px 14px; font-size: 13px;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, .06));
}
.aon-card .aon-card-t { font-weight: 800; font-size: 13px; color: var(--green-d, #157038); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.aon-card .aon-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.aon-card .aon-row .k { color: var(--muted, #64748b); }
.aon-card .aon-row .v { font-weight: 700; color: var(--ink, #1e293b); }
.aon-card .aon-row.total { border-top: 1px dashed var(--line, #e6e9ee); margin-top: 6px; padding-top: 8px; }
.aon-card .aon-row.total .v { color: var(--green-d, #157038); font-size: 15px; }

.aon-input-row {
  flex: 0 0 auto; display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px; border-top: 1px solid var(--line, #e6e9ee);
  background: var(--panel, #fff);
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.aon-input-row textarea {
  flex: 1; resize: none; border: 1px solid var(--line, #e6e9ee); border-radius: 10px;
  padding: 9px 12px; font-size: 13.5px; font-family: inherit; line-height: 1.4;
  max-height: 96px; min-height: 40px; outline: none;
}
.aon-input-row textarea:focus { border-color: var(--green, #1a8b46); box-shadow: var(--ring, 0 0 0 3px rgba(26, 139, 70, .18)); }
.aon-input-row .aon-send {
  flex: 0 0 auto; height: 40px; padding: 0 16px; border: none; border-radius: 10px;
  background: var(--green, #1a8b46); color: #fff; font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.aon-input-row .aon-send:disabled { opacity: .5; cursor: default; }

/* ── V5.10 3 탭 (홈/대화/설정) ── */
.aon-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.aon-tabpanel { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.aon-tabpanel[hidden] { display: none; }
.aon-tabbar { display: flex; border-top: 1px solid var(--line, #e5e7eb); background: var(--panel, #fff); flex-shrink: 0; }
.aon-tabbtn { flex: 1; padding: 10px 6px; border: 0; background: transparent; cursor: pointer; font-size: 13px; color: var(--muted, #6b7280); border-top: 2px solid transparent; }
.aon-tabbtn.active { color: var(--green, #1a8b46); border-top-color: var(--green, #1a8b46); font-weight: 700; background: rgba(26,139,70,0.05); }
.aon-tabbtn:hover { background: rgba(0,0,0,0.03); }
.aon-loading, .aon-empty { padding: 24px 16px; text-align: center; color: var(--muted, #6b7280); font-size: 13px; }
.aon-conv-list { padding: 8px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.aon-conv-item { text-align: left; padding: 10px 12px; border: 1px solid var(--line, #e5e7eb); border-radius: 8px; background: var(--panel, #fff); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.aon-conv-item:hover { background: rgba(26,139,70,0.04); }
.aon-conv-preview { font-size: 13px; color: var(--ink, #111); line-height: 1.4; }
.aon-conv-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted, #6b7280); }
.aon-conv-tag { background: #fef3c7; color: #92400e; padding: 1px 6px; border-radius: 4px; }
.aon-conv-hist { padding: 12px; gap: 8px; }
.aon-settings { padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.aon-field { display: flex; flex-direction: column; gap: 4px; }
.aon-field label { font-size: 12px; color: var(--muted, #6b7280); font-weight: 600; }
.aon-field .inp { padding: 8px 10px; border: 1px solid var(--line, #e5e7eb); border-radius: 6px; font-size: 14px; }
.aon-field .inp:disabled { background: #f9fafb; color: #9ca3af; }
.aon-help { font-size: 11.5px; color: var(--muted, #6b7280); padding: 8px 10px; background: #f9fafb; border-radius: 6px; line-height: 1.45; }

/* V5.11.4 새 대화 버튼 */
.aon-home-bar { padding: 6px 12px; border-bottom: 1px solid var(--line, #e5e7eb); display: flex; justify-content: flex-end; flex-shrink: 0; background: var(--panel, #fff); }
.aon-newconv-btn { background: transparent; border: 1px solid var(--green, #1a8b46); color: var(--green, #1a8b46); border-radius: 12px; padding: 3px 10px; font-size: 11.5px; cursor: pointer; font-weight: 600; }
.aon-newconv-btn:hover { background: rgba(26,139,70,0.08); }

/* ── V5.13 추가 스타일 ── */
/* FAB 배지 (미읽은 proactive) — position:fixed는 상위 규칙 유지 (relative X·배지는 fixed 안에서 absolute OK) */
.aon-fab-badge { position: absolute; top: -4px; right: -4px; background: #ff4757; color: #fff; border-radius: 10px; min-width: 18px; height: 18px; font-size: 11px; line-height: 18px; text-align: center; padding: 0 5px; pointer-events: none; }

/* Proactive 카드 */
.aon-proactive { background: #fef9e7 !important; border-left: 3px solid #f39c12 !important; }
.aon-sys-title { font-weight: 700; font-size: 12.5px; margin-bottom: 3px; }
.aon-sys-body { font-size: 12.5px; }
.aon-sys-meta { font-size: 11px; color: var(--muted, #64748b); margin-top: 3px; }

/* 멀티턴 선택지 */
.aon-options { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
.aon-options .btn { font-size: 12.5px; padding: 4px 12px; }

/* 멀티턴 step indicator — V5.15: 시각 진행바 */
.aon-step { display: flex; align-items: center; justify-content: space-between; padding: 5px 12px; font-size: 11px; color: var(--muted, #666); background: #f1f5f9; border-radius: 6px; margin: 0 12px; }
.aon-step .btn { font-size: 11px; padding: 2px 8px; }
.aon-step-bar { display: flex; align-items: center; gap: 2px; }
.aon-step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line, #d1d5db); flex-shrink: 0; }
.aon-step-dot.done { background: var(--green, #1a8b46); }
.aon-step-dot.active { background: var(--green, #1a8b46); box-shadow: 0 0 0 3px rgba(26,139,70,.22); }
.aon-step-line { width: 14px; height: 2px; background: var(--line, #d1d5db); flex-shrink: 0; }
.aon-step-line.done { background: var(--green, #1a8b46); }
.aon-step-txt { font-size: 11px; color: var(--muted, #64748b); }

/* V5.15: 예시 질문 버튼 (매 새 대화마다 표시) */
.aon-example-wrap {
  padding: 8px 12px 4px;
  align-self: stretch;
}
.aon-example-label { font-size: 11.5px; color: var(--muted, #64748b); margin-bottom: 7px; font-weight: 600; }
.aon-example-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.aon-example-btn {
  font-size: 12.5px; padding: 6px 14px; border-radius: 20px;
  background: var(--panel, #fff);
  border: 1.5px solid rgba(26,139,70,.4);
  color: var(--green-d, #157038);
  cursor: pointer; font-weight: 600;
  transition: background .12s, transform .1s;
}
.aon-example-btn:hover { background: rgba(26,139,70,.08); transform: translateY(-1px); }

/* V5.15: 모바일 소형 화면 추가 최적화 (기존 520px 全面화면 보완) */
@media (max-width: 400px) {
  .aon-msg { font-size: 13px; padding: 8px 10px; }
  .aon-input-row textarea { font-size: 13px; }
  .aon-head .aon-title { font-size: 14px; }
  .aon-card { font-size: 12px; }
  .aon-tabbar .aon-tabbtn { font-size: 12px; padding: 8px 4px; }
}

/* 음성 버튼 */
.aon-voice { background: none; border: none; cursor: pointer; padding: 0 6px; font-size: 18px; line-height: 40px; opacity: .8; }
.aon-voice:hover { opacity: 1; }
