/* ===================================================================
   CISB — AI Agent Look-Alike Widget Stylesheet
   Modern Glassmorphism Design matching CISB Brand colors
   =================================================================== */

/* ───────── Floating Action Button (FAB) ───────── */
.cisb-agent-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-navy);
  border: 2px solid var(--color-gold);
  color: var(--color-gold);
  box-shadow: 0 8px 24px rgba(27, 42, 74, 0.3), 
              0 0 0 0px rgba(200, 162, 74, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: fabPulse 2s infinite;
}

.cisb-agent-fab:hover {
  transform: scale(1.1) rotate(5deg);
  background: var(--color-teal);
  color: var(--color-white);
  border-color: var(--color-white);
  box-shadow: 0 12px 30px rgba(14, 76, 70, 0.4);
}

.cisb-agent-fab svg {
  width: 26px;
  height: 26px;
  transition: transform 0.3s ease;
}

.cisb-agent-fab:hover svg {
  transform: scale(1.05);
}

/* ───────── Chat Widget Container ───────── */
.cisb-agent-chat {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 140px);
  background: rgba(27, 42, 74, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1.5rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  z-index: 999;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  visibility: hidden;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.cisb-agent-chat.is-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  pointer-events: auto;
}

/* ───────── Chat Header ───────── */
.cisb-chat-header {
  padding: 1.25rem;
  background: rgba(14, 76, 70, 0.4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cisb-chat-header__profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cisb-chat-header__avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-fraunces);
  font-weight: 700;
  color: var(--color-navy);
  font-size: 1.2rem;
}

.cisb-chat-header__status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10B981;
  border: 2px solid var(--color-navy);
  animation: dotPulse 2s infinite;
}

.cisb-chat-header__info {
  display: flex;
  flex-direction: column;
}

.cisb-chat-header__name {
  font-family: var(--font-fraunces);
  color: var(--color-paper);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.2;
}

.cisb-chat-header__role {
  font-family: var(--font-mono);
  color: var(--color-gold);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.cisb-chat-header__close {
  color: rgba(246, 244, 237, 0.6);
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.cisb-chat-header__close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-gold-light);
  transform: rotate(90deg);
}

/* ───────── Chat History ───────── */
.cisb-chat-messages {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

/* Custom Scrollbar for Chat Messages */
.cisb-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.cisb-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.cisb-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}
.cisb-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.cisb-msg-row {
  display: flex;
  width: 100%;
}

.cisb-msg-row--user {
  justify-content: flex-end;
}

.cisb-msg-row--agent {
  justify-content: flex-start;
}

.cisb-msg-bubble {
  max-width: 80%;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  line-height: 1.45;
  animation: bubbleEntry 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) both;
}

.cisb-msg-row--user .cisb-msg-bubble {
  background: var(--color-gold);
  color: var(--color-navy);
  border-radius: 1rem 1rem 0 1rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(200, 162, 74, 0.15);
}

.cisb-msg-row--agent .cisb-msg-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(246, 244, 237, 0.9);
  border-radius: 1rem 1rem 1rem 0;
}

/* ───────── Thinking State & Bouncing Dots ───────── */
.cisb-thinking-indicator {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.625rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 1rem 1rem 1rem 0;
  max-width: 80%;
  animation: bubbleEntry 0.3s ease both;
}

.cisb-thinking-log {
  font-family: var(--font-mono);
  font-size: 9px;
  color: rgba(246, 244, 237, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.cisb-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 12px;
}

.cisb-dots span {
  width: 6px;
  height: 6px;
  background-color: var(--color-gold);
  border-radius: 50%;
  display: inline-block;
  animation: bounceDot 1.4s infinite ease-in-out both;
}

.cisb-dots span:nth-child(1) { animation-delay: -0.32s; }
.cisb-dots span:nth-child(2) { animation-delay: -0.16s; }

/* ───────── Suggestions Area ───────── */
.cisb-chat-suggestions {
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(27, 42, 74, 0.4);
}

.cisb-suggestion-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  padding: 0.4rem 0.75rem;
  font-size: 10px;
  color: rgba(246, 244, 237, 0.7);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cisb-suggestion-chip:hover {
  background: rgba(200, 162, 74, 0.12);
  border-color: var(--color-gold);
  color: var(--color-gold-light);
  transform: translateY(-1px);
}

/* ───────── Chat Input Area ───────── */
.cisb-chat-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 0.75rem;
  background: rgba(14, 76, 70, 0.2);
}

.cisb-chat-input-wrapper {
  flex: 1;
  position: relative;
}

.cisb-chat-input {
  width: 100%;
  height: 42px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  padding: 0 1rem;
  font-size: 0.85rem;
  color: var(--color-paper);
  font-family: var(--font-inter);
  outline: none;
  transition: all 0.2s ease;
}

.cisb-chat-input::placeholder {
  color: rgba(246, 244, 237, 0.35);
}

.cisb-chat-input:focus {
  border-color: var(--color-gold);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(200, 162, 74, 0.15);
}

.cisb-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--color-gold);
  color: var(--color-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.cisb-chat-send:hover {
  background: var(--color-gold-light);
  transform: scale(1.05);
}

.cisb-chat-send:active {
  transform: scale(0.95);
}

.cisb-chat-send svg {
  width: 18px;
  height: 18px;
}

/* ───────── Responsive styles ───────── */
@media (max-width: 480px) {
  .cisb-agent-chat {
    width: calc(100% - 32px);
    right: 16px;
    bottom: 92px;
    height: 500px;
  }
  .cisb-agent-fab {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
}

/* ───────── Keyframe Animations ───────── */
@keyframes fabPulse {
  0% {
    box-shadow: 0 8px 24px rgba(27, 42, 74, 0.3), 
                0 0 0 0px rgba(200, 162, 74, 0.4);
  }
  70% {
    box-shadow: 0 8px 24px rgba(27, 42, 74, 0.3), 
                0 0 0 10px rgba(200, 162, 74, 0);
  }
  100% {
    box-shadow: 0 8px 24px rgba(27, 42, 74, 0.3), 
                0 0 0 0px rgba(200, 162, 74, 0);
  }
}

@keyframes dotPulse {
  0%, 100% {
    box-shadow: 0 0 0 0px rgba(16, 185, 129, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
}

@keyframes bubbleEntry {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bounceDot {
  0%, 80%, 100% { 
    transform: scale(0);
  } 40% { 
    transform: scale(1.0);
  }
}
