/* ========== AI Bank Chat Widget ========== */
#aibank-chat-root {
  --cw-primary: #6366f1;
  --cw-primary-2: #4f46e5;
  --cw-text: #0f172a;
  --cw-muted: #64748b;
  --cw-dim: #94a3b8;
  --cw-border: rgba(15, 23, 42, 0.08);
  --cw-bg: #ffffff;
  --cw-body: #f4f6fb;
  --cw-shadow: 0 20px 60px rgba(15, 23, 42, 0.18);
  --cw-safe-b: env(safe-area-inset-bottom, 0px);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--cw-text);
  -webkit-font-smoothing: antialiased;
}
#aibank-chat-root *,
#aibank-chat-root *::before,
#aibank-chat-root *::after { box-sizing: border-box; }

#aibank-chat-root .cw-fab {
  position: fixed;
  right: 18px;
  bottom: calc(88px + var(--cw-safe-b));
  z-index: 10050;
  width: 60px;
  height: 60px;
  border: none !important;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff !important;
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 45%, #4f46e5 100%) !important;
  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.45), 0 0 0 4px rgba(99, 102, 241, 0.12);
  transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  animation: cw-fab-in 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
#aibank-chat-root .cw-fab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 14px 34px rgba(99, 102, 241, 0.55), 0 0 0 5px rgba(99, 102, 241, 0.16);
}
#aibank-chat-root .cw-fab:active { transform: scale(0.96); }
#aibank-chat-root .cw-fab.is-open { opacity: 0; pointer-events: none; transform: scale(0.7); }
#aibank-chat-root .cw-fab svg { width: 26px; height: 26px; display: block; }
#aibank-chat-root .cw-fab-pulse {
  position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(99, 102, 241, 0.45);
  animation: cw-pulse 2.2s ease-out infinite; pointer-events: none;
}
#aibank-chat-root .cw-fab-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
  line-height: 20px; text-align: center; border: 2px solid #fff;
  display: none; box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}
#aibank-chat-root .cw-fab-badge.show { display: block; }
@keyframes cw-pulse { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes cw-fab-in { from { opacity: 0; transform: scale(0.5) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }

#aibank-chat-root .cw-panel {
  position: fixed;
  right: 16px;
  bottom: calc(88px + var(--cw-safe-b));
  z-index: 10060;
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100dvh - 110px - var(--cw-safe-b)));
  display: flex; flex-direction: column;
  background: var(--cw-bg);
  border-radius: 22px; overflow: hidden;
  box-shadow: var(--cw-shadow);
  border: 1px solid rgba(255,255,255,0.65);
  opacity: 0; pointer-events: none;
  transform: translateY(18px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.34, 1.35, 0.64, 1);
}
#aibank-chat-root .cw-panel.open {
  opacity: 1; pointer-events: auto; transform: translateY(0) scale(1);
}
#aibank-chat-root .cw-header {
  position: relative; flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 14px 16px 16px; color: #fff;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(34, 211, 238, 0.28) 0%, transparent 55%),
    linear-gradient(135deg, #6366f1 0%, #4f46e5 55%, #4338ca 100%);
}
#aibank-chat-root .cw-avatar {
  position: relative; width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  overflow: hidden; background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.45);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px;
}
#aibank-chat-root .cw-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
#aibank-chat-root .cw-online {
  position: absolute; right: 1px; bottom: 1px; width: 11px; height: 11px; border-radius: 50%;
  background: #22c55e; border: 2px solid #4f46e5;
}
#aibank-chat-root .cw-header-text { flex: 1; min-width: 0; }
#aibank-chat-root .cw-header-name {
  font-size: 15px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#aibank-chat-root .cw-header-status {
  margin-top: 3px; display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.92;
}
#aibank-chat-root .cw-header-status .dot {
  width: 7px; height: 7px; border-radius: 50%; background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
}
#aibank-chat-root .cw-close {
  width: 34px; height: 34px; border: none !important; border-radius: 50%;
  background: rgba(255,255,255,0.16) !important; color: #fff !important;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 20px; line-height: 1;
}
#aibank-chat-root .cw-close:hover { background: rgba(255,255,255,0.28) !important; }

