/**
 * Combined Chatbot - Frontend Styles
 * Merges JAMP Chatbot and Hausa TTS Assistant aesthetics
 *
 * @package Combined_Chatbot
 */

/* ==================== Color Palette (JAMP orange theme) ==================== */
:root {
  --ccb-primary: #D15827;
  --ccb-primary-dark: #A84620;
  --ccb-primary-light: #E07947;
  --ccb-primary-pale: #F5D4C7;
  --ccb-primary-ghost: #FDF6F3;
  --ccb-accent: #D97752;
  --ccb-text-dark: #5C2415;
  --ccb-text-medium: #8B4028;
}

/* ==================== Reset ==================== */
#ccb_chatContainer *,
#ccb_floatingButton *,
#ccb_feedback-modal * {
  box-sizing: border-box;
}

/* ==================== Floating Toggle Button ==================== */
.ccb-toggle-btn,
#ccb_floatingButton {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 50;
  background-color: var(--ccb-primary);
  color: white;
  padding: 1rem;
  border-radius: 50%;
  box-shadow:
    0 10px 15px -3px rgba(209, 88, 39, 0.3),
    0 4px 6px -2px rgba(209, 88, 39, 0.2);
  border: none;
  cursor: pointer;
  transition:
    background-color 0.2s,
    transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ccb-toggle-btn:hover,
#ccb_floatingButton:hover {
  background-color: var(--ccb-primary-dark);
  transform: scale(1.1);
}

.ccb-toggle-btn:active,
#ccb_floatingButton:active {
  transform: scale(0.95);
}

.ccb-toggle-btn.hidden,
#ccb_floatingButton.hidden {
  display: none;
}

.ccb-toggle-icon {
  width: 1.5rem;
  height: 1.5rem;
}

/* ==================== Widget Container ==================== */
.ccb-widget-container,
#ccb_chatContainer {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 50;
  display: none;
  flex-direction: row;
  align-items: flex-start;
}

.ccb-widget-container.active,
#ccb_chatContainer.active {
  display: flex;
}

/* ==================== Widget Card ==================== */
.ccb-widget-card {
  background: white;
  border-radius: 1.5rem;
  box-shadow:
    0 20px 25px -5px rgba(209, 88, 39, 0.1),
    0 10px 10px -5px rgba(209, 88, 39, 0.04);
  padding: 1.25rem;
  width: 28rem;
  height: 80vh;
  max-height: 80vh;
  /* dvh accounts for the mobile browser's address bar being visible on
     first load — 80vh is computed against the larger viewport as if it
     were already collapsed, which is taller than what's actually visible,
     pushing this bottom-anchored fixed widget's top edge off-screen until
     the page is scrolled (collapsing the bar and "revealing" the rest).
     Kept alongside the vh version as a fallback for browsers without dvh
     support, which simply ignore this line. */
  height: 80dvh;
  max-height: 80dvh;
  overflow: hidden;
  position: relative;
  border: 2px solid var(--ccb-primary-pale);
  display: flex;
  flex-direction: column;
}

/* ==================== Header Buttons (mute + close) ==================== */
.ccb-header-btns {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  z-index: 10;
}

