/* ==========================================================================
   Manarah AI Agent — Modern Brand Edition (Homepage Desktop Only)
   Palette: Deep Navy (#092E40), Beacon Coral (#EA502E), Emerald (#10B981)
   ========================================================================== */

.manarah-assistant-root {
  --ma-navy: #092E40;
  --ma-navy-deep: #061d29;
  --ma-coral: #EA502E;
  --ma-coral-hover: #d44120;
  --ma-primary: #092E40;
  --ma-accent: #EA502E;
  --ma-bg: #ffffff;
  --ma-surface: #f4f7fb;
  --ma-border: rgba(9, 46, 64, 0.12);
  --ma-text: #0f172a;
  --ma-muted: #64748b;
  --ma-shadow: 0 24px 60px rgba(6, 29, 41, 0.24);
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 1055;
  font-family: var(--font-heading, 'Cairo', 'Tajawal', sans-serif);
}

[data-theme="dark"] .manarah-assistant-root {
  --ma-primary: #38bdf8;
  --ma-accent: #fb7152;
  --ma-bg: #0b1b28;
  --ma-surface: #07131d;
  --ma-border: rgba(148, 163, 184, 0.2);
  --ma-text: #f1f5f9;
  --ma-muted: #94a3b8;
  --ma-shadow: 0 28px 68px rgba(0, 0, 0, 0.65);
}

/* Hidden on inner pages unless user actively opened/chatted with the Agent in this session */
.manarah-assistant-root.manarah-inner-hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Strictly hide on mobile & tablet (< 992px) */
@media (max-width: 991.98px) {
  .manarah-assistant-root,
  .manarah-assistant-panel {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

/* Floating Desktop Launcher Pill */
.manarah-assistant-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 6px 18px 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(135deg, #061d29 0%, #092E40 60%, #0d445f 100%);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 14px 36px rgba(6, 29, 41, 0.36);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.manarah-assistant-launcher:hover,
.manarah-assistant-launcher:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(234, 80, 46, 0.55);
  box-shadow: 0 18px 42px rgba(9, 46, 64, 0.46);
  outline: none;
}

.manarah-launcher-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #EA502E 0%, #f97316 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(234, 80, 46, 0.42);
  flex-shrink: 0;
}

.manarah-launcher-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.manarah-launcher-label {
  font-weight: 800;
  font-size: 0.92rem;
  color: #ffffff;
}

.manarah-launcher-sub {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.8);
}

.manarah-launcher-pulse {
  position: absolute;
  top: 5px;
  right: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
}

.manarah-launcher-tooltip {
  position: absolute;
  bottom: 68px;
  left: 0;
  background: #061d29;
  color: #f8fafc;
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  box-shadow: 0 10px 26px rgba(6, 29, 41, 0.28);
}

.manarah-assistant-launcher:hover .manarah-launcher-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Redesigned Agent Dialog Panel */
.manarah-assistant-panel {
  position: fixed;
  bottom: 92px;
  left: 24px;
  width: min(425px, calc(100vw - 36px));
  height: min(600px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--ma-bg);
  color: var(--ma-text);
  border: 1px solid var(--ma-border);
  border-radius: 22px;
  box-shadow: var(--ma-shadow);
  overflow: hidden;
  transform-origin: bottom left;
  animation: manarah-panel-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.manarah-assistant-panel[hidden] {
  display: none !important;
}

@keyframes manarah-panel-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.manarah-assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background:
    radial-gradient(circle at top left, rgba(234, 80, 46, 0.28), transparent 46%),
    linear-gradient(135deg, #061d29 0%, #092E40 70%, #0d445f 100%);
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.manarah-assistant-identity {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.manarah-assistant-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(135deg, #EA502E 0%, #f97316 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(234, 80, 46, 0.36);
}

.manarah-avatar-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #092E40;
}

.manarah-assistant-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.25;
  color: #ffffff;
}

.manarah-assistant-subtitle {
  font-size: 0.74rem;
  color: rgba(226, 232, 240, 0.84);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.manarah-assistant-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.manarah-header-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.manarah-header-btn:hover {
  background: rgba(234, 80, 46, 0.28);
  border-color: rgba(234, 80, 46, 0.5);
}

/* Messages Stream */
.manarah-assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--ma-surface);
}

.manarah-assistant-messages::-webkit-scrollbar {
  width: 5px;
}

.manarah-assistant-messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.35);
}

.manarah-msg {
  display: flex;
  flex-direction: column;
  max-width: 92%;
  gap: 6px;
}

.manarah-msg--user {
  align-self: flex-start;
}

.manarah-msg--assistant {
  align-self: flex-end;
  max-width: 96%;
}

.manarah-msg-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 0.89rem;
  line-height: 1.65;
  word-wrap: break-word;
  white-space: pre-line;
}

.manarah-msg--user .manarah-msg-bubble {
  background: linear-gradient(135deg, #092E40 0%, #0d4b68 100%);
  color: #ffffff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 6px 16px rgba(9, 46, 64, 0.18);
}

.manarah-msg--assistant .manarah-msg-bubble {
  background: var(--ma-bg);
  color: var(--ma-text);
  border: 1px solid var(--ma-border);
  border-bottom-left-radius: 5px;
  box-shadow: 0 4px 14px rgba(9, 46, 64, 0.05);
}

.manarah-msg-title {
  font-weight: 800;
  font-size: 0.87rem;
  color: var(--ma-accent);
  margin-bottom: 5px;
}

.manarah-msg-steps {
  margin: 7px 0 0;
  padding-inline-start: 18px;
  font-size: 0.83rem;
  color: var(--ma-muted);
}

.manarah-msg-steps li {
  margin-bottom: 4px;
}

.manarah-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}

