:root {
  --navy: #0b1f3a;
  --teal: #0f6c7d;
  --gold: #d8b46a;
  --white: #ffffff;
  --shadow: 0 24px 60px rgba(11, 31, 58, 0.15);
  --chat-width: 33vw;
  --chat-width-expanded: 50vw;
}

.chat-bubble {
  position: fixed;
  right: 28px;
  bottom: 28px;
  background: var(--navy);
  color: var(--white);
  border: none;
  padding: 12px 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 20px 50px rgba(11, 31, 58, 0.25);
  z-index: 10001;
}

body.chat-open .chat-bubble {
  display: none;
}

.chat-bubble .pulse {
  width: 10px;
  height: 10px;
  background: var(--gold);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: var(--chat-width);
  min-width: 320px;
  background: var(--white);
  box-shadow: -12px 0 40px rgba(11, 31, 58, 0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease, width 0.2s ease;
  z-index: 10000;
}

body.chat-open .chat-panel {
  transform: translateX(0);
}

body.chat-expanded .chat-panel {
  width: var(--chat-width-expanded);
}

.chat-panel header {
  position: sticky;
  top: 0;
  z-index: 10003;
  background: var(--navy);
  color: var(--white);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-panel header h3 {
  margin: 0;
  font-size: 1rem;
}

.chat-panel header p {
  margin: 4px 0 0;
  font-size: 0.75rem;
  opacity: 0.8;
}

.chat-panel header button {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--white);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}

/* Provider toggle */
.provider-toggle {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 2px;
}

.provider-btn {
  background: transparent !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.6) !important;
  font-size: 0.72rem !important;
  padding: 4px 10px !important;
  border-radius: 999px !important;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.provider-btn.active {
  background: var(--gold) !important;
  color: var(--navy) !important;
  font-weight: 600;
}

.provider-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.18) !important;
  color: var(--white) !important;
}

.chat-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

.message {
  padding: 12px 14px;
  border-radius: 12px;
  max-width: 90%;
  line-height: 1.5;
  font-size: 0.92rem;
}

.message.user {
  align-self: flex-end;
  background: var(--navy);
  color: var(--white);
}

.message.bot {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid rgba(11, 31, 58, 0.08);
}

.message.bot h1,
.message.bot h2,
.message.bot h3 {
  font-family: inherit;
  color: var(--navy);
  margin: 0.2em 0 0.4em;
  font-size: 1rem;
}

.message.bot p {
  margin: 0.4em 0;
}

.message.bot ul,
.message.bot ol {
  margin: 0.4em 0 0.6em 1.2em;
  padding: 0;
}

.message.bot li {
  margin: 0.2em 0;
}

.message.bot a {
  color: var(--teal);
  text-decoration: underline;
}

.message.bot strong {
  color: var(--navy);
}

.message.bot code {
  background: rgba(11, 31, 58, 0.06);
  padding: 0.1em 0.3em;
  border-radius: 6px;
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85em;
}

.message.bot pre {
  background: rgba(11, 31, 58, 0.06);
  padding: 0.6em;
  border-radius: 10px;
  overflow-x: auto;
}

.message.typing {
  font-style: italic;
  color: rgba(46, 58, 70, 0.7);
  background: transparent;
  border: none;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1f3b64;
  font-size: 0.85rem;
  padding: 6px 10px;
  background: rgba(15, 108, 125, 0.08);
  border-radius: 8px;
  margin: 4px 0;
}

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

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--teal);
  border-radius: 50%;
  animation: bounce 1s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.chat-footer {
  padding: 12px 16px 16px;
  background: var(--white);
  border-top: 1px solid rgba(11, 31, 58, 0.08);
}

.chat-footer .reset {
  background: transparent;
  border: none;
  color: var(--teal);
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(11, 31, 58, 0.12);
  font-family: inherit;
}

.input-row button {
  background: var(--teal);
  color: var(--white);
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  70% {
    transform: scale(2.4);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@media (max-width: 1100px) {
  .chat-panel {
    width: 100%;
    min-width: 0;
  }
  body.chat-expanded .chat-panel {
    width: 100%;
  }
  .provider-btn {
    font-size: 0.65rem !important;
    padding: 3px 7px !important;
  }
}


#chatNew {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--white);
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

#chatNew:hover {
  background: rgba(255, 255, 255, 0.22);
}

.chat-actions {
  position: relative;
  z-index: 10002;
}

.chat-bubble, .chat-panel, .voice-bubble {
  pointer-events: auto;
}

/* Voice bubble — above chat bubble */
.voice-bubble {
  position: fixed;
  right: 28px;
  bottom: 90px;
  background: var(--navy);
  color: var(--white);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 20px 50px rgba(11, 31, 58, 0.25);
  z-index: 10001;
}

.voice-bubble .pulse {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--gold);
  border-radius: 50%;
  top: 4px;
  right: 4px;
  animation: pulse 2s infinite;
}

/* Hide bubbles when panels are open */
body.chat-open .voice-bubble,
body.voice-open .chat-bubble,
body.voice-open .voice-bubble {
  display: none;
}
