.chat-toggle-btn {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: 24px;
  z-index: 999;
  background: #007bff;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: transform 0.2s;
}

.chat-toggle-btn.bounce {
  transform: scale(1.2);
}

.chat-widget {
  position: fixed;
  bottom: var(--nav-size-slim);
  inset-inline-end: 20px;
  width: 420px;
  height: calc(99vh - 2 * var(--nav-size-slim)) !important;
  display: flex;
  flex-direction: column;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
  z-index: 999;
  background: #fff;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
}

.chat-widget.open {
  transform: translateY(0);
  opacity: 1;
}

.chat-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.msg-user {
  background: #007bff;
  color: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  max-width: 80%;
  margin-inline-start: auto;
}

.msg-external {
  background: #f1f1f1;
  border-radius: 10px;
  padding: 6px 10px;
  max-width: 80%;
  margin-inline-end: auto;
}
/* Mobile full screen chat */
@media (max-width: 768px) {
  .chat-widget {
    width: 100% !important;
    height: calc(100vh - 2 * var(--nav-size-slim)) !important;
    bottom: var(--nav-size-slim);
    inset-inline-end: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }


  .chat-toggle-btn {
    bottom: 20px;
    inset-inline-end: 20px;
  }
}
/* --- Chat Widget Layout --- */
.chat-widget .card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Fixed header */
.chat-widget .card-header {
  flex: 0 0 auto; /* header stays fixed */
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

/* Fixed footer */
.chat-widget .card-footer {
  flex: 0 0 auto; /* footer stays fixed */
  z-index: 2;
  background: #fff;
  border-top: 1px solid #e0e0e0;
}

/* Scrollable body */
.chat-widget .card-body.flex-grow-1 {
  flex: 1 1 auto; /* take remaining space */
  overflow-y: auto; /* enable vertical scroll */
  position: relative;
  padding: 10px;
  background: #f9f9f9;
  scroll-behavior: smooth; /* smooth scrolling */
}

/* Optional: message spacing */
.chat-widget .msg-user,
.chat-widget .msg-external {
  margin-bottom: 8px;
}

/* Scrollbar customization (optional) */
.chat-widget .card-body.flex-grow-1::-webkit-scrollbar {
  width: 6px;
}
.chat-widget .card-body.flex-grow-1::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.2);
  border-radius: 3px;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  .chat-widget {
    width: 100% !important;
    height: calc(100vh - 2 * var(--nav-size-slim)) !important;
    bottom: var(--nav-size-slim);
    inset-inline-end: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  .chat-widget .card-body.flex-grow-1 {
    padding: 8px;
  }
}

.chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  backdrop-filter: blur(2px) brightness(0.9); /* modern blur with dimming */
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.5) 100%
  ); /* subtle gradient overlay */
  z-index: 998;
  opacity: 0.5;
  pointer-events: none; /* prevent clicking when hidden */
  transition: opacity 0.4s ease, backdrop-filter 0.4s ease;
}

.chat-overlay.active {
  opacity: 1;
  pointer-events: all; /* clickable when active */
}
