/* ==========================================================================
   함박마을 리빙랩 초저비용 5대 멀티 에이전트 Q&A & 관리자 관제 전용 스타일 (.aiq-*)
   KWCAG 2.2 (명도대비 4.5:1+, 초점 가시성, 터치 타겟, word-break: keep-all) 준수
   ========================================================================== */

.aiq-root,
.aiq-admin-root {
  word-break: keep-all;
}

.aiq-root :focus-visible,
.aiq-admin-root :focus-visible,
.aiq-fab :focus-visible,
.aiq-drawer :focus-visible {
  outline: 2.5px solid #1E5EFF !important;
  outline-offset: 2px !important;
}

/* ---------- 상단 모드 스위치 (대화형 AI 상담 | 공개 Q&A 아카이브) ---------- */
.aiq-mode-bar {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  background: #FFFFFF;
  border-bottom: 1px solid #E6EEF8;
}

.aiq-mode-tab {
  flex: 1;
  min-height: 40px;
  border: 1.5px solid #DCE8FA;
  background: #F7FAFF;
  color: #475569;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.16s ease;
}

.aiq-mode-tab[aria-selected="true"] {
  background: #1E5EFF;
  border-color: #1E5EFF;
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(30, 94, 255, 0.22);
}

/* ---------- 실시간 에이전트 진행 단계 스테퍼 ---------- */
.aiq-stepper-card {
  background: #FFFFFF;
  border: 1.5px solid #CFE1FF;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(30, 94, 255, 0.08);
  max-width: 94%;
}

.aiq-stepper-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #1E5EFF;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.aiq-spinner {
  width: 14px;
  height: 14px;
  border: 2.2px solid #CFE1FF;
  border-top-color: #1E5EFF;
  border-radius: 50%;
  animation: aiq-spin 0.75s linear infinite;
}

@keyframes aiq-spin {
  to { transform: rotate(360deg); }
}

.aiq-step-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.aiq-step-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #64748B;
}

.aiq-step-row.is-active {
  color: #1E3A8A;
  font-weight: 700;
}

.aiq-step-row.is-done {
  color: #0F766E;
  font-weight: 600;
}

.aiq-step-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #E2E8F0;
  color: #475569;
  flex-shrink: 0;
}

.aiq-step-row.is-active .aiq-step-dot {
  background: #1E5EFF;
  color: #FFFFFF;
}

.aiq-step-row.is-done .aiq-step-dot {
  background: #CCFBF1;
  color: #0F766E;
}

/* ---------- 상태별 주민 응답 카드 (ANSWERED / PENDING_LEARNING / BLOCKED_POLICY) ---------- */
.aiq-res-card {
  width: 100%;
  max-width: 95%;
  background: #FFFFFF;
  border: 1.5px solid #E2ECF9;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.05);
}

.aiq-res-card.status-PENDING_LEARNING {
  background: #FFFBEB;
  border-color: #FCD34D;
}

.aiq-res-card.status-BLOCKED_POLICY {
  background: #FEF2F2;
  border-color: #FCA5A5;
}

.aiq-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.aiq-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.aiq-badge-answered {
  background: #E8F1FF;
  color: #1648CE;
}

.aiq-badge-cache {
  background: #ECFDF5;
  color: #047857;
}

.aiq-badge-compound {
  background: #F3E8FF;
  color: #6B21A8;
}

.aiq-badge-pending {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #F59E0B;
}

.aiq-badge-blocked {
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #F87171;
}

.aiq-badge-pivot {
  background: #F0F9FF;
  color: #0369A1;
  border: 1px solid #BAE6FD;
}

/* 외국인 주민 현장 제시용 한국어 문장 카드 (Show-to-Clerk / Taxi Card) */
.aiq-action-card {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #EFF6FF;
  border: 1.5px solid #93C5FD;
}

.aiq-action-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.aiq-action-card-title {
  font-size: 11.5px;
  font-weight: 800;
  color: #1E40AF;
}

.aiq-action-phrase {
  font-size: 15px;
  font-weight: 800;
  color: #0F172A;
  background: #FFFFFF;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid #BFDBFE;
}