.manarah-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--ma-border);
  background: var(--ma-bg);
  color: var(--ma-primary);
  transition: transform 0.16s ease, opacity 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
  text-decoration: none;
}

.manarah-action-btn--primary {
  border-color: #EA502E;
  background: linear-gradient(135deg, #EA502E 0%, #d44120 100%);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(234, 80, 46, 0.24);
}

.manarah-action-btn:hover {
  transform: translateY(-1px);
  border-color: #EA502E;
}

/* Quick Starter Chips */
.manarah-assistant-chips {
  display: flex;
  gap: 6px;
  padding: 9px 13px 7px;
  overflow-x: auto;
  background: var(--ma-bg);
  border-top: 1px solid var(--ma-border);
  scrollbar-width: none;
}

.manarah-assistant-chips::-webkit-scrollbar {
  display: none;
}

.manarah-assistant-chips:empty {
  display: none;
}

.manarah-chip-btn {
  flex: 0 0 auto;
  border: 1px solid var(--ma-border);
  background: var(--ma-surface);
  color: var(--ma-text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.manarah-chip-btn:hover {
  border-color: #EA502E;
  background: rgba(234, 80, 46, 0.08);
  color: #EA502E;
}

/* Composer Form */
.manarah-assistant-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  background: var(--ma-bg);
  border-top: 1px solid var(--ma-border);
}

.manarah-assistant-input {
  flex: 1;
  border: 1px solid var(--ma-border);
  background: var(--ma-surface);
  color: var(--ma-text);
  border-radius: 13px;
  padding: 10px 13px;
  font-size: 0.89rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.manarah-assistant-input:focus {
  border-color: #EA502E;
  box-shadow: 0 0 0 3px rgba(234, 80, 46, 0.12);
}

.manarah-assistant-send {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  border: 0;
  background: linear-gradient(135deg, #EA502E 0%, #d44120 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(234, 80, 46, 0.28);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.manarah-assistant-send:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.manarah-assistant-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.manarah-assistant-mic {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--ma-border);
  background: var(--ma-surface);
  color: var(--ma-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.16s ease, opacity 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.manarah-assistant-mic[hidden] {
  display: none !important;
}

.manarah-assistant-mic:hover {
  border-color: #EA502E;
  color: #EA502E;
}

.manarah-assistant-mic.is-listening {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  animation: manarah-pulse 1.2s infinite;
}

/* Markdown inside bubbles */
.manarah-md-p {
  margin: 0 0 6px;
}

.manarah-md-p:last-child {
  margin-bottom: 0;
}

.manarah-md-list {
  margin: 4px 0 6px;
  padding-inline-start: 18px;
}

.manarah-md-list li {
  margin-bottom: 4px;
}

.manarah-md-code {
  font-family: monospace;
  font-size: 0.82em;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(9, 46, 64, 0.08);
}

[data-theme="dark"] .manarah-md-code {
  background: rgba(148, 163, 184, 0.18);
}

.manarah-md-link {
  color: #EA502E;
  font-weight: 700;
  text-decoration: underline;
}

/* Footer Status Bar */
.manarah-assistant-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px 10px;
  font-size: 0.72rem;
  color: var(--ma-muted);
  background: var(--ma-bg);
}

.manarah-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.manarah-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
}

.manarah-human-fallback {
  color: #0d9488;
  font-weight: 700;
  text-decoration: none;
}

.manarah-human-fallback:hover {
  text-decoration: underline;
}

/* Typing indicator */
.manarah-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 2px;
}

.manarah-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #EA502E;
  animation: manarah-bounce 1.2s infinite ease-in-out;
}

.manarah-typing span:nth-child(2) { animation-delay: 0.15s; }
.manarah-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes manarah-bounce {
  0%, 80%, 100% { transform: scale(0.75); opacity: 0.45; }
  40% { transform: scale(1); opacity: 1; }
}

/* Interactive Spotlight Overlay & Popover */
.manarah-spotlight-ring {
  position: fixed;
  z-index: 1090;
  border-radius: 12px;
  border: 3px solid #EA502E;
  box-shadow: 0 0 0 9999px rgba(6, 29, 41, 0.54), 0 0 24px rgba(234, 80, 46, 0.55);
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease, background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.manarah-spotlight-popover {
  position: fixed;
  z-index: 1095;
  max-width: min(330px, calc(100vw - 24px));
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(234, 80, 46, 0.28);
  border-radius: 14px;
  padding: 13px 15px;
  box-shadow: 0 18px 42px rgba(6, 29, 41, 0.3);
}

[data-theme="dark"] .manarah-spotlight-popover {
  background: #0b1b28;
  color: #f8fafc;
  border-color: rgba(234, 80, 46, 0.45);
}

.manarah-spotlight-title {
  font-weight: 800;
  font-size: 0.92rem;
  margin-bottom: 5px;
  color: #EA502E;
}

.manarah-spotlight-body {
  font-size: 0.83rem;
  line-height: 1.5;
  margin-bottom: 10px;
}

.manarah-spotlight-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.manarah-spotlight-counter {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ma-muted);
}

.manarah-spotlight-nav {
  display: inline-flex;
  gap: 6px;
}

.manarah-spotlight-secondary {
  border: 1px solid rgba(9, 46, 64, 0.35);
  border-radius: 8px;
  padding: 5px 10px;
  background: transparent;
  color: #092E40;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

[data-theme="dark"] .manarah-spotlight-secondary {
  color: #7dd3fc;
  border-color: rgba(125, 211, 252, 0.45);
}

.manarah-spotlight-close {
  border: 0;
  border-radius: 8px;
  padding: 5px 12px;
  background: #EA502E;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
