/* ==========================================================================
   OptiTrader Assistant — Stylesheet
   v1.0.0 — RTL Arabic, Teal/Navy palette, accessibility-first
   ========================================================================== */

#ot-assistant-root {
  /* Brand */
  --ot-teal: #00B8D4;
  --ot-teal-dark: #0096B0;
  --ot-teal-light: #E0F7FB;
  --ot-navy: #0B1F3A;
  --ot-navy-80: #1F3555;

  /* Surfaces */
  --ot-bg: #FFFFFF;
  --ot-surface: #F7FAFC;
  --ot-surface-alt: #EEF4F8;
  --ot-border: #D8E2EA;

  /* Text */
  --ot-text: #0B1F3A;
  --ot-text-secondary: #5E6B78;
  --ot-text-muted: #8A96A3;

  /* Shadows */
  --ot-shadow-sm: 0 1px 2px rgba(11, 31, 58, 0.06);
  --ot-shadow-md: 0 4px 12px rgba(11, 31, 58, 0.08);
  --ot-shadow-lg: 0 12px 32px rgba(11, 31, 58, 0.12);
  --ot-shadow-launcher: 0 8px 24px rgba(0, 184, 212, 0.35);

  /* Radius */
  --ot-radius-sm: 8px;
  --ot-radius-md: 12px;
  --ot-radius-lg: 16px;
  --ot-radius-xl: 20px;
  --ot-radius-full: 9999px;

  /* Motion */
  --ot-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ot-duration-fast: 150ms;
  --ot-duration-base: 220ms;
  --ot-duration-slow: 320ms;

  /* Z-index */
  --ot-z-launcher: 2147483000;
  --ot-z-panel: 2147483001;

  font-family: 'IBM Plex Sans Arabic', 'Tajawal', 'Cairo',
               -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  direction: rtl;
}

#ot-assistant-root *,
#ot-assistant-root *::before,
#ot-assistant-root *::after {
  box-sizing: border-box;
}

/* ==========================================================================
   7.2 Launcher
   ========================================================================== */
.ot-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: var(--ot-radius-full);
  background: var(--ot-teal);
  border: none;
  cursor: pointer;
  box-shadow: var(--ot-shadow-launcher);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  padding: 0;
  transition: transform var(--ot-duration-base) var(--ot-ease),
              background-color var(--ot-duration-base) var(--ot-ease);
  z-index: var(--ot-z-launcher);
}
.ot-launcher:hover {
  transform: scale(1.05);
  background: var(--ot-teal-dark);
}
.ot-launcher:focus-visible {
  outline: 3px solid rgba(0, 184, 212, 0.45);
  outline-offset: 2px;
}
.ot-launcher svg {
  width: 24px;
  height: 24px;
}
@media (max-width: 640px) {
  .ot-launcher {
    width: 52px;
    height: 52px;
    bottom: 20px;
    right: 20px;
  }
}

/* ==========================================================================
   7.3 Panel (Desktop)
   ========================================================================== */
.ot-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 31, 58, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: var(--ot-z-panel);
  opacity: 0;
  transition: opacity var(--ot-duration-base) var(--ot-ease);
}
.ot-scrim.ot-open {
  opacity: 1;
}

.ot-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--ot-bg);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius-xl);
  box-shadow: var(--ot-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--ot-z-panel);
  transform: translateY(8px);
  opacity: 0;
  transition: transform var(--ot-duration-slow) var(--ot-ease),
              opacity var(--ot-duration-slow) var(--ot-ease);
}
.ot-panel.ot-open {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   7.4 Modal (Mobile)
   ========================================================================== */
@media (max-width: 640px) {
  .ot-scrim {
    display: block;
  }
  .ot-panel {
    top: 12px;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    height: auto;
    max-height: none;
    transform: translateY(16px);
  }
  .ot-panel.ot-open {
    transform: translateY(0);
  }
}

/* ==========================================================================
   7.5 Header
   ========================================================================== */
.ot-header {
  height: 64px;
  padding: 0 16px;
  background: var(--ot-navy);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.ot-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--ot-radius-full);
  background: var(--ot-teal);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ot-header-avatar svg {
  width: 20px;
  height: 20px;
}
.ot-header-text {
  flex: 1;
  min-width: 0;
}
.ot-header-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: #FFFFFF;
  margin: 0;
}
.ot-header-subtitle {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.72);
  margin: 2px 0 0;
}
.ot-header-close {
  width: 36px;
  height: 36px;
  border-radius: var(--ot-radius-sm);
  background: transparent;
  border: none;
  color: #FFFFFF;
  opacity: 0.7;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity var(--ot-duration-fast) var(--ot-ease),
              background-color var(--ot-duration-fast) var(--ot-ease);
}
.ot-header-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}
.ot-header-close:focus-visible {
  outline: 2px solid var(--ot-teal);
  outline-offset: 2px;
  opacity: 1;
}