.aiq-action-addr {
  font-size: 12px;
  color: #1E3A8A;
  margin-top: 6px;
  font-weight: 600;
}

.aiq-answer-body {
  font-size: 14px;
  line-height: 1.65;
  color: #1E293B;
  word-break: keep-all;
}

.aiq-res-card.status-BLOCKED_POLICY .aiq-answer-body {
  color: #991B1B;
  font-weight: 700;
}

.aiq-res-card.status-PENDING_LEARNING .aiq-answer-body {
  color: #78350F;
  font-weight: 600;
}

.aiq-sub-note {
  margin-top: 8px;
  font-size: 12px;
  color: #475569;
  line-height: 1.5;
}

/* 출처 및 담당 부서 배지 박스 */
.aiq-sources-box {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #DCE6F5;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.aiq-source-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #334155;
}

.aiq-dept-pill {
  background: #F1F5F9;
  color: #1E293B;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11.5px;
  font-weight: 700;
}

.aiq-code-pill {
  background: #E8F1FF;
  color: #1648CE;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
}

/* 연관 추천 질문 칩 2개 */
.aiq-followup-box {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #EEF3FA;
}

.aiq-followup-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

.aiq-followup-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.aiq-followup-chip {
  text-align: start;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #CFE1FF;
  background: #F8FBFF;
  color: #1648CE;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.aiq-followup-chip:hover {
  background: #E8F1FF;
}

/* 원클릭 피드백 바 */
.aiq-feedback-bar {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #EEF3FA;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.aiq-feedback-prompt {
  font-size: 12px;
  color: #475569;
  font-weight: 600;
}

.aiq-feedback-btns {
  display: flex;
  gap: 6px;
}

