
/* Assistant markdown display (ChatGPT-like) */
.omnis-assistant-md {
  line-height: 1.65;
  direction: rtl;
  text-align: right;
}

.omnis-assistant-md .omnis-md-p {
  margin: 0 0 0.75rem;
  direction: rtl;
  text-align: right;
}

.omnis-assistant-md .omnis-md-p:last-child {
  margin-bottom: 0;
}

.omnis-assistant-md .omnis-md-h2,
.omnis-assistant-md .omnis-md-h3 {
  margin: 1rem 0 0.5rem;
  font-weight: 600;
  color: rgb(15 23 42);
  direction: rtl;
  text-align: right;
}

.omnis-assistant-md .omnis-md-ul {
  margin: 0.25rem 0 0.75rem;
  padding-inline-start: 1.25rem;
  list-style: disc;
}

.omnis-assistant-md .omnis-md-li {
  margin: 0.25rem 0;
  direction: rtl;
  text-align: right;
}

/* All assistant bubbles — forced RTL (mixed Arabic/Latin must not flip layout) */
.source-assistant-body {
  direction: rtl;
  text-align: right;
}

.source-assistant-body [data-ai-text],
.source-assistant-body [data-ai-text] .omnis-md-p,
.source-assistant-body [data-ai-text] .omnis-md-h2,
.source-assistant-body [data-ai-text] .omnis-md-h3,
.source-assistant-body [data-ai-text] .omnis-md-ul,
.source-assistant-body [data-ai-text] .omnis-md-li {
  direction: rtl !important;
  text-align: right !important;
}

.omnis-assistant-md .omnis-md-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background: rgb(241 245 249);
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
}
#chat-input-wrap {
  min-width: 0;
}

/* صور + نص داخل تمرير واحد (مهم على WebView) */
#composer-scroll {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  max-height: var(--composer-scroll-max, min(42dvh, 15rem));
}

#composer-thumb-slot:not(.hidden) {
  min-height: 0;
  position: relative;
  z-index: 1;
}

#chat-input {
  position: relative;
  z-index: 0;
  border-bottom-width: 1px;
  box-sizing: border-box;
}

#chat-input:focus {
  border-bottom-color: rgb(56 189 248);
}

.composer-pending-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  padding: 0.25rem;
}

.composer-pending-thumb-wrap img {
  display: block;
}

#chat-main {
  transition: background-color 0.2s ease-out;
}

/* Pin scrolled user questions below fixed header */
#chat-thread .mb-6 .mb-2.flex.justify-end {
  scroll-margin-top: 4.5rem;
}

/* Sheet shell + Gemini-style vertical slide */
.sheet-root {
  transition: opacity 0.28s ease-out;
}

.sheet-root .sheet-panel {
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}

.sheet-root.is-open {
  pointer-events: auto;
  opacity: 1;
}

.sheet-root.is-open .sheet-panel {
  transform: translateY(0) !important;
}

.sheet-root.is-open .sheet-backdrop {
  opacity: 1;
}

.sheet-backdrop {
  opacity: 0;
  transition: opacity 0.28s ease-out;
}

/* Shared option surface — selected: light gray #f3f4f6 */
.sheet-option-btn {
  border-radius: 1rem;
  border: 1px solid rgb(241 245 249);
  background-color: rgb(255 255 255);
  text-align: start;
  font-weight: 600;
  color: rgb(30 41 59);
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease;
}

.sheet-option-btn:hover {
  border-color: rgb(226 232 240);
  background-color: rgb(248 250 252);
}

.sheet-option-btn.is-active {
  background-color: #f3f4f6;
  border-color: rgb(226 232 240);
}

/* Tools row: icon + label */
.sheet-option-btn--tool {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.875rem;
  padding: 0.95rem 1rem;
}

.sheet-option-btn--tool .tool-opt-icon {
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background-color: rgb(241 245 249);
  color: rgb(71 85 105);
  font-size: 1.05rem;
}

.sheet-option-btn--tool.is-active .tool-opt-icon {
  background-color: rgb(226 232 240);
  color: rgb(51 65 85);
}

/* Status stack: title, then faded description strictly below */
.sheet-option-btn--status {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  padding: 0.95rem 1rem;
}

.sheet-option-btn--status .status-title {
  font-size: 1rem;
  font-weight: 700;
  color: rgb(15 23 42);
  line-height: 1.35;
}

.sheet-option-btn--status .status-desc {
  font-size: 0.8125rem;
  font-weight: 400;
  color: rgb(148 163 184);
  line-height: 1.45;
}

/* Plus sheet rows */
.status-plus-row.is-active {
  background-color: #f3f4f6;
  border-color: rgb(226 232 240);
}

.status-option--plus .status-title {
  font-size: 1rem;
  font-weight: 700;
  color: rgb(15 23 42);
  line-height: 1.35;
}