/* ==========================================================================
   Body / Messages Area
   ========================================================================== */
.ot-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--ot-bg);
  scroll-behavior: smooth;
}
.ot-body::-webkit-scrollbar {
  width: 6px;
}
.ot-body::-webkit-scrollbar-track {
  background: transparent;
}
.ot-body::-webkit-scrollbar-thumb {
  background: var(--ot-border);
  border-radius: 3px;
}

/* ==========================================================================
   7.6 Bot Message Bubble
   ========================================================================== */
.ot-bubble {
  background: var(--ot-surface);
  color: var(--ot-text);
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  max-width: 88%;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.65;
  opacity: 0;
  transform: translateY(6px);
  animation: ot-bubble-in var(--ot-duration-base) var(--ot-ease) forwards;
}

@keyframes ot-bubble-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   7.7 Option Buttons
   ========================================================================== */
.ot-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  opacity: 0;
  animation: ot-bubble-in var(--ot-duration-base) var(--ot-ease) 80ms forwards;
}

.ot-btn {
  min-height: 44px;
  padding: 0 16px;
  background: #FFFFFF;
  border: 1.5px solid var(--ot-border);
  border-radius: var(--ot-radius-md);
  color: var(--ot-navy);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: right;
  transition: border-color var(--ot-duration-fast) var(--ot-ease),
              background-color var(--ot-duration-fast) var(--ot-ease),
              transform var(--ot-duration-fast) var(--ot-ease);
  width: 100%;
}
.ot-btn:hover {
  border-color: var(--ot-teal);
  background: var(--ot-teal-light);
}
.ot-btn:active {
  transform: translateY(1px);
}
.ot-btn:focus-visible {
  outline: 2px solid var(--ot-teal);
  outline-offset: 2px;
}
.ot-btn svg {
  flex-shrink: 0;
  color: var(--ot-navy-80);
}
.ot-btn:hover svg {
  color: var(--ot-teal-dark);
}
.ot-btn-label {
  flex: 1;
}

.ot-btn-back {
  align-self: flex-start;
  min-height: 32px;
  padding: 0 10px 0 12px;
  background: transparent;
  border: none;
  color: var(--ot-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  border-radius: var(--ot-radius-sm);
  transition: color var(--ot-duration-fast) var(--ot-ease),
              background-color var(--ot-duration-fast) var(--ot-ease);
}
.ot-btn-back:hover {
  color: var(--ot-teal-dark);
  background: var(--ot-surface);
}
.ot-btn-back:focus-visible {
  outline: 2px solid var(--ot-teal);
  outline-offset: 2px;
}

/* ==========================================================================
   7.8 Article Card
   ========================================================================== */
.ot-article {
  display: block;
  background: #FFFFFF;
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius-md);
  padding: 14px 16px;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--ot-duration-fast) var(--ot-ease),
              box-shadow var(--ot-duration-fast) var(--ot-ease);
}
.ot-article:hover {
  border-color: var(--ot-teal);
  box-shadow: var(--ot-shadow-sm);
}
.ot-article:focus-visible {
  outline: 2px solid var(--ot-teal);
  outline-offset: 2px;
}
.ot-article-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ot-navy);
  line-height: 1.45;
  margin: 0 0 4px;
}
.ot-article-desc {
  font-size: 12px;
  font-weight: 400;
  color: var(--ot-text-secondary);
  line-height: 1.4;
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ot-article-cta {
  font-size: 12px;
  font-weight: 600;
  color: var(--ot-teal-dark);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ot-article-cta svg {
  width: 14px;
  height: 14px;
}

.ot-show-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  background: var(--ot-surface);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius-md);
  color: var(--ot-navy-80);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  text-decoration: none;
  transition: background-color var(--ot-duration-fast) var(--ot-ease),
              border-color var(--ot-duration-fast) var(--ot-ease);
}
.ot-show-all:hover {
  background: var(--ot-teal-light);
  border-color: var(--ot-teal);
  color: var(--ot-teal-dark);
}
.ot-show-all:focus-visible {
  outline: 2px solid var(--ot-teal);
  outline-offset: 2px;
}

