/* Layout: Make row for controls + widget */
#blue-widget-layout-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-end;
  width: 100%;
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 99998;
  pointer-events: none;
}

/* Controls: always on outside left of widget, never overlaying, vertical column, centered */
#blue-widget-outside-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto;
  position: fixed;
  right: calc(25vw + 32px); /* Desktop: stick to left of widget */
  bottom: 1.5vw;
  z-index: 999999;
  gap: 16px;
}
#blue-widget-mic-btn, #blue-widget-mute-btn {
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: #fff;
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(14,165,233,0.12);
  opacity: 0.3;
  transition: opacity 0.19s, background 0.18s, box-shadow 0.15s;
  z-index: 999999;
  outline: none;
  pointer-events: auto;
}
#blue-widget-mic-btn:focus, #blue-widget-mic-btn.listening,
#blue-widget-mic-btn:hover,
#blue-widget-mute-btn:focus, #blue-widget-mute-btn.muted,
#blue-widget-mute-btn:hover {
  opacity: 1 !important;
}
#blue-widget-mute-btn.muted {
  background: linear-gradient(135deg, #f87171 0%, #be123c 100%);
}

/* Widget container is always to the right of controls */
#blue-widget-container {
  position: fixed;
  right: 1.5vw;
  bottom: 1.5vw;
  left: auto;
  width: 25vw;
  min-width: 220px;
  max-width: 100vw;
  height: 25vh;
  min-height: 180px;
  max-height: 100vh;
  z-index: 99999;
  box-shadow: 0 8px 32px rgba(2,132,199,0.13), 0 4px 16px rgba(14,165,233,0.16);
  border-radius: 18px 18px 12px 12px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(30,41,59,0.68) 0%, rgba(23,35,59,0.67) 100%);
  backdrop-filter: blur(6px) saturate(135%);
  transition: height 0.3s, width 0.3s, background 0.3s, border-radius 0.3s;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

/* Avatar as absolute background, always circular, always centered */
#blue-widget-avatar-bg {
  position: absolute;
  z-index: 0;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
}
#avatar-gif {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: 50%;
  opacity: 0.95;
  filter: drop-shadow(0 2px 32px rgba(14,165,233,0.12));
}

/* Widget content always in front of avatar background */
#blue-widget-bar,
#blue-widget-inner {
  position: relative;
  z-index: 2;
  background: transparent;
}

#blue-widget-bar {
  background: linear-gradient(135deg, #0ea5e9 0%, #1866af 100%);
  color: #fff;
  height: 36px;
  line-height: 36px;
  text-align: right;
  font-weight: bold;
  letter-spacing: 1.5px;
  cursor: pointer;
  padding: 0 20px;
  font-size: 1rem;
  font-family: 'Poppins', sans-serif;
  user-select: none;
  transition: background 0.18s, border-radius 0.3s, position 0.3s, opacity 0.18s, box-shadow 0.28s;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.13);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  opacity: 0.675; /* 25% more transparent than .9 */
}

#blue-widget-bar:hover, #blue-widget-container:hover #blue-widget-bar {
  opacity: 1 !important;
}

#blue-widget-bar.faded {
  opacity: 0.05 !important;
}

/* Collapse bar moves to bottom of screen, always aligns to right when collapsed */
#blue-widget-container.collapsed {
  height: 36px !important;
  min-height: 0 !important;
  max-height: 36px !important;
  width: 100vw !important;
  left: auto !important;
  right: 0 !important;
  bottom: 0 !important;
  border-radius: 0 !important;
  transition: all 0.33s cubic-bezier(.4,0,.2,1);
}
#blue-widget-container.collapsed #blue-widget-avatar-bg,
#blue-widget-container.collapsed #blue-widget-inner {
  display: none !important;
}
#blue-widget-container.collapsed #blue-widget-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw; /* Make the bar stretch the full width of the screen */
  border-radius: 0 !important;
}

#blue-widget-outside-controls.collapsed {
  display: none !important;
}

/* -- Remaining unchanged widget/inner/inputs/buttons styles ... -- */
#blue-widget-bar.limited {
  background: linear-gradient(135deg, #ee4b6a 0%, #5d191a 100%) !important;
  color: #fff !important;
}