.ccb-close-btn,
.ccb-mute-btn {
  color: #6b7280;
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.2s, background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ccb-close-btn:hover,
.ccb-mute-btn:hover {
  color: var(--ccb-primary);
  background-color: var(--ccb-primary-ghost);
}

.ccb-close-btn svg,
.ccb-mute-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

.ccb-mute-btn.muted {
  color: var(--ccb-primary);
}

/* ==================== Bot Switch Tabs ==================== */
.ccb-bot-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.ccb-bot-tab {
  flex: 1;
  padding: 0.625rem;
  border: 1px solid var(--ccb-primary-pale);
  border-radius: 0.5rem;
  outline: none;
  background-color: white;
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition:
    border-color 0.2s,
    background-color 0.2s,
    color 0.2s,
    box-shadow 0.2s;
}

.ccb-bot-tab:focus {
  border-color: var(--ccb-primary-light);
  box-shadow: 0 0 0 3px rgba(209, 88, 39, 0.1);
}

.ccb-bot-tab.active[data-tab="jamp"] {
  background-color: var(--ccb-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(209, 88, 39, 0.3);
}

.ccb-bot-tab.active[data-tab="hausa"] {
  background-color: var(--ccb-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(209, 88, 39, 0.3);
}

.ccb-bot-tab svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ==================== Bot Panel Visibility ==================== */
.ccb-bot-panel {
  display: none;
}

.ccb-bot-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ==================== Shared Header Styles ==================== */
.ccb-title {
  font-size: 22px;
  font-weight: bold;
  margin: 0;
}

.ccb-subtitle {
  font-size: 13px;
  color: #6b7280;
  margin: 0.2rem 0 0 0;
  display: block;
}

/* ==================== JAMP Specific Styles ==================== */
.ccb-jamp-header {
  text-align: center;
  margin-bottom: 0.75rem;
}

.ccb-jamp-title-text {
  color: var(--ccb-primary);
}

.ccb-status {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 0.15rem;
  display: none;
}

.ccb-status.active {
  display: block;
}

.ccb-status.connecting {
  color: #eab308;
}

.ccb-status.connected {
  color: #22c55e;
}

.ccb-status.error {
  color: #ef4444;
}

/* Language + Voice row */
.ccb-selects-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.625rem;
}

.ccb-selects-row .ccb-voice-container {
  flex: 1;
  margin-bottom: 0;
}

/* Voice Select */
.ccb-voice-container {
  margin-bottom: 0.625rem;
}

.ccb-voice-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ccb-primary);
  margin-bottom: 0.2rem;
  display: block;
}

.ccb-voice-select {
  padding: 0.45rem 0.625rem;
  width: 100%;
  border: 1px solid var(--ccb-primary-pale);
  border-radius: 0.5rem;
  outline: none;
  background-color: white;
  color: #374151;
  font-size: 14px;
  transition: border-color 0.2s;
}

.ccb-voice-select:focus {
  border-color: var(--ccb-primary-light);
  box-shadow: 0 0 0 3px rgba(209, 88, 39, 0.1);
}

/* Avatar — separate side panel to the left of the widget card, toggled by the
   arrow. A 3:4 aspect (rather than a full 9:16 phone shape) keeps the box from
   growing taller than the avatar's actual content, which was leaving empty
   black space above/below it — the horizontal crop (scale below) already
   matches the content's width, so only the aspect ratio needed to change,
   not the scale. */
.ccb-avatar-panel {
  position: relative;
  width: 22rem;
  aspect-ratio: 3 / 4;
  max-height: 80vh;
  max-height: 80dvh; /* see .ccb-widget-card's dvh note above */
  flex-shrink: 0;
  margin-right: 0.75rem;
  /* White (not dark) — the avatar's own content sits on a white background,
     so this only ever shows as a thin sliver at the rounded corners/edges
     where the scaled iframe doesn't fully reach, and white blends into that
     content invisibly instead of showing as a visible gray/dark ring. */
  background-color: #fff;
  border-radius: 1.5rem;
  overflow: hidden;
  /* Same 15%-tint math as --ccb-primary-pale (the widget card's border), but
     baked into an opaque color via color-mix instead of alpha transparency —
     --ccb-primary-pale is a translucent rgba(), so it only reads as pale
     against the widget card's white background; composited over this
     panel's dark fill it muddied toward black instead. color-mix produces
     the same pale result regardless of what's behind it. */
  border: 2px solid color-mix(in srgb, var(--ccb-primary) 15%, white);
  box-shadow:
    0 20px 25px -5px rgba(209, 88, 39, 0.1),
    0 10px 10px -5px rgba(209, 88, 39, 0.04);
  transition: width 0.3s ease, margin-right 0.3s ease, opacity 0.3s ease, border-width 0.3s ease;
}