.aiq-fb-btn {
  min-height: 34px;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.aiq-fb-btn.active-helpful {
  background: #ECFDF5;
  border-color: #10B981;
  color: #047857;
  font-weight: 700;
}

.aiq-fb-btn.active-improve {
  background: #FFF7ED;
  border-color: #F97316;
  color: #C2410C;
  font-weight: 700;
}

/* ---------- 공개 Q&A 아카이브 ---------- */
.aiq-archive-wrap {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
}

.aiq-filter-card {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 14px;
  border: 1px solid #E6EEF8;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aiq-search-row {
  display: flex;
  gap: 8px;
}

.aiq-search-input {
  flex: 1;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  font-size: 13.5px;
}

.aiq-select-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.aiq-select {
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  background: #FFFFFF;
  font-size: 13px;
}

.aiq-archive-card {
  background: #FFFFFF;
  border: 1px solid #E2ECF9;
  border-radius: 16px;
  padding: 15px;
  box-shadow: 0 3px 12px rgba(30, 94, 255, 0.05);
}

.aiq-archive-q {
  font-size: 14.5px;
  font-weight: 700;
  color: #0F172A;
  margin: 6px 0 8px;
}

/* ---------- 비챗봇 탭 플로팅 AI 질문 위젯 & 미니 드로어 ---------- */
.aiq-fab {
  position: fixed;
  right: 20px;
  bottom: 84px;
  z-index: 95;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #1E5EFF 0%, #1549D6 100%);
  color: #FFFFFF;
  font-size: 13.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(30, 94, 255, 0.34);
  transition: transform 0.16s ease, bottom 0.2s ease;
}

.aiq-fab:hover {
  transform: translateY(-2px);
}

.aiq-fab.shifted-up {
  bottom: 138px;
}

.aiq-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 160;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.aiq-drawer-backdrop.open {
  display: flex;
}

.aiq-drawer {
  width: 100%;
  max-width: 460px;
  max-height: 82dvh;
  background: #F8FBFF;
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.aiq-drawer-head {
  background: #1E5EFF;
  color: #FFFFFF;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.aiq-drawer-body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aiq-drawer-form {
  padding: 10px 12px;
  background: #FFFFFF;
  border-top: 1px solid #E2ECF9;
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   관리자 콘솔 (/admin) 멀티 에이전트 관제 전용 스타일
   ========================================================================== */
.aiq-admin-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.aiq-subtab-btn {
  min-height: 40px;
  padding: 9px 15px;
  border-radius: 12px;
  border: 1.5px solid #DCE8FA;
  background: #FFFFFF;
  color: #475569;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.aiq-subtab-btn[aria-selected="true"] {
  background: #1E5EFF;
  border-color: #1E5EFF;
  color: #FFFFFF;
}

.aiq-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.aiq-kpi-card {
  background: #FFFFFF;
  border: 1px solid #E2ECF9;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 4px 14px rgba(30, 94, 255, 0.06);
}

.aiq-kpi-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #475569;
}

.aiq-kpi-val {
  font-size: 25px;
  font-weight: 800;
  color: #0F172A;
  margin-top: 6px;
}

.aiq-kpi-sub {
  font-size: 12px;
  color: #64748B;
  margin-top: 4px;
}

.aiq-cluster-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
}

@media (max-width: 860px) {
  .aiq-cluster-layout {
    grid-template-columns: 1fr;
  }
}

.aiq-cluster-item {
  width: 100%;
  text-align: left;
  background: #FFFFFF;
  border: 1.5px solid #E2ECF9;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.aiq-cluster-item.selected {
  border-color: #1E5EFF;
  background: #F2F7FF;
}

.aiq-prio-HIGH {
  background: #FEE2E2;
  color: #B91C1C;
}

.aiq-prio-NORMAL {
  background: #FEF3C7;
  color: #92400E;
}

.aiq-prio-LOW {
  background: #E0F2FE;
  color: #075985;
}

.aiq-conflict-box {
  background: #FFF7ED;
  border: 1.5px solid #FB923C;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
  color: #9A3412;
}

.aiq-board-ref-box {
  background: #F0F9FF;
  border: 1px solid #BAE6FD;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.aiq-alert-row {
  background: #FFFBEB !important;
}

.aiq-xray-step {
  border-left: 3.5px solid #1E5EFF;
  background: #F8FAFC;
  border-radius: 0 12px 12px 0;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.aiq-xray-step.st-BLOCKED {
  border-left-color: #DC2626;
  background: #FEF2F2;
}

.aiq-xray-step.st-CACHE_HIT {
  border-left-color: #059669;
  background: #ECFDF5;
}

.aiq-xray-step.st-CUTOFF_PENDING {
  border-left-color: #D97706;
  background: #FFFBEB;
}

.aiq-score-bar-track {
  height: 8px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 5px;
}

.aiq-score-bar-fill {
  height: 100%;
  background: #1E5EFF;
  border-radius: 999px;
}


/* ==========================================================================
   고령자(50대+) · 외국인 주민 친화 UX 업그레이드 스타일
   (큰글씨 고대비 모드, 5개국어 원터치 바, 소리로 듣기 TTS, 큰 버튼 그리드, 필수 전화)
   ========================================================================== */

/* 1. 상단 큰글씨 전환 버튼 및 기본 터치 크기 보강 */
.aiq-font-toggle-btn {
  min-height: 36px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1.5px solid #93C5FD;
  background: #FFFFFF;
  color: #1648CE;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.aiq-font-toggle-btn.active {
  background: #1E5EFF;
  border-color: #1E5EFF;
  color: #FFFFFF;
}

.util-link-btn {
  min-height: 38px !important;
  padding: 6px 10px !important;
  font-size: 14px !important;
}

/* 2. 홈 화면 최상단 5개국어 원터치 언어 선택 바 */
.aiq-home-lang-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 18px;
}

.aiq-lang-chip {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid #CFE1FF;
  background: #FFFFFF;
  color: #1E293B;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(30, 94, 255, 0.06);
}

.aiq-lang-chip.active {
  background: #1E5EFF;
  border-color: #1E5EFF;
  color: #FFFFFF;
}

/* 3. 홈 화면 가로 슬라이드 없이 한눈에 보이는 3대 생활안내 큰 카드 */
.aiq-home-guides-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 420px) {
  .aiq-home-guides-grid {
    grid-template-columns: 1fr;
  }
  .aiq-home-guides-grid .info-card-btn {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: start;
  }
  .aiq-home-guides-grid .info-card-thumb {
    width: 96px;
    height: 82px;
    flex-shrink: 0;
  }
}