/* ==========================================================================
   7.9 CTA Card
   ========================================================================== */
.ot-cta-card {
  background: var(--ot-teal-light);
  border: 1px solid rgba(0, 184, 212, 0.3);
  border-radius: var(--ot-radius-md);
  padding: 16px;
  margin-top: 8px;
  margin-bottom: 12px;
}
.ot-cta-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ot-navy);
  margin: 0 0 6px;
  line-height: 1.4;
}
.ot-cta-desc {
  font-size: 13px;
  font-weight: 400;
  color: var(--ot-text-secondary);
  line-height: 1.55;
  margin: 0 0 12px;
}
.ot-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 42px;
  padding: 0 16px;
  background: var(--ot-teal-dark);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: var(--ot-radius-md);
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--ot-duration-fast) var(--ot-ease),
              transform var(--ot-duration-fast) var(--ot-ease);
}
.ot-cta-btn:hover {
  background: var(--ot-navy-80);
}
.ot-cta-btn:active {
  transform: translateY(1px);
}
.ot-cta-btn:focus-visible {
  outline: 3px solid rgba(0, 184, 212, 0.45);
  outline-offset: 2px;
}
.ot-cta-btn svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   FAQ Answer
   ========================================================================== */
.ot-faq-answer {
  background: var(--ot-teal-light);
  border-right: 3px solid var(--ot-teal);
  padding: 12px 14px;
  border-radius: var(--ot-radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--ot-navy-80);
  line-height: 1.65;
  margin-bottom: 12px;
  opacity: 0;
  transform: translateY(6px);
  animation: ot-bubble-in var(--ot-duration-base) var(--ot-ease) forwards;
}

/* ==========================================================================
   7.10 Motion & A11y
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  #ot-assistant-root *,
  #ot-assistant-root *::before,
  #ot-assistant-root *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

/* ==========================================================================
   v1.1 — Nudge bubble (next to launcher)
   ========================================================================== */
#ot-assistant-root .ot-nudge {
  position: fixed;
  bottom: 92px;
  right: 24px;
  max-width: 260px;
  min-height: 44px;
  padding: 10px 36px 10px 14px;
  background: var(--ot-bg);
  color: var(--ot-navy);
  border: 1px solid var(--ot-border);
  border-radius: 14px 14px 4px 14px;
  box-shadow: var(--ot-shadow-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  text-align: right;
  cursor: pointer;
  z-index: var(--ot-z-launcher);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--ot-duration-base) var(--ot-ease),
              transform var(--ot-duration-base) var(--ot-ease);
}
#ot-assistant-root .ot-nudge.ot-open {
  opacity: 1;
  transform: translateY(0);
}
#ot-assistant-root .ot-nudge:hover {
  border-color: var(--ot-teal);
}
#ot-assistant-root .ot-nudge:focus-visible {
  outline: 2px solid var(--ot-teal);
  outline-offset: 2px;
}
#ot-assistant-root .ot-nudge-text {
  display: block;
}
#ot-assistant-root .ot-nudge-close {
  position: absolute;
  top: 4px;
  left: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--ot-text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
#ot-assistant-root .ot-nudge-close:hover {
  color: var(--ot-navy);
  background: var(--ot-surface);
}
#ot-assistant-root .ot-nudge-close:focus-visible {
  outline: 2px solid var(--ot-teal);
  outline-offset: 1px;
}
@media (max-width: 640px) {
  #ot-assistant-root .ot-nudge {
    bottom: 84px;
    right: 20px;
    max-width: 240px;
  }
}

/* ==========================================================================
   v1.1 — Article Top Sticky Strip
   ========================================================================== */