/* Toggled closed via JS — collapses/slides the panel away rather than hiding
   it outright, so the arrow can animate it back open (unlike .ccb-hidden,
   which is only for "Avatar isn't the selected language at all"). */
.ccb-avatar-panel.ccb-collapsed {
  width: 0;
  margin-right: 0;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
}

/* Scaled up and center-cropped to cut the OpenAvatarChat UI's own margins —
   same technique JAMP's own custom2_faq_bot.html uses around its avatar iframe. */
.ccb-avatar-frame {
  display: block;
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 100%;
  border: 0;
  transform: translateY(-50%) scale(1.6);
}

/* Covers the iframe while it's connecting (first open, or reconnecting after
   stopAllPlayback tore it down on close) so the user sees a spinner instead
   of a blank panel. Hidden once "avatar_session_ready" arrives. */
.ccb-avatar-loader {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  transition: opacity 0.25s ease;
}

.ccb-avatar-loader.ccb-hidden {
  opacity: 0;
  pointer-events: none;
}

.ccb-avatar-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 3px solid var(--ccb-primary-pale);
  border-top-color: var(--ccb-primary);
  animation: ccb-avatar-spin 0.8s linear infinite;
}

@keyframes ccb-avatar-spin {
  to { transform: rotate(360deg); }
}

.ccb-avatar-name {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 5;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  background-color: var(--ccb-primary);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  pointer-events: none;
}

.ccb-avatar-status-dot {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #9ca3af;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.ccb-avatar-status-dot.ccb-ready {
  background-color: #4ade80;
}

.ccb-avatar-status-dot.ccb-speaking {
  animation: ccb-avatar-pulse 1s ease-in-out infinite;
}

@keyframes ccb-avatar-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(74, 222, 128, 0.6); }
  50%      { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), 0 0 0 6px rgba(74, 222, 128, 0); }
}

/* Arrow toggle — inset from the widget card's top-left corner, mirroring
   .ccb-header-btns on the top-right. Kept fully inside the card's bounds
   (no straddling/negative offset) since the card clips overflow, which was
   cutting the button off when it sat on the seam between the two panels. */
.ccb-avatar-toggle {
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background-color: var(--ccb-primary);
  color: white;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}

.ccb-avatar-toggle-icon {
  width: 1rem;
  height: 1rem;
  transition: transform 0.3s ease;
}

/* Open state points left (collapse); closed state points right (expand) */
.ccb-avatar-toggle:not(.ccb-open) .ccb-avatar-toggle-icon {
  transform: rotate(180deg);
}

/* Chat Container */
.ccb-chat-container {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  padding: 1rem;
  background-color: var(--ccb-primary-ghost);
  border-radius: 0.75rem;
  border: 1px solid var(--ccb-primary-pale);
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--ccb-primary-pale) transparent;
}

.ccb-chat-container::-webkit-scrollbar {
  width: 5px;
}

.ccb-chat-container::-webkit-scrollbar-track {
  background: transparent;
}

.ccb-chat-container::-webkit-scrollbar-thumb {
  background: var(--ccb-primary-pale);
  border-radius: 3px;
}

