:root {
  --brand: #5b3f95;
  --brand-dark: #4a327f;
  --accent: #10b3a3;
  --bg: #eef0f5;
  --card: #ffffff;
  --text: #1f2530;
  --muted: #6e7683;
  --shadow: 0 20px 45px rgba(31, 33, 45, 0.2);
  --radius-lg: 20px;
  --radius-md: 14px;
}

.chat-launcher,
.chat-launcher *,
.chat-widget,
.chat-widget * {
  box-sizing: border-box;
}

.chat-launcher,
.chat-widget {
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
}

.page-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 10% 20%, rgba(91, 63, 149, 0.18), transparent 40%),
    radial-gradient(circle at 80% 10%, rgba(16, 179, 163, 0.12), transparent 45%),
    linear-gradient(160deg, rgba(90, 93, 101, 0.08), transparent 40%);
  pointer-events: none;
}

.chat-launcher {
  position: fixed;
  right: 28px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 2000;
  padding: 0;
}

.launcher-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 90deg, var(--brand), var(--accent), var(--brand));
  animation: spin 6s linear infinite;
}

.launcher-core {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #fff url("/Home%20-%20Ministry%20of%20Industry%20and%20Mineral%20Resources_files/chat-bot-logo.svg") center/cover no-repeat;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: transparent;
  font-size: 0;
  line-height: 0;
}

.chat-widget {
  position: fixed;
  right: 28px;
  bottom: 100px;
  width: 380px;
  max-height: 92vh;
  background: transparent;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 1999;
}

.chat-widget.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-frame {
  position: relative;
  background: rgba(255, 255, 255, 1);
  border-radius: 24px;
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: min(78vh, 640px);
}


.chat-breadcrumb {
  margin: -4px 8px 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(91, 63, 149, 0.08);
  color: #2f2a3a;
  font-size: 12px;
  font-weight: 600;
}
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  border-radius: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
}

.logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 0;
  background: url("/Home - Ministry of Industry and Mineral Resources_files/Logo_01-removebg-preview.png") no-repeat center/contain;
  transform: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  font-size: 11px;
  opacity: 0.85;
}

.brand-sub {
  font-size: 12px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-pill {
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
}

.icon-btn {
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
}

.menu-panel {
  position: absolute;
  top: 54px;
  right: 8px;
  width: 220px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: none;
  flex-direction: column;
  gap: 8px;
  z-index: 25;
}

.menu-panel.open {
  display: flex;
}

.menu-item {
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.menu-lang {
  font-weight: 600;
  color: var(--brand);
}

.menu-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
  margin: 4px 0;
}

.hero-area {
  background: transparent;
  padding: 0;
  color: var(--text);
}

.greeting h1 {
  margin: 4px 0 6px;
  font-size: 22px;
}

.greeting p {
  margin: 0 0 14px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
}

.welcome-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 18px;
  color: var(--text);
}

.welcome-card h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.welcome-card p {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.primary-btn {
  width: 100%;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chat-shell {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 14px;
  flex: 1;
  min-height: 260px;
  overflow: hidden;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: 100%;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message.user {
  align-items: flex-end;
}

.message.assistant {
  align-items: flex-start;
}

.bubble {
  max-width: 80%;
  background: #f1f3f7;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 11px;
  line-height: 1.5;
}

.bubble strong {
  font-weight: 700;
}

.bubble em {
  font-style: italic;
}

.bubble div {
  margin-bottom: 6px;
}

.bubble div:last-child {
  margin-bottom: 0;
}

.msg-list {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.msg-list li {
  margin-bottom: 6px;
}

.message.user .bubble {
  background: rgba(16, 179, 163, 0.15);
  border: 1px solid rgba(16, 179, 163, 0.3);
}

.bubble.streaming {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.citations {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  display: block;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 8px;
}

.citations a {
  color: var(--brand);
  text-decoration: none;
}

.citations-title {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 6px;
}

.citations div {
  display: block;
  margin-bottom: 4px;
  word-break: break-word;
}

.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.voice-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  padding: 0 6px;
}

.voice-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
}

.voice-status.connecting::before {
  background: #f0b429;
}

.voice-status.listening::before {
  background: var(--accent);
}

.voice-status.speaking::before {
  background: var(--brand);
}

.voice-status.error::before {
  background: #e05d5d;
}

.chat-input textarea {
  flex: 1;
  border: none;
  resize: none;
  font-family: inherit;
  font-size: 13px;
  background: transparent;
  color: var(--text);
}

.chat-input textarea:focus {
  outline: none;
}

#send-button {
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.voice-button {
  border: 1px solid rgba(0, 0, 0, 0.12);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  color: var(--brand);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.voice-button.recording {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 0 6px rgba(91, 63, 149, 0.12);
  animation: pulse 1.2s ease-in-out infinite;
}

.beta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  color: var(--muted);
  font-size: 11px;
  padding: 0 4px;
}

.beta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(91, 63, 149, 0.2);
}

.status-text {
  display: none;
}

.message-meta {
  font-size: 9px;
  color: var(--muted);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.message-time {
  margin-left: 6px;
}

.message.user .message-meta {
  text-align: right;
}

.chat-widget .hidden {
  display: none;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dots span {
  width: 6px;
  height: 6px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 50%;
  display: inline-block;
  animation: bounce 1s infinite;
}

.dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.dots span:nth-child(3) {
  animation-delay: 0.4s;
}

.chat-widget.rtl {
  font-family: "Noto Sans Arabic", "Manrope", sans-serif;
}

.chat-widget.rtl .app-header,
.chat-widget.rtl .brand {
  flex-direction: row-reverse;
}

.chat-widget.rtl .brand-text,
.chat-widget.rtl .welcome-card {
  text-align: right;
}

.chat-widget.rtl .menu-panel {
  right: auto;
  left: 0;
}

.chat-widget.rtl .menu-item {
  text-align: right;
}

.chat-widget.rtl .chat-input {
  flex-direction: row-reverse;
}

.chat-widget.rtl .chat-input textarea {
  text-align: right;
}

.chat-widget.rtl .beta {
  flex-direction: row-reverse;
}

.chat-widget.rtl .message-meta {
  text-align: right;
}

.chat-widget.rtl .message-time {
  margin-left: 0;
  margin-right: 6px;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
}

.chat-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(91, 63, 149, 0.25); }
  70% { box-shadow: 0 0 0 8px rgba(91, 63, 149, 0.05); }
  100% { box-shadow: 0 0 0 0 rgba(91, 63, 149, 0); }
}

@media (max-width: 520px) {
  .chat-widget {
    right: 12px;
    left: 12px;
    width: auto;
  }

  .chat-launcher {
    right: 16px;
    bottom: 16px;
  }
}

.chat-breadcrumb.home {
  text-decoration: underline;
  text-underline-offset: 3px;
}