.ot-article-strip {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #0B1F3A;
  color: #fff;
  font-family: 'IBM Plex Sans Arabic', 'Tajawal', sans-serif;
  direction: rtl;
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
              opacity 260ms cubic-bezier(0.22, 1, 0.36, 1);
}
.ot-article-strip.ot-strip-hidden,
.ot-article-strip.ot-hidden-by-user {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}
.ot-article-strip .ot-strip-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 48px 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ot-article-strip .ot-strip-text {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  line-height: 1.4;
}
.ot-article-strip .ot-strip-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  background: #00B8D4;
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 150ms ease;
}
.ot-article-strip .ot-strip-btn:hover {
  background: #0096B0;
  color: #fff;
}
.ot-article-strip .ot-strip-close {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.ot-article-strip .ot-strip-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}
@media (max-width: 640px) {
  .ot-article-strip .ot-strip-inner {
    height: 44px;
    padding: 0 44px 0 12px;
  }
  .ot-article-strip .ot-strip-text {
    font-size: 13px;
  }
  .ot-article-strip .ot-strip-btn {
    padding: 5px 12px;
    font-size: 12px;
  }
}

/* ==========================================================================
   v1.1 — Article Inline CTA (after 3rd paragraph)
   ========================================================================== */
.ot-inline-cta {
  background: #E0F7FB;
  border-right: 4px solid #00B8D4;
  border-radius: 12px;
  padding: 20px 24px;
  margin: 32px 0;
  font-family: 'IBM Plex Sans Arabic', 'Tajawal', sans-serif;
  direction: rtl;
  text-align: right;
}
.ot-inline-cta-title {
  font-size: 16px;
  font-weight: 700;
  color: #0B1F3A;
  line-height: 1.5;
  margin: 0 0 6px;
}
.ot-inline-cta-desc {
  font-size: 14px;
  font-weight: 400;
  color: #5E6B78;
  line-height: 1.7;
  margin: 0 0 14px;
}
.ot-inline-cta-btn {
  display: inline-block;
  padding: 10px 22px;
  background: #0096B0;
  color: #fff !important;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 150ms ease;
}
.ot-inline-cta-btn:hover {
  background: #0B1F3A;
  color: #fff !important;
}

/* ==========================================================================
   v1.1 — Article End CTA Block
   ========================================================================== */
.ot-end-cta {
  background: linear-gradient(135deg, #E0F7FB 0%, #FFFFFF 100%);
  border: 1px solid rgba(0,184,212,0.3);
  border-radius: 16px;
  padding: 40px 32px;
  margin: 48px 0 32px;
  font-family: 'IBM Plex Sans Arabic', 'Tajawal', sans-serif;
  direction: rtl;
  text-align: center;
}
.ot-end-cta-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  background: #00B8D4;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ot-end-cta-icon svg {
  width: 24px;
  height: 24px;
}
.ot-end-cta-title {
  font-size: 20px;
  font-weight: 700;
  color: #0B1F3A;
  line-height: 1.4;
  margin: 0 0 10px;
}
.ot-end-cta-desc {
  font-size: 15px;
  font-weight: 400;
  color: #5E6B78;
  line-height: 1.8;
  margin: 0 auto 18px;
  max-width: 520px;
}
.ot-end-cta-list {
  list-style: none;
  padding: 0;
  margin: 0 auto 24px;
  max-width: 320px;
  text-align: right;
}
.ot-end-cta-list li {
  position: relative;
  padding: 6px 28px 6px 0;
  font-size: 14px;
  font-weight: 500;
  color: #1F3555;
  line-height: 1.5;
}
.ot-end-cta-list li::before {
  content: '✓';
  position: absolute;
  right: 0;
  top: 6px;
  width: 20px;
  height: 20px;
  background: rgba(16,185,129,0.12);
  color: #10B981;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ot-end-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 280px;
  padding: 0 24px;
  background: #0096B0;
  color: #fff !important;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 150ms ease, transform 150ms ease;
}
.ot-end-cta-btn:hover {
  background: #0B1F3A;
  color: #fff !important;
}
.ot-end-cta-btn:active {
  transform: translateY(1px);
}
@media (max-width: 640px) {
  .ot-end-cta {
    padding: 28px 20px;
    margin: 36px 0 24px;
  }
  .ot-end-cta-title {
    font-size: 18px;
  }
  .ot-end-cta-desc {
    font-size: 14px;
  }
  .ot-end-cta-btn {
    min-width: 0;
    width: 100%;
  }
}