.ccb-messages {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ==================== Messages (shared) ==================== */
.ccb-message {
  padding: 0.875rem 1.125rem;
  border-radius: 0.75rem;
  max-width: 80%;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  font-size: 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.6;
}

.ccb-message.user {
  background-color: var(--ccb-primary-pale);
  color: var(--ccb-text-dark);
  margin-left: auto;
  border: 1px solid var(--ccb-accent);
}

.ccb-message.assistant {
  background-color: white;
  color: var(--ccb-text-dark);
  border: 1px solid var(--ccb-primary-pale);
}

/* Markdown content inside assistant messages */
.ccb-message h1, .ccb-message h2, .ccb-message h3,
.ccb-message h4, .ccb-message h5, .ccb-message h6 {
  font-size: 0.82em;
  font-weight: 700;
  margin: 0.75em 0 0.25em;
  color: var(--ccb-primary);
  line-height: 1.3;
  padding-bottom: 0.2em;
  border-bottom: 1px solid var(--ccb-primary-pale);
}

.ccb-message p { margin: 0.4em 0; }
.ccb-message ul, .ccb-message ol { margin: 0.4em 0; padding-left: 1.25em; }
.ccb-message li { margin: 0.2em 0; }
.ccb-message strong { color: var(--ccb-text-dark); }
.ccb-message code {
  background: var(--ccb-primary-pale);
  border-radius: 3px;
  padding: 0.1em 0.3em;
  font-size: 0.85em;
}

/* Inline audio-loading indicator inside Hausa message bubble */
.ccb-audio-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--ccb-primary-pale);
}

.ccb-audio-loading .ccb-loading-dots {
  display: flex;
  gap: 4px;
}

.ccb-audio-loading .ccb-dot {
  width: 6px;
  height: 6px;
}

.ccb-audio-loading-label {
  font-size: 11px;
  color: var(--ccb-primary);
  opacity: 0.75;
}

/* ==================== Loading Indicator ==================== */
.ccb-loading,
.ccb-loading-overlay {
  display: none;
  justify-content: flex-start;
  padding: 1.5rem;
}

.ccb-loading.active,
.ccb-loading-overlay.active {
  display: flex;
}

.ccb-loading-dots {
  display: flex;
  gap: 0.5rem;
}

.ccb-dot {
  width: 0.75rem;
  height: 0.75rem;
  background-color: var(--ccb-primary-light);
  border-radius: 50%;
  animation: ccbWave 0.8s infinite;
}

.ccb-dot-delay-1 {
  animation-delay: 0.2s;
}

.ccb-dot-delay-2 {
  animation-delay: 0.4s;
}

.ccb-dot-delay-3 {
  animation-delay: 0.6s;
}

@keyframes ccbWave {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }
}

/* ==================== JAMP Input Container ==================== */
.ccb-input-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ccb-input {
  flex: 1;
  padding: 0.875rem;
  font-size: 14px;
  border: 1px solid var(--ccb-primary-pale);
  border-radius: 0.75rem;
  outline: none;
  background-color: white;
  color: #374151;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ccb-input::placeholder {
  color: #9ca3af;
}

.ccb-input:focus {
  border-color: var(--ccb-primary-light);
  box-shadow: 0 0 0 3px rgba(209, 88, 39, 0.1);
}

