.chiroai-widget-container {
  box-sizing: border-box;
  width: 100%;
  margin: 0 0 1rem 0;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  color: #e5e7eb;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Ensure block stays at the beginning of chat history */
  order: -1;
  flex-shrink: 0;
}

/* Ensure the block container is positioned at the start */
.mwai-conversation .chiroai-widget-container {
  order: -1;
}

/* If blocks are rendered in a different container, ensure our block is first */
.mwai-message:has(.chiroai-widget-container),
.mwai-reply:has(.chiroai-widget-container) {
  order: -1;
}

.chiroai-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.chiroai-avatar {
  width: 36px;
  height: 36px;
  /* border-radius: 999px; */
  /* background: radial-gradient(circle at 30% 20%, #e879f9 0, #a855f7 40%, #4f46e5 100%); */
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #f9fafb;
  /* box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.9), 0 12px 25px rgba(79, 70, 229, 0.7); */
  /* overflow: hidden; */
}

.chiroai-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 999px;
}

.chiroai-title {
  font-weight: 600;
  font-size: 1rem;
  color: #f9fafb;
}

.chiroai-subtitle {
  text-align: center;
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: #cbd5f5;
}

.chiroai-question-list {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.chiroai-question-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.7);
  color: #e5e7eb;
  font-size: 1rem;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.chiroai-question-item:hover,
.chiroai-question-item:focus-visible {
  background: rgba(55, 0, 122, 0.9);
  border-color: rgba(55, 0, 122, 0.9);
  box-shadow: 0 0 0 1px rgba(55, 0, 122, 0.6), 0 10px 20px rgba(55, 0, 122, 0.45);
  outline: none;
  transform: translateY(-1px);
}

.chiroai-question-item:active {
  transform: translateY(0);
  box-shadow: 0 0 0 1px rgba(55, 0, 122, 0.8), 0 4px 10px rgba(55, 0, 122, 0.6);
}

.chiroai-question-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  flex-shrink: 0;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #e879f9 0, #a855f7 40%, #4f46e5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #f9fafb;
  line-height: 1;
  text-align: center;
}

.chiroai-question-text {
  white-space: normal;
}

@media (max-width: 768px) {
  .chiroai-widget-container {
    padding: 0.9rem 0.9rem;
    border-radius: 10px;
  }

  .chiroai-question-list {
    gap: 0.4rem;
  }

  .chiroai-question-item {
    font-size: 0.78rem;
    padding: 0.35rem 0.6rem;
  }

  .chiroai-question-text {
    white-space: normal;
  }
}

/* Language Selector Styles */
.mwai-language-selector {
  position: relative;
  display: inline-block;
  margin-right: 8px;
  z-index: 10;
}

.mwai-language-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 10px;
  /* Match submit button height using CSS variables + slightly taller */
  height: calc(var(--mwai-submitHeight, var(--mwai-submitSize, 40px)) + 4px);
  min-height: calc(var(--mwai-submitHeight, var(--mwai-submitSize, 40px)) + 4px);
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 6px;
  color: #e5e7eb;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
  outline: none;
  user-select: none;
  white-space: nowrap;
  box-sizing: border-box;
}

.mwai-language-button:hover,
.mwai-language-button:focus-visible {
  background: rgba(55, 0, 122, 0.9);
  border-color: rgba(55, 0, 122, 0.9);
  box-shadow: 0 0 0 1px rgba(55, 0, 122, 0.6), 0 4px 8px rgba(55, 0, 122, 0.3);
  outline: none;
  transform: translateY(-1px);
}

.mwai-language-button:active {
  transform: translateY(0);
  box-shadow: 0 0 0 1px rgba(55, 0, 122, 0.8), 0 2px 4px rgba(55, 0, 122, 0.4);
}

.mwai-language-button[aria-expanded="true"] {
  background: rgba(55, 0, 122, 0.9);
  border-color: rgba(55, 0, 122, 0.9);
}

.mwai-language-code {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1;
}

.mwai-language-arrow {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
  display: inline-block;
  line-height: 1;
  opacity: 0.8;
}

