:root {
  --primary: #ED480D;
  --primary-hover: #D63F0B;
  --primary-subtle: #FBEAE2;
  --primary-gradient: linear-gradient(135deg, #E64000 0%, #FF6838 100%);
  --widget-border: #ED480D;

  --dark: #20242C;
  --dark-surface: #2A2F3A;

  --bg-page: #F8F7F4;
  --bg-card: #FFFFFF;
  --bg-subtle: #F4F3F0;

  --text-main: #20242C;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --text-inverse: #FFFFFF;

  --border-color: #E5E0D8;
  --border-subtle: #ECE7DE;

  --danger: #DC3545;
  --success: #00B074;

  --radius-pill: 9999px;
  --radius-bubble: 18px;
  --radius-card: 28px;

  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-fast: 0.18s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* Outer Widget Wrapper */
.chat-widget-wrapper {
  width: 50%;
  min-width: 480px;
  height: 85vh;
  max-height: 900px;
  display: flex;
  margin: 0 auto;
}

/* Chat Card with Border Stroke matching the Reference Style */
.chat-widget-card {
  width: 100%;
  height: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  border: 2px solid var(--widget-border);
  box-shadow: 0 20px 50px rgba(237, 72, 13, 0.14), 0 6px 20px rgba(32, 36, 44, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Gradient Header Inspired by Reference Widget */
.chat-header {
  background: var(--primary-gradient);
  color: var(--text-inverse);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  user-select: none;
}

.header-branding {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-badge {
  background: #FFFFFF;
  padding: 5px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.brand-logo-img {
  height: 32px;
  width: auto;
  max-width: 135px;
  object-fit: contain;
  display: block;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.brand-subtitle::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #22C55E;
  box-shadow: 0 0 6px #22C55E;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.header-ctrl-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  border: none;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.header-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.05);
}

/* Options Dropdown */
.options-dropdown {
  position: absolute;
  top: 40px;
  right: 0;
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-subtle);
  padding: 6px;
  min-width: 180px;
  z-index: 50;
  display: none;
}

.options-dropdown.open {
  display: flex;
  flex-direction: column;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dark);
  text-decoration: none;
  background: transparent;
  border: none;
  border-radius: 8px;
  width: 100%;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--bg-subtle);
  color: var(--primary);
}

/* Emergency Alert Banner */
.emergency-banner {
  background: #FFF5F5;
  border-bottom: 1px solid #FED7D7;
  padding: 10px 16px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  animation: slide-down 0.2s ease;
}

.emergency-banner.visible {
  display: flex;
}

@keyframes slide-down {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.emergency-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.emergency-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: var(--danger);
  color: #fff;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

.emergency-text {
  font-size: 0.78rem;
  color: var(--danger);
  font-weight: 600;
}

.emergency-call-btn {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: var(--danger);
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  white-space: nowrap;
}

/* Messages Stream */
.chat-messages {
  flex: 1;
  padding: 18px 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #FFFFFF;
}

.message-turn {
  display: flex;
  gap: 8px;
  max-width: 92%;
  animation: fade-in 0.2s ease;
}

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

.message-turn.user {
  align-self: flex-end;
  justify-content: flex-end;
}

.message-turn.assistant {
  align-self: flex-start;
  align-items: flex-end;
}

.assistant-avatar-pill {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.assistant-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.assistant-avatar-pill.small {
  width: 20px;
  height: 20px;
}

.turn-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
}

/* Speech Bubbles */
.message-bubble {
  padding: 11px 16px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}

.assistant-bubble {
  background: var(--bg-subtle);
  color: var(--dark);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 4px;
}

.user-bubble {
  background: var(--primary-gradient);
  color: #FFFFFF;
  border-radius: var(--radius-bubble) var(--radius-bubble) 4px var(--radius-bubble);
  font-weight: 500;
}

.message-bubble p {
  margin-bottom: 6px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble strong {
  font-weight: 700;
}

.message-bubble ul, .message-bubble ol {
  margin: 6px 0 6px 18px;
}

.message-bubble li {
  margin-bottom: 3px;
}

/* 2x2 Quick Pill Grid (Identical layout to screenshot) */
.quick-pill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.quick-pill-btn {
  background: #FFFFFF;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-pill);
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-pill-btn:hover {
  background: var(--primary-subtle);
  transform: translateY(-1px);
}

/* Interactive Navigation Menu List Card (Inspired by Reference Screenshot) */
.action-menu-card {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  margin-top: 4px;
}

.action-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 15px;
  border-bottom: 1px solid #F0ECE4;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--dark);
  transition: background var(--transition-fast), color var(--transition-fast);
  text-align: left;
  background: #FFFFFF;
  border-left: none;
  border-right: none;
  border-top: none;
  width: 100%;
}

.action-menu-item:last-child {
  border-bottom: none;
}

.action-menu-item:hover {
  background: var(--primary-subtle);
  color: var(--primary);
}

.menu-chevron-svg {
  color: #A0AEC0;
  transition: transform var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.action-menu-item:hover .menu-chevron-svg {
  color: var(--primary);
  transform: translateX(2px);
}

/* Typing Indicator */
.typing-indicator-row {
  display: none;
  align-items: flex-end;
  gap: 8px;
  padding: 0 16px 8px;
}

.typing-indicator-row.active {
  display: flex;
}

.typing-bubble {
  background: var(--bg-subtle);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 4px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.3s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Bottom Input Bar Styled like Reference Widget */
.chat-input-bar {
  background: #FFFFFF;
  border-top: 1px solid var(--border-subtle);
  padding: 12px 16px;
}

.input-form-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-field {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--dark);
  padding: 6px 0;
}

.input-field::placeholder {
  color: var(--text-light);
}

.input-action-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-icon-btn {
  background: transparent;
  border: none;
  color: #718096;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.tool-icon-btn:hover {
  color: var(--primary);
  background: var(--primary-subtle);
}

/* Circular Send Submit Button with Gradient and Soft Shadow */
.send-submit-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(237, 72, 13, 0.35);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  flex-shrink: 0;
  margin-left: 2px;
}

.send-submit-btn:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 6px 16px rgba(237, 72, 13, 0.45);
}

.send-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.send-icon {
  width: 17px;
  height: 17px;
  transform: rotate(0deg);
}

/* Responsive */
@media (max-width: 768px) {
  .chat-widget-wrapper {
    width: 90%;
    min-width: 0;
    height: 90vh;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0;
  }
  .chat-widget-wrapper {
    width: 100%;
    min-width: 0;
    height: 100vh;
    max-height: 100vh;
  }
  .chat-widget-card {
    border-radius: 0;
    border: none;
  }
}