.ccb-send-btn {
  background-color: var(--ccb-primary);
  color: white;
  padding: 0.6rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ccb-send-btn:hover {
  background-color: var(--ccb-primary-dark);
}

.ccb-send-btn:active {
  opacity: 0.85;
}

.ccb-send-icon {
  width: 1rem;
  height: 1rem;
  transform: rotate(90deg);
}


/* Mic button (voice input) */
.ccb-mic-btn {
  background-color: var(--ccb-primary);
  color: white;
  padding: 0.6rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ccb-mic-btn:hover {
  background-color: var(--ccb-primary-dark);
}

.ccb-mic-btn:active {
  opacity: 0.85;
}

.ccb-mic-btn.recording {
  background-color: #ef4444;
  animation: ccbRecordPulse 1.5s ease-in-out infinite;
}

.ccb-mic-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ==================== Hausa TTS Specific Styles ==================== */
.ccb-hausa-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.ccb-hausa-title-text {
  color: var(--ccb-primary);
}

/* Hausa Tabs */
.ccb-hausa-tabs {
  margin-bottom: 1.5rem;
  display: flex;
  gap: 0.5rem;
}

.ccb-hausa-tab {
  flex: 1;
  padding: 0.625rem;
  border: 1px solid var(--ccb-primary-pale);
  border-radius: 0.5rem;
  outline: none;
  background-color: white;
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition:
    border-color 0.2s,
    background-color 0.2s,
    color 0.2s,
    box-shadow 0.2s;
}

.ccb-hausa-tab:focus {
  border-color: var(--ccb-primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.ccb-hausa-tab.active {
  background-color: var(--ccb-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ccb-hausa-tab svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Hausa Chat Body */
.ccb-hausa-chat-body {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background-color: var(--ccb-primary-ghost);
  border-radius: 0.75rem;
  border: 1px solid var(--ccb-primary-pale);
  max-height: calc(80vh - 320px);
  min-height: 220px;
}

.ccb-hausa-chat-body::-webkit-scrollbar {
  width: 5px;
}

.ccb-hausa-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.ccb-hausa-chat-body::-webkit-scrollbar-thumb {
  background: var(--ccb-primary-pale);
  border-radius: 3px;
}

.ccb-conversation {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Hausa Messages */
.ccb-hausa-message {
  padding: 0.875rem 1.125rem;
  border-radius: 0.75rem;
  max-width: 80%;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  font-size: 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.6;
  animation: ccbSlideIn 0.2s ease-out;
}

@keyframes ccbSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ccb-hausa-user-message {
  background-color: var(--ccb-primary-pale);
  color: var(--ccb-text-dark);
  margin-left: auto;
  border: 1px solid var(--ccb-accent);
}

.ccb-hausa-assistant-message {
  background-color: white;
  color: var(--ccb-text-dark);
  border: 1px solid var(--ccb-primary-pale);
  align-self: flex-start;
}

/* ==================== Tab content visibility ==================== */
.ccb-hausa-tab-content {
  display: none;
}

.ccb-hausa-tab-content.active {
  display: block;
}

/* Hausa Text Input */
.ccb-hausa-input-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ccb-hausa-text-input {
  flex: 1;
  padding: 0.875rem;
  font-size: 14px;
  border: 1px solid var(--ccb-primary-pale);
  border-radius: 0.75rem;
  outline: none;
  background-color: white;
  color: #374151;
  font-family: inherit;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  height: auto;
}

.ccb-hausa-text-input::placeholder {
  color: #9ca3af;
}

.ccb-hausa-text-input:focus {
  border-color: var(--ccb-primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.ccb-hausa-submit-button {
  background-color: var(--ccb-primary);
  color: white;
  padding: 0.875rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition:
    background-color 0.2s,
    transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ccb-hausa-submit-button:hover {
  background-color: var(--ccb-primary-dark);
  transform: scale(1.05);
}

.ccb-hausa-submit-button:active {
  transform: scale(0.95);
}

.ccb-hausa-submit-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ccb-hausa-submit-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: white;
  transform: rotate(90deg);
}

/* Voice Input Section */
.ccb-hausa-voice-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem 0 0.5rem;
}

.ccb-hausa-record-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--ccb-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 0.2s,
    transform 0.1s;
  box-shadow:
    0 10px 15px -3px rgba(99, 102, 241, 0.3),
    0 4px 6px -2px rgba(99, 102, 241, 0.2);
}

.ccb-hausa-record-button:hover {
  background-color: var(--ccb-primary-dark);
  transform: scale(1.05);
}

.ccb-hausa-record-button:active {
  transform: scale(0.95);
}

.ccb-hausa-record-button.recording {
  background-color: #ef4444;
  animation: ccbRecordPulse 1.5s ease-in-out infinite;
}

@keyframes ccbRecordPulse {
  0%, 100% {
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 6px 30px rgba(239, 68, 68, 0.65);
  }
}

.ccb-hausa-mic-icon {
  width: 18px;
  height: 18px;
  color: white;
}

.ccb-hausa-timer {
  font-size: 22px;
  font-weight: 700;
  color: var(--ccb-text-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.ccb-hausa-recording-status {
  font-size: 13px;
  color: #9ca3af;
  text-align: center;
  font-weight: 500;
  padding: 5px 12px;
  background: white;
  border-radius: 0.5rem;
  border: 1px solid var(--ccb-primary-pale);
  transition: color 0.2s;
}

/* Waveform visualizer */
.ccb-hausa-visualizer {
  display: block;
  width: 100%;
  max-width: 220px;
  height: 44px;
  border-radius: 0.5rem;
  background: var(--ccb-primary-ghost);
  border: 1px solid var(--ccb-primary-pale);
}

.ccb-hausa-timer-row {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Audio Player */
.ccb-hausa-audio-player-container {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.ccb-hausa-audio-player-container.ccb-hidden {
  display: none !important;
}

.ccb-hausa-audio-player {
  width: 100%;
  accent-color: var(--ccb-primary);
}

/* Inline Audio Player (per-message) */
.ccb-hausa-inline-audio-wrapper {
  margin-top: 0.75rem;
  width: 100%;
}

.ccb-hausa-inline-audio {
  width: 100%;
  height: 32px;
  border-radius: 0.5rem;
  outline: none;
  accent-color: var(--ccb-primary);
}

.ccb-hausa-inline-audio::-webkit-media-controls-panel {
  background-color: var(--ccb-primary-ghost);
}

/* ==================== Feedback Buttons (JAMP) ==================== */
.feedback-buttons {
  margin-top: 1.5rem;
  display: flex;
  gap: 1.5rem;
}

.feedback-buttons button {
  border: 1px solid #d1d5db;
  padding: 0.625rem;
  border-radius: 50%;
  background-color: white;
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.2s;
}

.feedback-buttons button:hover {
  background-color: var(--ccb-primary-ghost);
  border-color: var(--ccb-primary-pale);
}

.feedback-buttons button svg {
  width: 1.5rem;
  height: 1.5rem;
  color: #9ca3af;
}

.feedback-buttons button.bg-green-100 {
  background-color: #dcfce7;
  border-color: #86efac;
}

.feedback-buttons button.bg-red-100 {
  background-color: #fee2e2;
  border-color: #fca5a5;
}

/* ==================== Audio Player (JAMP) ==================== */
.audio-player {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.audio-player .play-pause {
  background-color: var(--ccb-primary);
  color: white;
  padding: 0.625rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
  flex-shrink: 0;
  /* Without this, the inline SVG icons' baseline gap makes the button
     slightly taller than wide, so the border-radius circle reads as an oval
     instead of a perfect circle. */
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-player .play-pause:hover {
  background-color: var(--ccb-primary-dark);
}

.audio-player .play-pause svg {
  width: 1.25rem;
  height: 1.25rem;
}

.audio-player .hidden {
  display: none;
}

.audio-player .progress {
  flex: 1;
  min-width: 120px;
  accent-color: var(--ccb-primary);
}

.audio-player .time {
  font-size: 19px;
  color: var(--ccb-text-medium);
  flex-shrink: 0;
}

.audio-player .download {
  background-color: var(--ccb-primary-pale);
  color: var(--ccb-primary-dark);
  padding: 0.625rem;
  border-radius: 50%;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-player .download:hover {
  background-color: var(--ccb-accent);
}

.audio-player .download svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ==================== Modal ==================== */
.ccb-modal {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(92, 36, 21, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.ccb-modal.active {
  display: flex;
}

.ccb-modal-content {
  background-color: white;
  border-radius: 0.5rem;
  padding: 2rem;
  width: 100%;
  max-width: 28rem;
  border: 2px solid var(--ccb-primary-pale);
}

.ccb-modal-title {
  font-size: 23px;
  font-weight: bold;
  color: var(--ccb-primary);
  margin: 0 0 1.5rem 0;
}

.ccb-modal-textarea {
  width: 100%;
  padding: 0.875rem;
  font-size: 19px;
  border: 1px solid var(--ccb-primary-pale);
  border-radius: 0.75rem;
  outline: none;
  margin-bottom: 1.5rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ccb-modal-textarea:focus {
  border-color: var(--ccb-primary-light);
  box-shadow: 0 0 0 3px rgba(209, 88, 39, 0.1);
}

.ccb-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.ccb-modal-cancel,
.ccb-modal-submit {
  padding: 0.625rem 1rem;
  border-radius: 0.75rem;
  border: none;
  cursor: pointer;
  font-size: 19px;
  transition: background-color 0.2s, transform 0.1s;
}

.ccb-modal-cancel {
  background-color: #d1d5db;
  color: #374151;
}

.ccb-modal-cancel:hover {
  background-color: #9ca3af;
}

.ccb-modal-submit {
  background-color: var(--ccb-primary);
  color: white;
}

.ccb-modal-submit:hover {
  background-color: var(--ccb-primary-dark);
}

.ccb-modal-cancel:active,
.ccb-modal-submit:active {
  transform: scale(0.95);
}

/* ==================== Utility ==================== */
.ccb-hidden,
.hidden {
  display: none !important;
}

/* ==================== Mobile Responsive ==================== */

/* Medium screens (tablets, small laptop windows): the row layout (avatar
   panel beside the widget card, 22rem + 28rem + gaps ≈ 830px) doesn't fit —
   the avatar panel was overflowing off the left edge below that. Stacking
   them also means the widget card can no longer keep its fixed 80vh height
   (avatar panel + card together would exceed the viewport and push off the
   top) — it has to become shrinkable so the two share whatever vertical
   room is actually available. */
@media (max-width: 900px) {
  .ccb-widget-container,
  #ccb_chatContainer {
    flex-direction: column;
    align-items: flex-end;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem); /* see .ccb-widget-card's dvh note above */
  }

  .ccb-widget-card {
    height: auto;
    max-height: 75vh;
    max-height: 75dvh;
    flex: 1 1 auto;
    min-height: 0;
  }

  .ccb-avatar-panel {
    width: min(60vw, 16rem);
    max-width: 100%;
    max-height: 40vh;
    max-height: 40dvh;
    margin-right: 0;
    margin-bottom: 0.75rem;
    align-self: flex-end;
    flex-shrink: 0;
  }

  .ccb-avatar-panel.ccb-collapsed {
    margin-bottom: 0;
  }
}

/* Narrow screens: shift inward so widget isn't flush against right edge,
   and go full-width instead of the fixed 28rem card. */
@media (max-width: 520px) {
  .ccb-widget-container,
  #ccb_chatContainer {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    align-items: stretch;
    max-height: calc(100vh - 1rem);
    max-height: calc(100dvh - 1rem);
  }

  .ccb-widget-card {
    width: 100%;
    max-height: 80vh;
    max-height: 80dvh;
    flex: 1 1 auto;
    min-height: 0;
  }

  .ccb-avatar-panel {
    /* aspect-ratio derives height from this width, so shrinking width alone
       keeps the panel in proportion — no separate height rule needed. The
       max-height is just a backstop for unusually short viewports. */
    width: min(70vw, 16rem);
    max-height: 40vh;
    max-height: 40dvh;
    align-self: center;
  }
}

/* Very small screens: full-height sheet from bottom */
@media (max-width: 400px) {
  .ccb-widget-container,
  #ccb_chatContainer {
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    align-items: flex-end;
    justify-content: flex-end;
  }

  .ccb-widget-card {
    border-radius: 1.5rem 1.5rem 0 0;
    max-height: 95vh;
    max-height: 95dvh;
    width: 100vw;
    margin: 0;
  }

  .ccb-avatar-panel {
    align-self: center;
  }
}

/* Touch devices: disable hover scale effects */
@media (hover: none) and (pointer: coarse) {
  .audio-player .progress {
    min-width: 80px;
  }

  .audio-player .time {
    font-size: 13px;
  }
}


/* ==================== Reduced Motion ==================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
