/* =======================================================================
 * 에스앤제이 동물병원 - 장애인 접근 편의 도구 + FAQ 챗봇 위젯 (0-Server)
 * ======================================================================= */

[hidden] { display: none !important; }

/* -----------------------------------------------------------------------
 * 1) 장애인 접근 편의 모드 (html 루트 클래스 기반)
 * ----------------------------------------------------------------------- */

/* 색상 필터 조합: body 직속 요소마다 개별 적용해 fixed/sticky 레이아웃 보존 */
html.acc-contrast body > * { filter: contrast(1.35) saturate(1.1) !important; }
html.acc-invert body > *    { filter: invert(1) hue-rotate(180deg) !important; }
html.acc-gray body > *      { filter: grayscale(1) !important; }
html.acc-contrast.acc-invert body > * { filter: contrast(1.35) saturate(1.1) invert(1) hue-rotate(180deg) !important; }
html.acc-gray.acc-contrast body > *   { filter: contrast(1.35) saturate(1.1) grayscale(1) !important; }
html.acc-gray.acc-invert body > *     { filter: grayscale(1) invert(1) hue-rotate(180deg) !important; }

html.acc-invert { background: #0a1520; }
html.acc-invert body { background-color: #0a1520 !important; }

/* 글자 크기 확대/축소 (브라우저 줌과 동일한 루트 zoom 방식) */
html.acc-zoom-1 { zoom: 1.1; }
html.acc-zoom-2 { zoom: 1.2; }
html.acc-zoom-3 { zoom: 1.35; }

/* 글자 간격 확대 */
html.acc-letter body,
html.acc-letter body p,
html.acc-letter body li,
html.acc-letter body span,
html.acc-letter body a,
html.acc-letter body td,
html.acc-letter body th,
html.acc-letter body label,
html.acc-letter body strong,
html.acc-letter body em,
html.acc-letter body h1,
html.acc-letter body h2,
html.acc-letter body h3,
html.acc-letter body h4,
html.acc-letter body h5,
html.acc-letter body h6,
html.acc-letter body button,
html.acc-letter body input,
html.acc-letter body textarea { letter-spacing: 0.06em !important; }

/* 줄 간격 확대 */
html.acc-line body p,
html.acc-line body li,
html.acc-line body td,
html.acc-line body th,
html.acc-line body span,
html.acc-line body a,
html.acc-line body label,
html.acc-line body strong,
html.acc-line body em,
html.acc-line body input,
html.acc-line body textarea,
html.acc-line body button { line-height: 1.9 !important; }

/* 큰 커서 (접근성 전용 확대 포인터) */
html.acc-cursor,
html.acc-cursor * {
  cursor: url('data:image/svg+xml;utf8,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20width=%2752%27%20height=%2752%27%20viewBox=%270%200%2052%2052%27%3E%3Cpath%20d=%27M6%202%20L6%2040%20L17%2031%20L24%2045%20L35%2041%20L28%2028%20L42%2028%20Z%27%20fill=%27white%27%20stroke=%27black%27%20stroke-width=%273%27%20stroke-linejoin=%27round%27/%3E%3C/svg%3E') 4 2, default !important;
}

/* -----------------------------------------------------------------------
 * 2) 접근성 플로팅 버튼 + 패널
 * ----------------------------------------------------------------------- */
.acc-fab {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full, 9999px);
  background: linear-gradient(135deg, var(--primary-700, #1a3f61), var(--primary-900, #0d1e2e));
  color: #fff;
  font-size: 25px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px -6px rgba(13, 30, 46, 0.5);
  z-index: 958;
  border: 2px solid rgba(255, 255, 255, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.acc-fab:hover, .acc-fab:focus-visible { transform: translateY(-3px); box-shadow: 0 16px 30px -8px rgba(13, 30, 46, 0.55); }

.acc-panel {
  position: fixed;
  left: 24px;
  bottom: 96px;
  width: 308px;
  background: #ffffff;
  border-radius: var(--radius-lg, 22px);
  box-shadow: 0 24px 48px -16px rgba(13, 30, 46, 0.35);
  border: 1px solid var(--border-color, #e2e8f0);
  z-index: 952;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.acc-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary-800, #132e47), var(--primary-700, #1a3f61));
  color: #fff;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 800;
}
.acc-close {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full, 9999px);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.acc-close:hover, .acc-close:focus-visible { background: rgba(255, 255, 255, 0.28); }

.acc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px;
}
.acc-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 4px;
  border-radius: var(--radius-sm, 8px);
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
  min-height: 52px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.acc-btn svg, .acc-btn .acc-ico { font-size: 19px; line-height: 1; }
.acc-btn:hover { background: #e2e8f0; }
.acc-btn:focus-visible { outline: 2px solid var(--accent-teal, #0d9488); outline-offset: 2px; }
.acc-btn.on {
  background: linear-gradient(135deg, var(--accent-teal, #0d9488), var(--accent-emerald, #10b981));
  color: #fff;
  border-color: transparent;
}
.acc-btn-reset {
  grid-column: 1 / -1;
  background: #fee2e2;
  border-color: #fecaca;
  color: #b91c1c;
  flex-direction: row;
  gap: 6px;
  min-height: 42px;
}
.acc-btn-reset.on { background: linear-gradient(135deg, #dc2626, #ef4444); color: #fff; }

.acc-tip {
  padding: 0 14px 12px;
  font-size: 11px;
  color: var(--text-muted, #64748b);
  line-height: 1.5;
}

/* 읽어주기 상태 바 */
.acc-tts-state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm, 8px);
  background: #fffbeb;
  border: 1px solid #fde68a;
  font-size: 12px;
  color: #92400e;
  font-weight: 700;
}
.acc-tts-state .acc-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; flex: 0 0 auto;
  animation: acc-blink 1s ease-in-out infinite;
}
@keyframes acc-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.acc-tts-state button {
  margin-left: auto;
  background: #f59e0b;
  color: #fff;
  border-radius: var(--radius-full, 9999px);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
}
.acc-tts-state button:hover { background: #d97706; }

/* 읽기 가이드 라인 (마우스 위치 고정 띠) */
.acc-guide {
  position: fixed;
  inset: 0;
  z-index: 940;
  pointer-events: none;
  background:
    linear-gradient(to bottom,
      rgba(6, 14, 26, 0.38) 0 var(--acc-gy, 40%),
      rgba(255, 215, 64, 0.28) var(--acc-gy, 40%) calc(var(--acc-gy, 40%) + var(--acc-gh, 56px)),
      rgba(6, 14, 26, 0.38) calc(var(--acc-gy, 40%) + var(--acc-gh, 56px)) 100%);
}

/* 현재 읽어주는 요소 하이라이트 */
.acc-speaking {
  outline: 3px dashed #f59e0b !important;
  outline-offset: 3px !important;
  border-radius: 6px;
  background: #fffbeb !important;
  transition: outline 0.15s ease, background 0.15s ease;
}

/* 접근성 토스트 */
.acc-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 110px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-full, 9999px);
  font-size: 13px;
  font-weight: 700;
  z-index: 2000;
  box-shadow: var(--shadow-lg, 0 20px 35px -8px rgba(19, 46, 71, 0.12));
  animation: acc-toast-in 0.22s ease;
  pointer-events: none;
}
@keyframes acc-toast-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* -----------------------------------------------------------------------
 * 3) FAQ 챗봇 위젯
 * ----------------------------------------------------------------------- */
.chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 58px;
  height: 58px;
  border-radius: var(--radius-full, 9999px);
  background: linear-gradient(135deg, var(--accent-teal, #0d9488), var(--accent-emerald, #10b981));
  color: #fff;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px -6px rgba(13, 148, 136, 0.55);
  z-index: 958;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.chat-fab.has-unread::after {
  content: "";
  position: absolute;
  top: -2px; right: -2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent-red, #ef4444);
  border: 2px solid #fff;
  animation: chat-pulse 1.6s ease-in-out infinite;
}
@keyframes chat-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
.chat-fab:hover, .chat-fab:focus-visible { transform: translateY(-3px) scale(1.05); }

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 372px;
  height: 560px;
  max-height: calc(100vh - 140px);
  background: #ffffff;
  border-radius: var(--radius-lg, 22px);
  box-shadow: 0 24px 56px -14px rgba(13, 30, 46, 0.4);
  border: 1px solid var(--border-color, #e2e8f0);
  z-index: 954;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(135deg, var(--primary-800, #132e47), var(--primary-600, #23527c));
  color: #fff;
  padding: 14px 16px;
}
.chat-head strong { font-size: 15px; font-weight: 800; display: block; }
.chat-sub { font-size: 11px; opacity: 0.85; }
.chat-badge {
  font-size: 10px;
  font-weight: 800;
  color: #065f46;
  background: #a7f3d0;
  padding: 2px 9px;
  border-radius: var(--radius-full, 9999px);
  margin-left: 6px;
  vertical-align: 1px;
}
.chat-close {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full, 9999px);
  font-size: 19px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.chat-close:hover, .chat-close:focus-visible { background: rgba(255, 255, 255, 0.3); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}
.chat-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: keep-all;
  white-space: pre-line;
}
.chat-msg.bot {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 5px;
  color: #0f172a;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(19, 46, 71, 0.05));
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent-teal, #0d9488), var(--accent-emerald, #10b981));
  border-bottom-right-radius: 5px;
  color: #fff;
}
.chat-msg.typing {
  color: var(--text-muted, #64748b);
  font-size: 12.5px;
  font-style: italic;
}
.chat-msg .chat-err { color: #b91c1c; font-weight: 700; }

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 12px;
  background: #f8fafc;
}
.chat-chip {
  background: #fff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  border-radius: var(--radius-full, 9999px);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.chat-chip:hover { background: var(--accent-mint, #e6f9f3); border-color: var(--accent-teal, #0d9488); }
.chat-chip:focus-visible { outline: 2px solid var(--accent-teal, #0d9488); outline-offset: 1px; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  background: #fff;
}
.chat-form input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-full, 9999px);
  padding: 10px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: #f8fafc;
}
.chat-form input:focus { border-color: var(--accent-teal, #0d9488); background: #fff; }
.chat-form button {
  background: linear-gradient(135deg, var(--accent-teal, #0d9488), var(--accent-emerald, #10b981));
  color: #fff;
  border-radius: var(--radius-full, 9999px);
  padding: 0 20px;
  font-size: 13.5px;
  font-weight: 800;
  flex: 0 0 auto;
}
.chat-form button:hover { filter: brightness(1.06); }

.chat-mute-author { font-size: 10.5px; color: #94a3b8; font-weight: 700; margin-bottom: 2px; }

/* -----------------------------------------------------------------------
 * 4) 모바일 반응형 (모바일 하단 고정 바 대응)
 * ----------------------------------------------------------------------- */
@media (max-width: 768px) {
  .acc-fab {
    left: 12px;
    bottom: calc(88px + env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
  }
  .acc-panel {
    left: 12px;
    right: 12px;
    bottom: calc(150px + env(safe-area-inset-bottom));
    width: auto;
  }
  .chat-fab {
    right: 12px;
    bottom: calc(88px + env(safe-area-inset-bottom));
    width: 54px;
    height: 54px;
  }
  .chat-panel {
    left: 12px;
    right: 12px;
    bottom: calc(150px + env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    max-height: 58vh;
  }
  .acc-toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}