/* ==========================================================================
   Muscat Auditing & Accounting Services - Expert Chat Widget
   Persona: Omani Female Vice Assistant Manager (Arabic & English)
   ========================================================================== */

:root {
  --maas-chat-navy: #0e2744;
  --maas-chat-blue: #1769aa;
  --maas-chat-light-blue: #e0f2fe;
  --maas-chat-gold: #eab308;
  --maas-chat-gold-hover: #ca8a04;
  --maas-chat-green: #10b981;
  --maas-chat-slate: #334155;
  --maas-chat-bg: #f8fafc;
  --maas-chat-border: #e2e8f0;
  --maas-chat-shadow: 0 20px 45px rgba(14, 39, 68, 0.22), 0 8px 18px rgba(0,0,0,0.1);
}

/* Floating Trigger Button */
.maas-chat-trigger-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

[dir="rtl"] .maas-chat-trigger-wrap,
.rtl-mode .maas-chat-trigger-wrap,
.rtl-layout .maas-chat-trigger-wrap {
  right: auto;
  left: 24px;
  flex-direction: row-reverse;
  font-family: 'Cairo', 'Plus Jakarta Sans', sans-serif;
}

/* Teaser Notification Bubble */
.maas-chat-teaser {
  background: #ffffff;
  border: 1px solid var(--maas-chat-border);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  border-radius: 24px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  animation: maasPulseTeaser 3.5s infinite ease-in-out;
  transition: transform 0.25s ease, opacity 0.25s ease;
  max-width: 300px;
}

.maas-chat-teaser:hover {
  transform: translateY(-2px);
}

.maas-chat-teaser-text {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.4;
}

.maas-chat-teaser-role {
  display: block;
  font-size: 11px;
  color: var(--maas-chat-blue);
  font-weight: 500;
}

.maas-chat-teaser-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 2px;
  font-size: 16px;
  line-height: 1;
}

.maas-chat-teaser-close:hover {
  color: #ef4444;
}

/* Main Trigger Button */
.maas-chat-trigger-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--maas-chat-navy) 0%, var(--maas-chat-blue) 100%);
  border: 3px solid #ffffff;
  box-shadow: 0 12px 28px rgba(23, 105, 170, 0.4);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  outline: none;
  padding: 0;
}

.maas-chat-trigger-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 16px 36px rgba(23, 105, 170, 0.5);
}

.maas-trigger-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.maas-trigger-badge {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 18px;
  height: 18px;
  background: var(--maas-chat-green);
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35);
}

[dir="rtl"] .maas-trigger-badge,
.rtl-mode .maas-trigger-badge {
  right: auto;
  left: 1px;
}