.status-option--plus .status-desc {
  font-size: 0.8125rem;
  font-weight: 400;
  color: rgb(148 163 184);
  line-height: 1.45;
}

.sheet-plus-row {
  display: flex;
  width: 100%;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  border-radius: 1rem;
  border: 1px solid rgb(241 245 249);
  background-color: rgb(255 255 255);
  padding: 0.95rem 1rem;
  text-align: start;
  font-weight: 400;
  color: rgb(30 41 59);
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease;
}

.sheet-plus-row:hover {
  border-color: rgb(226 232 240);
  background-color: rgb(248 250 252);
}

.sheet-plus-row .plus-opt-icon {
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background-color: rgb(241 245 249);
  color: rgb(71 85 105);
  font-size: 1.05rem;
}

#toast.is-visible {
  pointer-events: auto;
  opacity: 1;
}

#toast.is-visible .toast-inner {
  animation: toast-in 0.25s ease-out forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet-root,
  .sheet-root .sheet-panel,
  .sheet-backdrop,
  #toast {
    transition-duration: 0.01ms !important;
  }

  .sheet-root .sheet-panel {
    transition: transform 0.01ms linear !important;
  }

  #toast.is-visible .toast-inner {
    animation: none;
  }

  .sidebar-overlay,
  .sidebar-panel {
    transition-duration: 0.01ms !important;
  }

  .voice-focus-root,
  .voice-focus-card,
  .mic-wrap.is-recording .mic-wave,
  .voice-focus-mic {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* Sidebar drawer (75% width, slides from right) */
.sidebar-overlay {
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.sidebar-panel {
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
}

.sidebar-root.is-open {
  pointer-events: auto;
}

.sidebar-root.is-open .sidebar-overlay {
  opacity: 1;
}

.sidebar-root.is-open .sidebar-panel {
  transform: translateX(0);
}

.sidebar-archive-list {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* Mic hold — pulsing blue waves (footer) */
.mic-wrap .mic-wave {
  position: absolute;
  inset: -2px;
  border-radius: 9999px;
  border: 2px solid rgb(56 189 248 / 0.45);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.65);
}

.mic-wrap.is-recording .mic-wave {
  animation: mic-wave-ring 1.35s ease-out infinite;
}

.mic-wrap.is-recording .mic-wave--2 {
  animation-delay: 0.38s;
}

.mic-wrap.is-recording .mic-wave--3 {
  animation-delay: 0.76s;
}

@keyframes mic-wave-ring {
  0% {
    opacity: 0.85;
    transform: scale(0.65);
  }
  100% {
    opacity: 0;
    transform: scale(2.15);
  }
}

/* Voice focus screen */
.voice-focus-card {
  opacity: 0;
  transform: translateY(0.75rem) scale(0.97);
  transition:
    transform 0.32s cubic-bezier(0.32, 0.72, 0, 1),
    opacity 0.28s ease-out;
}

.voice-focus-root.is-open {
  pointer-events: auto;
  opacity: 1;
}

.voice-focus-root.is-open .voice-focus-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.voice-focus-mic {
  animation: voice-mic-pulse 1.1s ease-in-out infinite;
}

@keyframes voice-mic-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.88;
  }
}
/* ========== خطوط النظام ========== */
body, input, textarea, button, .sheet-option-btn, .sheet-plus-row, .status-title, .status-desc, .footer-status-btn, #btn-sidebar-menu, #btn-new-chat {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code, pre, .monospace {
  font-family: "SF Mono", "JetBrains Mono", "Fira Code", monospace;
}

/* تحسين النصوص العربية */
[lang="ar"], [dir="rtl"], .arabic-text {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
}

/* تحسين العناوين */
h1, h2, h3, h4, .font-semibold, .font-bold {
  letter-spacing: -0.02em;
}

/* Auth session bootstrap loading */
.auth-session-loading {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.95rem;
  color: #334155;
}

.auth-session-loading[hidden] {
  display: none !important;
}

.auth-session-loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid #e2e8f0;
  border-top-color: #0284c7;
  border-radius: 50%;
  animation: auth-session-spin 0.8s linear infinite;
}

@keyframes auth-session-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Login screen (pre-chat gate) */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.login-screen[hidden] {
  display: none !important;
}

.login-screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: min(90vw, 24rem);
  padding: 16px;
}

.login-logo {
  width: min(72vw, 320px);
  height: auto;
  margin-bottom: 18px;
  object-fit: contain;
}

