/* SIRCA AI Chat widget */
.sirca-chat-widget {
  position: fixed;
  z-index: 2100;
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--bottom-nav-h, 74px) + 12px);
  font-family: 'Poppins', sans-serif;
}

@media (min-width: 992px) {
  .sirca-chat-widget {
    bottom: 24px;
    right: 24px;
  }
}

.sirca-chat-fab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.1rem 0.65rem 0.85rem;
  background: linear-gradient(145deg, #024FAE 0%, #0F2740 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  box-shadow:
    0 6px 20px rgba(2, 79, 174, 0.4),
    0 0 0 4px rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.sirca-chat-fab:hover {
  transform: scale(1.04);
  box-shadow: 0 10px 28px rgba(2, 79, 174, 0.45);
}
.sirca-chat-fab-icon { font-size: 1.35rem; }
.sirca-chat-fab-close { display: none; font-size: 1.2rem; }
.sirca-chat-widget.is-open .sirca-chat-fab-icon { display: none; }
.sirca-chat-widget.is-open .sirca-chat-fab-close { display: block; }
.sirca-chat-widget.is-open .sirca-chat-fab {
  border-radius: 50%;
  width: 52px;
  height: 52px;
  padding: 0;
  justify-content: center;
}
.sirca-chat-widget.is-open .sirca-chat-fab-label { display: none; }

.sirca-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(380px, calc(100vw - 28px));
  max-height: min(520px, calc(100vh - var(--bottom-nav-h, 74px) - 100px));
  background: #fff;
  border-radius: 20px;
  border: 1px solid rgba(2, 79, 174, 0.12);
  box-shadow: 0 20px 60px rgba(15, 39, 64, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s;
  pointer-events: none;
}
.sirca-chat-widget.is-open .sirca-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sirca-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #024FAE, #0F2740);
  color: #fff;
}
.sirca-chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.sirca-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.sirca-chat-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}
.sirca-chat-status {
  font-size: 0.68rem;
  opacity: 0.88;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.sirca-chat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
}
.sirca-chat-close {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sirca-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #f7f4ee;
  min-height: 200px;
  max-height: 280px;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
.sirca-chat-msg {
  margin-bottom: 0.75rem;
  display: flex;
}
.sirca-chat-msg--user { justify-content: flex-end; }
.sirca-chat-msg--bot { justify-content: flex-start; }
.sirca-chat-bubble {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.55;
  word-break: break-word;
}
.sirca-chat-msg--bot .sirca-chat-bubble {
  background: #fff;
  color: #0f172a;
  border: 1px solid rgba(2, 79, 174, 0.1);
  border-bottom-left-radius: 4px;
}
.sirca-chat-msg--user .sirca-chat-bubble {
  background: linear-gradient(135deg, #024FAE, #2B6591);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sirca-chat-msg--typing .sirca-chat-bubble {
  display: flex;
  gap: 4px;
  padding: 0.75rem 1rem;
}
.sirca-chat-msg--typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: sircaChatDot 1s infinite;
}
.sirca-chat-msg--typing span:nth-child(2) { animation-delay: 0.15s; }
.sirca-chat-msg--typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sircaChatDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

.sirca-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem 0.5rem;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.sirca-chat-chip {
  border: 1px solid rgba(197, 150, 61, 0.35);
  background: #faf6ed;
  color: #0f2740;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.sirca-chat-chip:hover {
  background: #f3ede3;
  border-color: #C5963D;
}

.sirca-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.sirca-chat-input {
  flex: 1;
  border: 1px solid rgba(2, 79, 174, 0.18);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  outline: none;
}
.sirca-chat-input:focus {
  border-color: #024FAE;
  box-shadow: 0 0 0 3px rgba(2, 79, 174, 0.12);
}
.sirca-chat-send {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(145deg, #C5963D, #9A7830);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.sirca-chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.sirca-chat-footer-note {
  margin: 0;
  padding: 0.4rem 0.75rem 0.55rem;
  text-align: center;
  background: #fff;
  font-size: 0.9rem;
}
.sirca-chat-footer-note a {
  color: #024FAE;
  margin: 0 0.5rem;
  text-decoration: none;
}
.sirca-chat-footer-note a:hover { color: #C5963D; }

@media (max-width: 575.98px) {
  .sirca-chat-panel {
    width: calc(100vw - 20px);
    right: -4px;
    max-height: min(70vh, 480px);
  }
}

body.sirca-chat-open {
  overflow: hidden;
  touch-action: none;
}

body.sirca-chat-open .sirca-chat-messages,
body.sirca-chat-open .sirca-chat-panel {
  touch-action: pan-y;
}