/* The Chat Container Modal */
.maas-chat-container {
  position: fixed;
  bottom: 102px;
  right: 24px;
  width: 440px;
  max-width: calc(100vw - 32px);
  height: 650px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 22px;
  box-shadow: var(--maas-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  border: 1px solid rgba(226, 232, 240, 0.85);
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

[dir="rtl"] .maas-chat-container,
.rtl-mode .maas-chat-container,
.rtl-layout .maas-chat-container {
  right: auto;
  left: 24px;
  font-family: 'Cairo', 'Plus Jakarta Sans', sans-serif;
}

.maas-chat-container.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.maas-chat-header {
  background: linear-gradient(135deg, #091c32 0%, #173a60 55%, #1769aa 100%);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  position: relative;
}

.maas-header-advisor {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.maas-advisor-avatar-wrap {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}

.maas-advisor-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.maas-advisor-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 13px;
  height: 13px;
  background: #10b981;
  border: 2px solid #091c32;
  border-radius: 50%;
}

[dir="rtl"] .maas-advisor-status-dot,
.rtl-mode .maas-advisor-status-dot {
  right: auto;
  left: 0;
}

.maas-advisor-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.maas-advisor-name {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.maas-advisor-badge-icon {
  color: #facc15;
  font-size: 13px;
}

.maas-advisor-title {
  font-size: 11.5px;
  color: #93c5fd;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.maas-advisor-status-text {
  font-size: 10.5px;
  color: #86efac;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.maas-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.maas-control-btn {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
  outline: none;
}

.maas-control-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.maas-control-btn.active-voice {
  background: #facc15;
  color: #0f172a;
  border-color: #facc15;
}

/* Advisor Persona Tabs Bar */
.maas-advisor-picker-bar {
  background: #0f172a;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #94a3b8;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.maas-advisor-tabs {
  display: flex;
  gap: 6px;
}

.maas-advisor-tab {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #cbd5e1;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.maas-advisor-tab:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.maas-advisor-tab.active {
  background: var(--maas-chat-blue);
  border-color: #38bdf8;
  color: #ffffff;
  font-weight: 600;
}

/* Quick Subjects Pill Bar */
.maas-subjects-bar {
  background: #f1f5f9;
  border-bottom: 1px solid var(--maas-chat-border);
  padding: 8px 12px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.maas-subjects-bar::-webkit-scrollbar {
  height: 4px;
}

.maas-subjects-bar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.maas-subject-pill {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  font-family: inherit;
}

.maas-subject-pill:hover {
  background: var(--maas-chat-light-blue);
  border-color: var(--maas-chat-blue);
  color: var(--maas-chat-blue);
  transform: translateY(-1px);
}

/* Chat Messages Area */
.maas-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

/* Message Bubble Styles */
.maas-msg {
  display: flex;
  gap: 10px;
  max-width: 90%;
  position: relative;
  animation: maasFadeIn 0.3s ease-out;
}

.maas-msg-assistant {
  align-self: flex-start;
}

.maas-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.maas-msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid var(--maas-chat-blue);
}

.maas-msg-bubble {
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.maas-msg-assistant .maas-msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid var(--maas-chat-border);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[dir="rtl"] .maas-msg-assistant .maas-msg-bubble,
.rtl-mode .maas-msg-assistant .maas-msg-bubble {
  border-top-left-radius: 16px;
  border-top-right-radius: 4px;
}

.maas-msg-user .maas-msg-bubble {
  background: linear-gradient(135deg, var(--maas-chat-navy) 0%, var(--maas-chat-blue) 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(23, 105, 170, 0.2);
}

[dir="rtl"] .maas-msg-user .maas-msg-bubble,
.rtl-mode .maas-msg-user .maas-msg-bubble {
  border-top-right-radius: 16px;
  border-top-left-radius: 4px;
}

.maas-msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10.5px;
  color: #94a3b8;
  gap: 8px;
}

.maas-msg-speak-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--maas-chat-blue);
  cursor: pointer;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 12px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.maas-msg-speak-btn:hover {
  background: var(--maas-chat-light-blue);
  color: var(--maas-chat-navy);
  border-color: var(--maas-chat-blue);
}

.maas-msg-speak-btn.speaking {
  background: #fef08a;
  color: #854d0e;
  border-color: #facc15;
  animation: maasPulseSpeak 1.2s infinite alternate;
}

/* Quick Action Chips inside chat */
.maas-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.maas-chip {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  padding: 5px 11px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.maas-chip:hover {
  background: var(--maas-chat-blue);
  color: #ffffff;
  border-color: var(--maas-chat-blue);
}

/* Action Cards inside chat */
.maas-card-cta {
  background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
}

.maas-card-cta-title {
  font-weight: 700;
  color: #0f172a;
  font-size: 13px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.maas-card-cta-desc {
  font-size: 12px;
  color: #475569;
  margin-bottom: 8px;
}

.maas-card-cta-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.maas-card-btn-wa {
  background: #25d366;
  color: #ffffff !important;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}

.maas-card-btn-wa:hover {
  background: #1eb857;
}

.maas-card-btn-call {
  background: var(--maas-chat-blue);
  color: #ffffff !important;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}

/* Typing Indicator */
.maas-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--maas-chat-border);
  align-self: flex-start;
  width: fit-content;
}

.maas-typing-dot {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: maasBounce 1.4s infinite ease-in-out both;
}

.maas-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.maas-typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Chat Input Footer */
.maas-chat-footer {
  background: #ffffff;
  border-top: 1px solid var(--maas-chat-border);
  padding: 10px 14px;
}

.maas-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

[dir="rtl"] .maas-input-row,
.rtl-mode .maas-input-row {
  padding: 4px 14px 4px 6px;
}

.maas-input-row:focus-within {
  border-color: var(--maas-chat-blue);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.15);
}

.maas-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 13.5px;
  outline: none;
  color: #0f172a;
  font-family: inherit;
}

.maas-input-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  outline: none;
}

.maas-mic-btn {
  background: transparent;
  color: #64748b;
}

.maas-mic-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.maas-mic-btn.recording {
  color: #ef4444;
  background: #fee2e2;
  animation: maasPulseRed 1s infinite alternate;
}

.maas-send-btn {
  background: linear-gradient(135deg, var(--maas-chat-navy) 0%, var(--maas-chat-blue) 100%);
  color: #ffffff;
}

.maas-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 10px rgba(23, 105, 170, 0.35);
}

.maas-footer-disclaimer {
  font-size: 10.5px;
  color: #94a3b8;
  text-align: center;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Animations */
@keyframes maasFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes maasBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@keyframes maasPulseRed {
  0% { transform: scale(1); }
  100% { transform: scale(1.18); }
}

@keyframes maasPulseSpeak {
  0% { transform: scale(1); }
  100% { transform: scale(1.06); }
}

@keyframes maasPulseTeaser {
  0%, 100% { box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12); }
  50% { box-shadow: 0 12px 30px rgba(23, 105, 170, 0.22); }
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .maas-chat-container {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  
  .maas-chat-trigger-wrap {
    bottom: 16px;
    right: 16px;
  }
  
  [dir="rtl"] .maas-chat-trigger-wrap,
  .rtl-mode .maas-chat-trigger-wrap {
    left: 16px;
    right: auto;
  }
  
  .maas-chat-teaser {
    display: none;
  }
}
