/* Omdaa Code — مركز الوكلاء (موبايل أولاً · Pro Glass) */
.agents-pro-glass {
  --agents-bg: rgba(6, 24, 40, 0.92);
  --agents-chip: rgba(56, 189, 248, 0.12);
  --agents-chip-active: rgba(56, 189, 248, 0.22);
  --agents-gold: #fcd34d;
  background: var(--agents-bg);
}

#agents-view { display: none; flex-direction: column; min-height: 0; }

.agents-head, .agents-strip { display: none !important; }

.jazab-chat { background: linear-gradient(180deg, rgba(6, 24, 40, 0.98), rgba(2, 10, 18, 0.99)); }

.jazab-empty {
  position: relative; text-align: center; padding: 28px 20px 16px; margin-top: 8vh;
}
.jazab-empty-glow {
  position: absolute; inset: 10% 15%; border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.2), transparent 70%);
  filter: blur(24px); pointer-events: none;
}
.jazab-empty h2 {
  font-size: clamp(22px, 6vw, 28px);
  letter-spacing: -0.02em;
  font-weight: 800; margin: 0 0 8px;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.jazab-empty p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; }

.jazab-log { padding: 8px 10px 4px; }

.jazab-bubble {
  margin-bottom: 14px; max-width: 96%;
  animation: jazab-in 0.35s ease-out;
}
@keyframes jazab-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.jazab-bubble.u { margin-inline-start: auto; }
.jazab-bubble.a { margin-inline-end: auto; }
.jazab-bubble-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.jazab-avatar {
  width: 26px; height: 26px; border-radius: 8px; font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(56, 189, 248, 0.15); color: var(--accent);
}
.jazab-bubble.u .jazab-avatar { background: rgba(255,255,255,.08); color: var(--muted); }
.jazab-name { font-size: 12px; font-weight: 700; color: var(--accent); }
.jazab-bubble-body, .jazab-stream {
  padding: 12px 14px; border-radius: 16px; font-size: 15px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.06);
}
.jazab-bubble.u .jazab-bubble-body {
  background: rgba(56, 189, 248, 0.12); border-color: rgba(56, 189, 248, 0.25);
}
.jazab-bubble.streaming .jazab-stream {
  border-color: rgba(252, 211, 77, 0.25);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.08);
}
.jazab-stream::after {
  content: '▍'; animation: jazab-cursor 0.9s step-end infinite; color: var(--accent);
}
@keyframes jazab-cursor { 50% { opacity: 0; } }
.pulse-dot { animation: agent-pulse 1.2s ease-in-out infinite; }

.jazab-sys { font-size: 11px; padding: 6px 10px; opacity: 0.85; }