#aibank-chat-root .cw-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 10px;
  background: radial-gradient(circle at top right, rgba(99,102,241,0.06), transparent 40%), var(--cw-body);
  -webkit-overflow-scrolling: touch;
}
#aibank-chat-root .cw-body::-webkit-scrollbar { width: 5px; }
#aibank-chat-root .cw-body::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.12); border-radius: 8px; }

#aibank-chat-root .cw-welcome {
  align-self: center; width: 100%; margin: 4px 0 8px; padding: 14px;
  border-radius: 16px; background: #fff; border: 1px solid var(--cw-border);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05); text-align: center;
}
#aibank-chat-root .cw-welcome-icon {
  width: 42px; height: 42px; margin: 0 auto 8px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
}
#aibank-chat-root .cw-welcome strong {
  display: block; font-size: 13.5px; font-weight: 800; color: var(--cw-text); margin-bottom: 4px;
}
#aibank-chat-root .cw-welcome p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--cw-muted); }

#aibank-chat-root .cw-msg {
  max-width: 82%; padding: 10px 13px 8px; border-radius: 18px;
  font-size: 13.5px; line-height: 1.45; word-break: break-word;
  animation: cw-msg-in 0.22s ease-out both;
}
@keyframes cw-msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
#aibank-chat-root .cw-msg.visitor {
  align-self: flex-end; color: #fff;
  background: linear-gradient(135deg, #818cf8, #6366f1 50%, #4f46e5);
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.25);
}
#aibank-chat-root .cw-msg.manager {
  align-self: flex-start; color: var(--cw-text); background: #fff;
  border: 1px solid var(--cw-border); border-bottom-left-radius: 6px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}
#aibank-chat-root .cw-msg-meta {
  display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 10.5px; opacity: 0.72;
}
#aibank-chat-root .cw-msg.visitor .cw-msg-meta { justify-content: flex-end; color: rgba(255,255,255,0.92); }
#aibank-chat-root .cw-msg.manager .cw-msg-meta { color: var(--cw-dim); }

#aibank-chat-root .cw-footer {
  flex-shrink: 0; padding: 10px 12px calc(12px + var(--cw-safe-b));
  background: #fff; border-top: 1px solid var(--cw-border);
}
#aibank-chat-root .cw-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 6px 6px 6px 14px; border-radius: 999px; background: #f1f5f9;
  border: 1px solid transparent;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
#aibank-chat-root .cw-input-row:focus-within {
  background: #fff; border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}
#aibank-chat-root .cw-input {
  flex: 1; min-width: 0; border: none !important; outline: none !important;
  background: transparent !important; resize: none; max-height: 96px;
  padding: 8px 0; font: inherit; font-size: 14px; line-height: 1.4; color: var(--cw-text);
}
#aibank-chat-root .cw-input::placeholder { color: var(--cw-dim); }
#aibank-chat-root .cw-send {
  width: 40px; height: 40px; border: none !important; border-radius: 50%; flex-shrink: 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: #fff !important; background: linear-gradient(135deg, #818cf8, #4f46e5) !important;
  box-shadow: 0 6px 14px rgba(99, 102, 241, 0.35);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
#aibank-chat-root .cw-send:disabled { opacity: 0.4; cursor: default; box-shadow: none; }
#aibank-chat-root .cw-send:not(:disabled):hover { transform: scale(1.05); }
#aibank-chat-root .cw-send svg { width: 18px; height: 18px; display: block; }
#aibank-chat-root .cw-hint { margin-top: 7px; text-align: center; font-size: 10.5px; color: var(--cw-dim); }