#blue-widget-inner {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow-y: auto;
  color: #d1d5db;
  transition: max-height 0.35s cubic-bezier(.4,0,.2,1);
  max-height: 1000px;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  background: transparent;
  opacity: 0.9;
}
#blue-widget-display-text {
  position: relative;
  z-index: 3;
  width: 100%;
  text-align: center;
  padding: 0 12px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
}
#blue-widget-display-text span,
#blue-widget-overlay-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  width: 100%;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 8px rgba(30,41,59,0.44);
  background: rgba(0,0,0,0.06);
  border-radius: 7px;
  padding: 1px 7px;
  opacity: 0.95;
  margin: 0 auto;
}
#blue-widget-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  margin-bottom: 6px;
  font-size: 1rem;
  color: #e0eaff;
  font-family: 'Poppins', sans-serif;
  opacity: 0.92;
  background: transparent;
}
#blue-widget-form {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  background: transparent;
  opacity: 0.87;
}
.blue-widget-sender {
  color: #174075 !important; /* deep/dark blue */
  font-weight: 700;
  letter-spacing: 0.03em;
}

#blue-widget-input {
  flex: 1 1 auto;
  border-radius: 8px;
  padding: 7px 10px;
  border: 1.5px solid #0ea5e9;
  background: rgba(19,30,53,0.82);
  color: #fff;
  font-size: 1rem;
  font-family: 'Poppins', sans-serif;
  box-shadow: 0 2px 7px rgba(14,165,233,0.10);
  opacity: 0.85;
}
#blue-widget-submit {
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: #fff;
  font-weight: 700;
  padding: 0 16px;
  cursor: pointer;
  font-size: 1rem;
  font-family: 'Poppins', sans-serif;
  box-shadow: 0 2px 8px rgba(14,165,233,0.12);
  transition: background 0.18s, box-shadow 0.15s;
  opacity: 0.85;
}
#blue-widget-submit:hover { 
  background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
  box-shadow: 0 4px 14px rgba(14,165,233,0.19);
  opacity: 1;
}

#blue-widget-bar-text {
  width: 100%;
  margin-bottom: 6px;
  margin-top: 2px;
  text-align: center;
  background: rgba(13,23,36,0.12);
  border-radius: 6px;
  opacity: 0.9;
  min-height: 1.1em;
  max-height: 2.3em;
  display: flex;
  align-items: center;
  justify-content: center;
}
#blue-widget-bar-text-content {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  font-size: 1rem;
  color: #f1f5fa;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  width: 100%;
}

/* Responsive: always anchor widget to bottom right, controls to left, and 50vw width on mobile */
@media (max-width: 800px) {
  #blue-widget-layout-row {
    justify-content: flex-end;
    align-items: flex-end;
    width: 100vw;
    right: 0;
    left: 0;
    bottom: 0;
    position: fixed;
    pointer-events: none;
  }
  #blue-widget-container {
    width: 50vw !important;
    min-width: 0 !important;
    left: auto !important;
    right: 2vw !important;
    height: 32vh;
    bottom: 1vw;
    border-radius: 14px 14px 9px 9px;
    padding: 0;
    max-height: 46vh;
    pointer-events: auto;
  }
  #blue-widget-outside-controls {
    right: calc(50vw + 32px);
    left: auto;
    bottom: 2vw;
    position: fixed;
    gap: 12px;
  }
  #blue-widget-inner {
    padding: 7px 4px;
    font-size: 0.95rem;
  }
  #blue-widget-form {
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    margin-top: 5px;
  }
  #blue-widget-input {
    font-size: 0.92rem;
    padding: 6px 9px;
  }
  #blue-widget-submit {
    font-size: 0.92rem;
    padding: 6px 0;
    width: 100%;
  }
  #blue-widget-bar-text-content,
  #blue-widget-display-text span,
  #blue-widget-overlay-text {
    font-size: 0.78rem !important;
  }
}

/* Optional: always pointer-events: auto for mic/mute for easier touch interaction */
#blue-widget-mic-btn, #blue-widget-mute-btn {
  pointer-events: auto !important;
}

#blue-widget-bar.thinking {
  box-shadow: 0 0 16px 4px #38bdf8aa, 0 0 0 0 #38bdf8;
}

#blue-widget-bar-text {
  transition: opacity 0.5s;
  opacity: 0;
}

#blue-widget-bar-text,
#blue-widget-bar-text-content {
  color: #dbc761 !important; /* dark, modern yellow */
  font-weight: 700;
  letter-spacing: 0.02em;
}