.omdaa-mode-bar {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(56, 189, 248, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.omdaa-mode-bar button {
  flex: 1; height: 34px; border-radius: 9px; padding: 0 8px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.04em;
  text-transform: uppercase;
  background: transparent; color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.omdaa-mode-bar button.on {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.16);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35), 0 4px 12px rgba(56, 189, 248, 0.08);
}
.omdaa-mode-bar button[data-mode="agent"].on {
  color: var(--agents-gold);
  background: rgba(252, 211, 77, 0.14);
  box-shadow: inset 0 0 0 1px rgba(252, 211, 77, 0.35), 0 4px 12px rgba(252, 211, 77, 0.06);
}

.jazab-status {
  font-size: 12px; color: var(--accent); padding: 4px 6px 6px; font-weight: 600;
  animation: jazab-pulse-text 1.5s ease-in-out infinite;
}
@keyframes jazab-pulse-text { 50% { opacity: 0.55; } }

.jazab-composer { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
.jazab-send {
  flex: none !important; width: 52px; font-size: 22px; font-weight: 800;
  border-radius: 14px !important;
}

.agents-head {
  display: none;
}
.agents-head strong { font-size: 16px; letter-spacing: -0.02em; }
#agents-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: rgba(252, 211, 77, 0.2); color: var(--agents-gold);
  font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}

.agents-strip {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 10px 8px; flex: none;
  -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
}
.agents-strip::-webkit-scrollbar { display: none; }

.agent-chip {
  flex: none; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 160px; height: 40px; padding: 0 12px 0 10px;
  border-radius: 999px; border: 1px solid rgba(56, 189, 248, 0.2);
  background: var(--agents-chip); color: var(--muted);
  font-size: 12px; font-weight: 600;
}
.agent-chip.active {
  color: var(--text); border-color: rgba(56, 189, 248, 0.45);
  background: var(--agents-chip-active);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.15);
}
.agent-chip .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent2);
  animation: agent-pulse 1.2s ease-in-out infinite;
}
@keyframes agent-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}
.agent-chip .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-chip .x {
  width: 22px; height: 22px; border-radius: 50%; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.agent-chip .x:active { background: rgba(255,255,255,.1); }

.agents-new-chip {
  flex: none; height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px dashed rgba(56, 189, 248, 0.35); color: var(--accent);
  font-size: 12px; font-weight: 700;
}
.agents-new-chip:active { background: rgba(56, 189, 248, 0.12); }

.agents-log {
  flex: 1; min-height: 0; overflow: auto; padding: 12px 12px 8px;
  -webkit-overflow-scrolling: touch;
}
.agents-msg {
  margin-bottom: 12px; padding: 10px 12px; border-radius: 14px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
  font-size: 14px; line-height: 1.65;
}
.agents-msg.u { border-color: rgba(56, 189, 248, 0.2); background: rgba(56, 189, 248, 0.08); }
.agents-msg.a { border-color: rgba(252, 211, 77, 0.15); }
.agents-msg.sys { font-size: 12px; color: var(--muted); background: transparent; border-style: dashed; }
.agents-msg pre {
  margin: 6px 0 0; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: 13px; direction: ltr; text-align: left;
}
.agents-msg b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }

.agents-composer {
  flex: none; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(10, 37, 64, 0.85);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}
.agents-mode-row {
  display: flex; gap: 6px; margin-bottom: 8px;
}
.agents-mode-row button {
  flex: 1; height: 36px; border-radius: 10px; font-size: 12px; font-weight: 700;
  background: rgba(255,255,255,.04); color: var(--muted);
}
.agents-mode-row button.on {
  background: rgba(56, 189, 248, 0.18); color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
}
.agents-mode-row button[data-mode="auto"].on { color: var(--agents-gold); background: rgba(252, 211, 77, 0.12); }

#agents-input {
  width: 100%; min-height: 72px; max-height: 140px; resize: none;
  padding: 12px; border-radius: 14px; font-size: 15px; line-height: 1.5;
  background: rgba(0,0,0,.25); color: var(--text); border: 1px solid var(--line);
}
#agents-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.agents-composer-actions {
  display: flex; gap: 8px; margin-top: 8px; align-items: stretch;
}
#agents-at {
  flex: none; height: 44px; padding: 0 14px; border-radius: 12px;
  background: rgba(255,255,255,.05); color: var(--muted); font-size: 13px; font-weight: 600;
}
#agents-send {
  flex: 1; height: 44px; border-radius: 12px; font-size: 15px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #0ea5e9); color: #04121f;
}
#agents-send:disabled { opacity: 0.45; }

body.kb #agents-view .agents-composer { padding-bottom: 8px; }

@media (max-width: 899px) {
  #bottomnav [data-go="agents"] { flex: 1.12; }
  #bottomnav [data-go="agents"] svg {
    width: 24px; height: 24px;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.45));
  }
  body[data-view="agents"] #agents-view { padding-bottom: 0; }
}

@media (min-width: 900px) {
  #agents-view { border-left: 1px solid var(--line); max-width: 420px; }
}