.login-screen-btn {
  width: 200px;
  border: 1px solid #90caf9;
  background: transparent;
  color: #000000;
  padding: 8px 20px;
  text-align: center;
  border-radius: 10px;
}
/* Auth Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: white;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.modal-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid #eef2ff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.close-modal {
  font-size: 28px;
  cursor: pointer;
  color: #94a3b8;
  transition: color 0.2s;
}

.close-modal:hover {
  color: #475569;
}

.modal-body {
  padding: 24px;
}

.auth-input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s;
  box-sizing: border-box;
}

.auth-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56,189,248,0.1);
}

.forgot-password-link {
  text-align: left;
  margin-bottom: 20px;
}

.forgot-password {
  font-size: 13px;
  color: #7dd3fc;
  cursor: not-allowed;
}

.forgot-password.active {
  color: #0ea5e9;
  cursor: pointer;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.auth-btn.primary {
  background-color: white;
  color: #1e293b;
  border: 1px solid #bae6fd;
}

.auth-btn.primary:hover {
  background-color: #f0f9ff;
  border-color: #38bdf8;
}

.auth-btn.primary:disabled,
.auth-btn.primary.auth-btn--disabled {
  cursor: not-allowed;
  opacity: 0.45;
  pointer-events: none;
  background-color: #f8fafc;
  border-color: #e2e8f0;
  color: #94a3b8;
}

.auth-btn.secondary {
  background-color: white;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.auth-btn.secondary:hover {
  background-color: #f8fafc;
}

.switch-auth {
  text-align: center;
  font-size: 13px;
  color: #64748b;
}

.switch-auth a {
  color: #0ea5e9;
  text-decoration: none;
  cursor: pointer;
}

.switch-auth a:hover {
  text-decoration: underline;
}

.resend-code {
  text-align: left;
  margin-bottom: 20px;
}

.resend-code a {
  color: #0ea5e9;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

#usage-limit-overlay {
  position: fixed;
  inset-inline: 0;
  bottom: calc(var(--footer-h, 10.5rem) + 12px);
  z-index: 70;
  display: none;
  padding: 12px 12px calc(env(safe-area-inset-bottom) + 12px);
  pointer-events: auto;
}

#usage-limit-overlay.is-visible {
  display: block;
}

#usage-limit-overlay .usage-limit-card {
  width: min(680px, 100%);
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 16px;
  padding: 14px 14px 12px;
  box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.12);
  text-align: center;
}

#usage-limit-overlay .usage-limit-message {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.5;
}

#usage-limit-overlay .usage-limit-timer {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 700;
  color: #0284c7;
  letter-spacing: 0.04em;
}

#usage-limit-overlay .usage-limit-upsell {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  line-height: 1.5;
}

#usage-limit-overlay .usage-limit-api-input {
  margin-top: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
  box-sizing: border-box;
  background: #ffffff;
  border: 0.5px solid #38bdf8;
  font-size: 14px;
  direction: ltr;
}

#usage-limit-overlay .usage-limit-api-input::placeholder {
  color: rgba(100, 116, 139, 0.75);
}

#usage-limit-overlay .usage-limit-api-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #0ea5e9;
  text-decoration: none;
}

#usage-limit-overlay .usage-limit-api-link:hover {
  text-decoration: underline;
}

#usage-limit-overlay .usage-limit-confirm {
  display: block;
  width: fit-content;
  margin: 10px auto 0;
  padding: 6px 16px;
  border-radius: 12px;
  background: transparent;
  border: 0.5px solid #38bdf8;
  color: #0284c7;
  font-size: 13px;
  font-weight: 700;
}

#usage-limit-overlay .usage-limit-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

#api-key-save-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  pointer-events: auto;
}

#api-key-save-overlay.is-visible {
  display: flex;
}

#api-key-save-overlay .api-key-save-overlay-message {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  text-align: center;
  padding: 1rem 1.5rem;
}

#btn-send.omnis-stop-processing {
  width: 2.75rem !important;
  height: 2.75rem !important;
  min-width: 2.75rem !important;
  min-height: 2.75rem !important;
  max-width: 2.75rem !important;
  max-height: 2.75rem !important;
  padding: 0 !important;
  margin: 0 !important;
  flex: 0 0 2.75rem !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: none !important;
  background: transparent !important;
  box-sizing: border-box !important;
  outline: none !important;
  box-shadow: none !important;
}

/* Visual stop icon only — same scale as .text-xl send arrow; hit area stays 2.75rem */
#btn-send.omnis-stop-processing::before {
  content: '';
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid #ef4444;
  border-radius: 3px;
  box-sizing: border-box;
  flex-shrink: 0;
}

#api-key-invalid-toast {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 90;
  display: none;
  justify-content: center;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 10px);
  pointer-events: none;
}

#api-key-invalid-toast.is-visible {
  display: flex;
}

#api-key-invalid-toast .api-key-invalid-toast-inner {
  max-width: 22rem;
  border-radius: 16px;
  background: #e0f2fe;
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #0c4a6e;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