.aiq-home-guides-grid .info-card-btn {
  width: 100% !important;
  min-width: 0 !important;
}

/* 4. 마을 필수·긴급 전화 원터치 바로 걸기 바 */
.aiq-emergency-box {
  background: #FFFFFF;
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 4px 20px rgba(30, 94, 255, 0.08);
}

.aiq-emergency-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.aiq-tel-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 58px;
  padding: 10px 12px;
  border-radius: 13px;
  background: #F8FAFC;
  border: 1.5px solid #DCE8FA;
  text-decoration: none;
  color: #0F172A;
  transition: background 0.15s, border-color 0.15s;
}

.aiq-tel-card:hover {
  background: #EFF6FF;
  border-color: #1E5EFF;
}

.aiq-tel-card.urgent {
  background: #FEF2F2;
  border-color: #FCA5A5;
}

.aiq-tel-name {
  font-size: 13px;
  font-weight: 800;
  color: #1E293B;
}

.aiq-tel-num {
  font-size: 14.5px;
  font-weight: 800;
  color: #1648CE;
  margin-top: 2px;
}

.aiq-tel-card.urgent .aiq-tel-num {
  color: #DC2626;
}

/* 5. AI 답변 '소리로 듣기' 버튼 및 타자 없는 6대 큰 주제 버튼 */
.aiq-card-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.aiq-tts-btn {
  min-height: 36px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1.5px solid #93C5FD;
  background: #F0F7FF;
  color: #1648CE;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.aiq-tts-btn.speaking {
  background: #1E5EFF;
  border-color: #1E5EFF;
  color: #FFFFFF;
}

.aiq-big-topic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.aiq-big-topic-btn {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid #CFE1FF;
  background: #F8FBFF;
  color: #0F172A;
  font-size: 13.5px;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.3;
}

.aiq-big-topic-btn:hover {
  background: #E8F1FF;
  border-color: #1E5EFF;
}

/* 6. [가+ 큰글씨] 고령자 고대비·확대 모드 (body.large-text-mode) */
body.large-text-mode {
  --text-sub: #334155;
}

body.large-text-mode .hero-sub-title {
  font-size: 20px !important;
  color: #334155 !important;
  font-weight: 600 !important;
}

body.large-text-mode .hero-main-title {
  font-size: 33px !important;
}

body.large-text-mode .hero-chat-text,
body.large-text-mode .quick-item-label,
body.large-text-mode .mini-post-title,
body.large-text-mode .info-card-title {
  font-size: 16.5px !important;
  font-weight: 700 !important;
  color: #0F172A !important;
}

body.large-text-mode .info-card-sub,
body.large-text-mode .aiq-sub-note,
body.large-text-mode .aiq-dept-pill,
body.large-text-mode .tab-label {
  font-size: 14px !important;
  color: #1E293B !important;
}

body.large-text-mode .aiq-answer-body,
body.large-text-mode .chat-bubble.user,
body.large-text-mode .guide-val,
body.large-text-mode .incheoner-lead {
  font-size: 17.5px !important;
  line-height: 1.75 !important;
}

body.large-text-mode .aiq-big-topic-btn,
body.large-text-mode .aiq-followup-chip,
body.large-text-mode .tip-q-btn,
body.large-text-mode .aiq-mode-tab,
body.large-text-mode .aiq-lang-chip {
  font-size: 15.5px !important;
  min-height: 50px !important;
}

body.large-text-mode #chatTextInput,
body.large-text-mode .aiq-search-input {
  font-size: 17px !important;
  min-height: 48px !important;
}

body.large-text-mode .aiq-tel-name {
  font-size: 15px !important;
}

body.large-text-mode .aiq-tel-num {
  font-size: 17px !important;
}

[dir="rtl"] .detail-back-btn svg {
  transform: scaleX(-1);
}