.mwai-language-button[aria-expanded="true"] .mwai-language-arrow {
  transform: rotate(180deg);
  opacity: 1;
}

.mwai-language-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: auto;
  margin-bottom: 5px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  max-height: 300px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 180px;
  max-width: 250px;
  z-index: 1000;
  padding: 4px 0;
  /* Custom scrollbar styling for better UX */
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* Webkit scrollbar styling */
.mwai-language-dropdown::-webkit-scrollbar {
  width: 8px;
}

.mwai-language-dropdown::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 4px;
}

.mwai-language-dropdown::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.mwai-language-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Dropdown is always positioned above the button */

.mwai-language-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  color: #1f2937;
  font-size: 0.875rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  outline: none;
  box-sizing: border-box;
}

.mwai-language-item:hover,
.mwai-language-item:focus-visible {
  background-color: #f3f4f6;
  color: #111827;
  outline: none;
}

.mwai-language-item:active {
  background-color: #e5e7eb;
}

.mwai-language-item-selected {
  background-color: #eef2ff;
  color: #4f46e5;
  font-weight: 600;
}

.mwai-language-item-selected:hover,
.mwai-language-item-selected:focus-visible {
  background-color: #e0e7ff;
  color: #4338ca;
}

.mwai-language-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Positioning: Language selector should be before submit button */
.mwai-input {
  position: relative;
}

.mwai-input .mwai-language-selector {
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
}

/* Ensure language selector doesn't overlap with textarea */
.mwai-input .mwai-input-text {
  padding-right: calc(var(--mwai-submitWidth, 40px) + var(--mwai-submitRight, 12px) + 60px);
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  /* Ensure input container uses flexbox for proper alignment */
  .mwai-input {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
  }

  /* ChatGPT theme specific mobile styles */
  .mwai-chatgpt-theme .mwai-input {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .mwai-chatgpt-theme .mwai-input .mwai-input-text {
    flex: 6;
  }

  .mwai-input .mwai-language-selector {
    margin-right: 0;
    display: inline-flex;
    align-items: center;
    flex: 1;
  }

  .mwai-language-button {
    padding: 0 8px;
    /* Match submit button height on mobile + slightly taller */
    height: calc(var(--mwai-submitHeight, var(--mwai-submitSize, 40px)) + 4px);
    min-height: calc(var(--mwai-submitHeight, var(--mwai-submitSize, 40px)) + 4px);
    font-size: 0.8rem;
    gap: 3px;
  }

  .mwai-language-code {
    font-size: 0.8rem;
  }

  .mwai-language-arrow {
    font-size: 0.65rem;
  }

  .mwai-language-dropdown {
    min-width: 160px;
    max-width: 220px;
    max-height: 250px;
    margin-bottom: 4px;
    /* Shift dropdown to the left on mobile to prevent overflow */
    left: auto;
    right: 0;
    transform: translateX(0);
  }

  .mwai-language-item {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .mwai-input .mwai-input-text {
    padding-right: calc(var(--mwai-submitWidth, 40px) + var(--mwai-submitRight, 8px) + 55px);
  }
}

@media (max-width: 480px) {
  .mwai-language-button {
    padding: 0 6px;
    /* Match submit button height on small mobile + slightly taller */
    height: calc(var(--mwai-submitHeight, var(--mwai-submitSize, 40px)) + 4px);
    min-height: calc(var(--mwai-submitHeight, var(--mwai-submitSize, 40px)) + 4px);
    font-size: 0.75rem;
    gap: 2px;
  }

  .mwai-language-code {
    font-size: 0.75rem;
  }

  .mwai-language-arrow {
    font-size: 0.65rem;
  }

  .mwai-language-dropdown {
    min-width: 140px;
    max-width: 180px;
    max-height: 200px;
    margin-bottom: 3px;
    /* Shift dropdown to the left on small mobile to prevent overflow */
    left: auto;
    right: 0;
    transform: translateX(0);
  }

  .mwai-language-item {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  .mwai-input .mwai-input-text {
    padding-right: calc(var(--mwai-submitWidth, 40px) + var(--mwai-submitRight, 6px) + 50px);
  }
}


