/* Tarqiya - AI Assistant Styles ("مساعد ترقية الذكي") */

/* Floating Launcher Button - Pill Button Matching User Screenshot */
.ai-assistant-launcher {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: var(--z-ai-assistant);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 20px 0 16px;
  background: var(--color-brand-gradient-h);
  color: #FFFFFF;
  border-radius: var(--radius-full);
  box-shadow: 0 6px 22px rgba(13, 100, 219, 0.38);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.92rem;
  font-weight: 700;
  transition: all var(--transition-normal);
}

html[dir="ltr"] .ai-assistant-launcher {
  left: auto;
  right: 24px;
}

.ai-assistant-launcher:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #094EB0 0%, #0060C5 100%);
  box-shadow: 0 8px 26px rgba(13, 100, 219, 0.48);
}

.ai-launcher-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #10B981;
  box-shadow: 0 0 8px #10B981;
  flex-shrink: 0;
}

.ai-launcher-title-text {
  font-size: 0.92rem;
  font-weight: 700;
  color: #FFFFFF;
  white-space: nowrap;
}

.ai-launcher-text {
  display: none !important;
}

.ai-online-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background-color: #22C55E;
  border-radius: var(--radius-full);
  border: 2px solid #FFFFFF;
}

.ai-launcher-text {
  display: flex;
  flex-direction: column;
}

.ai-launcher-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.1;
}

.ai-launcher-sub {
  font-size: 0.75rem;
  opacity: 0.85;
}

/* Chat Drawer / Modal Container */
.ai-chat-window {
  position: fixed;
  bottom: 84px;
  left: 24px;
  width: 400px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-ai-assistant);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

html[dir="ltr"] .ai-chat-window {
  left: auto;
  right: 24px;
}

.ai-chat-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* AI Header */
.ai-chat-header {
  background: linear-gradient(135deg, var(--color-primary), var(--color-main-blue));
  color: #FFFFFF;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-header-avatar {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ai-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-header-name {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
}

.ai-header-role {
  font-size: 0.75rem;
  opacity: 0.9;
}

/* Context Tag Banner */
.ai-context-banner {
  background-color: var(--color-light-blue);
  color: var(--color-main-blue);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(13, 100, 219, 0.15);
}

/* Messages Area */
.ai-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: fadeIn 0.2s ease-out;
}

.ai-msg.user {
  align-self: flex-end;
  text-align: right;
}
html[dir="ltr"] .ai-msg.user {
  text-align: left;
}

.ai-msg.bot {
  align-self: flex-start;
  text-align: right;
}
html[dir="ltr"] .ai-msg.bot {
  text-align: left;
}

.ai-msg-bubble {
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.5;
}

.ai-msg.user .ai-msg-bubble {
  background-color: var(--color-main-blue);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}
html[dir="ltr"] .ai-msg.user .ai-msg-bubble {
  border-bottom-right-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
}

.ai-msg.bot .ai-msg-bubble {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-subtle);
  border-bottom-left-radius: 4px;
}
html[dir="ltr"] .ai-msg.bot .ai-msg-bubble {
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: 4px;
}

.ai-msg-time {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Quick Action Suggestion Chips */
.ai-chips-bar {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  overflow-x: auto;
  white-space: nowrap;
  border-top: 1px solid var(--color-border-subtle);
  background-color: var(--color-surface);
}

.ai-chip {
  padding: 5px 10px;
  font-size: 0.78rem;
  background-color: var(--color-bg);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-chip:hover {
  background-color: var(--color-light-blue);
  color: var(--color-main-blue);
  border-color: var(--color-main-blue);
}

/* Voice Waveform & Speech Visualizer */
.ai-voice-status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px;
  background-color: var(--color-light-blue);
  border-top: 1px solid rgba(13, 100, 219, 0.15);
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
}

.waveform-bar {
  width: 3px;
  height: 6px;
  background-color: var(--color-main-blue);
  border-radius: var(--radius-full);
}

.ai-speaking .waveform-bar, .ai-listening .waveform-bar {
  animation: waveformPulse 1s ease-in-out infinite;
}

.waveform-bar:nth-child(1) { animation-delay: 0.0s; }
.waveform-bar:nth-child(2) { animation-delay: 0.2s; }
.waveform-bar:nth-child(3) { animation-delay: 0.4s; }
.waveform-bar:nth-child(4) { animation-delay: 0.1s; }
.waveform-bar:nth-child(5) { animation-delay: 0.3s; }

@keyframes waveformPulse {
  0%, 100% { height: 6px; }
  50% { height: 20px; }
}

/* Input Row */
.ai-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.ai-chat-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-size: 0.9rem;
}

.ai-chat-input:focus {
  border-color: var(--color-main-blue);
  outline: none;
}

.ai-mic-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-mic-btn:hover {
  background-color: var(--color-light-blue);
  color: var(--color-main-blue);
}

.ai-mic-btn.listening {
  background-color: var(--color-error);
  color: #FFFFFF;
  border-color: var(--color-error);
  animation: pulseGlow 1.2s infinite;
}

.ai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background-color: var(--color-main-blue);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-send-btn:hover {
  background-color: var(--color-main-blue-hover);
}

/* Mobile Fullscreen Voice Mode */
.ai-voice-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(9, 78, 176, 0.96);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  color: #FFFFFF;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.ai-voice-modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.ai-voice-modal-avatar {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 4px solid var(--color-main-blue);
  box-shadow: 0 0 30px rgba(13, 100, 219, 0.5);
  margin-bottom: var(--space-5);
  animation: pulseGlow 3s infinite;
}

.ai-voice-modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 640px) {
  .ai-assistant-launcher {
    bottom: 74px;
    left: 12px;
  }
  html[dir="ltr"] .ai-assistant-launcher {
    right: 12px;
  }

  .ai-chat-window {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  html[dir="ltr"] .ai-chat-window {
    left: 0;
    right: 0;
  }
}