/* قائمة مهام الوكيل */
.agents-todos {
  flex: none; max-height: 120px; overflow: auto; padding: 6px 12px 4px;
  border-bottom: 1px solid var(--line); background: rgba(0,0,0,.15);
}
.agents-todos .todo-row {
  display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 4px 0;
}
.agents-todos .todo-row.done { opacity: 0.55; text-decoration: line-through; }
.agents-todos .todo-box {
  width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--accent);
  flex: none; margin-top: 2px;
}
.agents-todos .todo-row.done .todo-box { background: var(--accent2); border-color: var(--accent2); }

/* شريط تقدم خطي (تحت strip) */
.agents-progress {
  flex: none;
  padding: 6px 12px 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.12);
}
.agents-progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 6px;
}
.agents-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.55);
  transition: width 0.35s ease;
}
.agents-progress-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

#agents-revert:not([hidden]) {
  color: var(--accent2);
  border: 1px solid rgba(252, 211, 77, 0.35);
  border-radius: 10px;
}

/* diff inline */
.diff-box {
  max-height: 45vh; overflow: auto; font-family: var(--mono); font-size: 12px;
  background: #0a0f14; border-radius: 12px; padding: 8px; margin: 8px 0;
  border: 1px solid var(--line);
}
.diff-line { display: flex; gap: 8px; padding: 1px 4px; white-space: pre-wrap; word-break: break-word; }
.diff-g { width: 14px; flex: none; opacity: 0.7; user-select: none; }
.diff-add { background: rgba(76, 209, 154, 0.12); color: #a7f3d0; }
.diff-del { background: rgba(255, 107, 107, 0.12); color: #fecaca; }
.diff-ctx { color: var(--muted); }
.sheet.diff-sheet { max-height: 92%; }

/* Composer grab (المحرر) */
.composer-grab {
  position: absolute; left: 50%;
  /* فوق bottom nav — ليس وسط الشاشة */
  bottom: calc(var(--nav-h, 56px) + env(safe-area-inset-bottom) + 4px);
  transform: translateX(-50%);
  z-index: 28; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 20px 4px; border: 0; background: transparent; color: var(--muted);
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  pointer-events: auto;
}
.composer-grab-pill {
  width: 48px; height: 5px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.45);
}
.composer-grab-label { color: var(--accent); }
body[data-view="editor"] #editor-view .composer-grab { display: flex; }
body:not([data-view="editor"]) .composer-grab,
body.kb .composer-grab { display: none !important; }
@media (min-width: 900px) { .composer-grab { display: none !important; } }

/* شريط وكلاء بالخلفية (فوق bottom nav) */
.agents-bg-bar {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(var(--nav-h, 56px) + env(safe-area-inset-bottom) + 6px);
  z-index: 38;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px;
  pointer-events: none;
}
.agents-bg-bar:not([hidden]) { pointer-events: auto; }
.agents-bg-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 72vw;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(6, 24, 40, 0.92);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.agents-bg-chip .pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: agents-pulse 1.2s ease-in-out infinite;
}
@keyframes agents-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}
.agents-bg-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agents-bg-meta { color: var(--accent); font-variant-numeric: tabular-nums; }
body[data-view="agents"] .agents-bg-bar { display: none !important; }
body.kb .agents-bg-bar { bottom: 8px; }

/* لوحة diff في المحرر */
.editor-diff-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 52%;
  z-index: 32;
  display: flex;
  flex-direction: column;
  border-top: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(6, 24, 40, 0.94);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
  padding-bottom: env(safe-area-inset-bottom);
}
#editor-view { position: relative; }
.editor-diff-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.editor-diff-path { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55vw; }
.editor-diff-hint {
  flex: none;
  margin: 0;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--accent2);
  background: rgba(252, 211, 77, 0.08);
}
.editor-diff-body { flex: 1; min-height: 0; max-height: none; margin: 0; border-radius: 0; border: 0; }
.editor-diff-actions {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  justify-content: flex-end;
}
.editor-diff-actions .primary { min-width: 120px; }
.editor-diff-actions .danger { min-width: 80px; }
body:not([data-view="editor"]) #editor-diff-panel { display: none !important; }