#aibank-chat-root .cw-backdrop {
  display: none; position: fixed; inset: 0; z-index: 10055;
  background: rgba(15, 23, 42, 0.35); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity 0.2s ease; pointer-events: none;
}
#aibank-chat-root .cw-backdrop.show { display: block; opacity: 1; pointer-events: auto; }

body.cw-chat-open .sticky-cta { opacity: 0 !important; pointer-events: none !important; }

@media (max-width: 480px) {
  #aibank-chat-root .cw-fab {
    right: 14px; bottom: calc(84px + var(--cw-safe-b)); width: 56px; height: 56px;
  }
  #aibank-chat-root .cw-panel {
    right: 0; left: 0; bottom: 0; width: 100vw; max-width: none;
    height: min(78dvh, 620px); border-radius: 22px 22px 0 0; transform: translateY(24px);
  }
  #aibank-chat-root .cw-panel.open { transform: translateY(0); }
}

/* ===== Eye-catching callout near FAB ===== */
#aibank-chat-root .cw-callout {
  position: fixed;
  right: 88px;
  bottom: calc(100px + var(--cw-safe-b));
  z-index: 10051;
  max-width: min(220px, calc(100vw - 110px));
  padding: 12px 14px 11px;
  border-radius: 16px;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 55%, #7c3aed 100%);
  color: #fff;
  box-shadow:
    0 12px 28px rgba(79, 70, 229, 0.4),
    0 0 0 1px rgba(255,255,255,0.12) inset;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: cw-callout-in 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) 0.55s both,
             cw-callout-bob 2.4s ease-in-out 1.2s infinite;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
#aibank-chat-root .cw-callout.is-hidden,
#aibank-chat-root.is-open .cw-callout {
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px) scale(0.92);
  animation: none;
}
#aibank-chat-root .cw-callout-title {
  display: block;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.35;
  text-shadow: 0 1px 0 rgba(0,0,0,0.08);
}
#aibank-chat-root .cw-callout-sub {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0.92;
  line-height: 1.3;
}
#aibank-chat-root .cw-callout-arrow {
  position: absolute;
  right: -10px;
  top: 50%;
  width: 0; height: 0;
  margin-top: -8px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 11px solid #6366f1;
  filter: drop-shadow(2px 0 2px rgba(79, 70, 229, 0.25));
}
#aibank-chat-root .cw-callout-close {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 22px;
  height: 22px;
  border: none !important;
  border-radius: 50%;
  background: #fff !important;
  color: #4f46e5 !important;
  font-size: 14px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  padding: 0;
}
@keyframes cw-callout-in {
  from { opacity: 0; transform: translateX(16px) scale(0.85); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes cw-callout-bob {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-6px); }
}

/* Make FAB more visible */
#aibank-chat-root .cw-fab {
  width: 64px;
  height: 64px;
  box-shadow:
    0 12px 32px rgba(99, 102, 241, 0.55),
    0 0 0 5px rgba(99, 102, 241, 0.16),
    0 0 24px rgba(129, 140, 248, 0.45) !important;
}
#aibank-chat-root .cw-fab svg { width: 28px; height: 28px; }
#aibank-chat-root .cw-fab-label {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  background: #ef4444;
  padding: 2px 7px;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.35);
  animation: cw-fab-label-pulse 1.6s ease-in-out infinite;
}
@keyframes cw-fab-label-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.06); }
}

@media (max-width: 480px) {
  #aibank-chat-root .cw-callout {
    right: 78px;
    bottom: calc(96px + var(--cw-safe-b));
    max-width: min(190px, calc(100vw - 100px));
    padding: 11px 12px 10px;
  }
  #aibank-chat-root .cw-callout-title { font-size: 12.5px; }
  #aibank-chat-root .cw-callout-sub { font-size: 11px; }
  #aibank-chat-root .cw-fab {
    width: 60px;
    height: 60px;
  }
}
