/* ═══════════════════════════════════════════════════════════════════════════
   NeoCode Smart Editor — style.css
   Cyberpunk Glassmorphism | Dark Mode | Futuristic 2080 Aesthetic (RTL Adapted)
═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────────────────── */
:root {
  --bg-deep:        #04040f;
  --bg-dark:        #080818;
  --bg-panel:       rgba(8, 8, 28, 0.72);
  --bg-glass:       rgba(12, 12, 40, 0.65);
  --bg-glass-light: rgba(20, 20, 60, 0.55);
  --bg-input:       rgba(6, 6, 22, 0.8);

  --cyan:     #00f5ff;
  --cyan-dim: rgba(0, 245, 255, 0.18);
  --cyan-glow:rgba(0, 245, 255, 0.35);
  --purple:   #bf00ff;
  --purple-dim:rgba(191, 0, 255, 0.18);
  --purple-glow:rgba(191, 0, 255, 0.35);
  --green:    #00ff88;
  --green-dim:rgba(0, 255, 136, 0.18);
  --pink:     #ff0099;
  --orange:   #ff6600;
  --yellow:   #ffe000;

  --text-primary:   #e8eaff;
  --text-secondary: #8890c4;
  --text-muted:     #4a5080;
  --text-code:      #c9d1f5;

  --border-glass: rgba(0, 245, 255, 0.12);
  --border-hover: rgba(0, 245, 255, 0.35);
  --border-active:rgba(0, 245, 255, 0.7);

  --font-display: 'Cairo', sans-serif;
  --font-ui:      'Cairo', sans-serif;
  --font-code:    'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --header-h:        60px;
  --bottom-toolbar-h:64px;
  --transition:      0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.14s ease;
}

/* ── Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  min-height: 100dvh;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-weight: 600;
  overflow: hidden;
  position: relative;
}

button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

textarea {
  font-family: var(--font-code);
}

/* ── Animated Background ───────────────────────────────────────────────── */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 245, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 245, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.bg-scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 0;
}

.neon-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  z-index: 0;
  animation: orbFloat 12s ease-in-out infinite alternate;
}

.orb-1 {
  width: 500px; height: 500px;
  background: rgba(0, 245, 255, 0.06);
  top: -150px; left: -150px;
  animation-delay: 0s;
}

.orb-2 {
  width: 400px; height: 400px;
  background: rgba(191, 0, 255, 0.07);
  top: 30%; right: -100px;
  animation-delay: -4s;
}

.orb-3 {
  width: 350px; height: 350px;
  background: rgba(0, 255, 136, 0.04);
  bottom: -100px; left: 40%;
  animation-delay: -8s;
}

@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, 30px) scale(1.08); }
}

/* ── Glass Panel Base ──────────────────────────────────────────────────── */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-glass);
  position: relative;
  z-index: 1;
}

.glass-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(0,245,255,0.04) 0%, transparent 50%);
  pointer-events: none;
}

/* ── Header ───────────────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--border-glass);
  z-index: 100;
  border-radius: 0;
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--purple), transparent);
  opacity: 0.6;
}

/* Brand */
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
}

.brand-icon svg {
  width: 36px; height: 36px;
  filter: drop-shadow(0 0 8px var(--cyan-glow));
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 6px var(--cyan-glow));
}

.brand-tagline {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: var(--font-display);
}

/* Header Tabs */
.header-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
  max-width: 320px;
  margin: 0 auto;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  transition: var(--transition);
  position: relative;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-glass-light);
  border-color: var(--border-glass);
}

.tab-btn.active {
  color: var(--cyan);
  background: var(--cyan-dim);
  border-color: var(--border-active);
  box-shadow: 0 0 16px var(--cyan-glow), inset 0 0 12px rgba(0,245,255,0.08);
  text-shadow: 0 0 10px var(--cyan);
}

.tab-icon {
  font-size: 0.75rem;
  font-weight: 900;
  opacity: 0.8;
}

.tab-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  opacity: 0.7;
}

.html-dot { background: #ff6b6b; box-shadow: 0 0 6px #ff6b6b; }
.css-dot  { background: #4ecaff; box-shadow: 0 0 6px #4ecaff; }
.js-dot   { background: #ffe066; box-shadow: 0 0 6px #ffe066; }

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-glass-light);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  transition: var(--transition);
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn svg { width: 16px; height: 16px; }

.icon-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.icon-btn.glow-cyan:hover {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 16px var(--cyan-glow);
}

.icon-btn.glow-purple:hover {
  background: var(--purple-dim);
  border-color: var(--purple);
  color: var(--purple);
  box-shadow: 0 0 16px var(--purple-glow);
}

.run-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 20px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(0,255,136,0.18), rgba(0,245,255,0.12));
  border: 1px solid rgba(0,255,136,0.5);
  color: var(--green);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  transition: var(--transition);
  box-shadow: 0 0 12px rgba(0,255,136,0.2);
  cursor: pointer;
}

.run-btn svg { width: 12px; height: 12px; flex-shrink: 0; }

.run-btn:hover {
  background: linear-gradient(135deg, rgba(0,255,136,0.3), rgba(0,245,255,0.2));
  border-color: var(--green);
  box-shadow: 0 0 24px rgba(0,255,136,0.4), 0 4px 12px rgba(0,255,136,0.15);
  transform: translateY(-1px);
  text-shadow: 0 0 8px var(--green);
}

.run-btn:active { transform: scale(0.97); }

/* ── Dropdown ─────────────────────────────────────────────────────────── */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  border-radius: var(--radius-lg);
  padding: 8px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.97);
  transition: var(--transition);
  pointer-events: none;
}

.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.dropdown-header {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--cyan);
  text-transform: uppercase;
  padding: 4px 10px 8px;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 4px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  text-align: right;
  transition: var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.dropdown-item svg { width: 15px; height: 15px; flex-shrink: 0; }

.dropdown-item:hover {
  color: var(--cyan);
  background: var(--cyan-dim);
  border-color: rgba(0,245,255,0.2);
  padding-right: 16px;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-glass);
  margin: 6px 0;
}

/* ── Workspace ────────────────────────────────────────────────────────── */
.workspace {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 0;
  overflow: hidden;
  z-index: 1;
}

@media (max-width: 768px) {
  .workspace {
    bottom: var(--bottom-toolbar-h);
    flex-direction: column;
  }
}

/* ── Editor Panel ─────────────────────────────────────────────────────── */
.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 0;
  border-top: none;
  border-right: none;
  border-bottom: none;
  border-left: 1px solid var(--border-glass);
  overflow: hidden;
  transition: flex 0.3s ease;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(4, 4, 20, 0.5);
  flex-shrink: 0;
  gap: 8px;
}

.editor-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-code);
  font-size: 0.75rem;
}

.current-file {
  color: var(--cyan);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.line-col {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.editor-quick-actions {
  display: flex;
  gap: 4px;
}

.micro-btn {
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  transition: var(--transition-fast);
  cursor: pointer;
}

.micro-btn svg { width: 13px; height: 13px; }

.micro-btn:hover {
  color: var(--cyan);
  background: var(--cyan-dim);
  border-color: rgba(0,245,255,0.25);
}

/* Editors Container */
.editors-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.editor-wrapper {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: row;
}

.editor-wrapper.active {
  display: flex;
}

/* Line Numbers */
.line-numbers {
  width: 44px;
  flex-shrink: 0;
  background: rgba(4, 4, 20, 0.6);
  border-left: 1px solid var(--border-glass);
  overflow: hidden;
  padding: 12px 0;
  font-family: var(--font-code);
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--text-muted);
  text-align: right;
  user-select: none;
  pointer-events: none;
}

.line-numbers span {
  display: block;
  padding-right: 8px;
  letter-spacing: -0.02em;
}

/* Code Editor Textarea */
.code-editor {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: var(--bg-input);
  color: var(--text-code);
  font-family: var(--font-code);
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 12px 16px;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  caret-color: var(--cyan);
  transition: background var(--transition);
  -webkit-overflow-scrolling: touch;
}

.code-editor:focus {
  background: rgba(8, 8, 30, 0.95);
}

.code-editor::selection {
  background: rgba(0, 245, 255, 0.2);
}

.code-editor::-webkit-scrollbar { width: 6px; height: 6px; }
.code-editor::-webkit-scrollbar-track { background: transparent; }
.code-editor::-webkit-scrollbar-thumb {
  background: rgba(0,245,255,0.2);
  border-radius: 3px;
}
.code-editor::-webkit-scrollbar-thumb:hover {
  background: rgba(0,245,255,0.4);
}

/* Language-specific accent */
#codeCSS  { caret-color: #4ecaff; }
#codeCSS::selection  { background: rgba(78,202,255,0.2); }
#codeJS   { caret-color: #ffe066; }
#codeJS::selection   { background: rgba(255,224,102,0.2); }

/* ── Panel Divider ────────────────────────────────────────────────────── */
.panel-divider {
  width: 6px;
  background: var(--border-glass);
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  transition: background var(--transition-fast);
}

.panel-divider:hover,
.panel-divider.dragging {
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-glow);
}

.panel-divider::before {
  content: '⋮';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  letter-spacing: -2px;
}

@media (max-width: 768px) {
  .panel-divider { display: none; }
}

/* ── Preview Panel ────────────────────────────────────────────────────── */
.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border-glass);
  overflow: hidden;
  transition: flex 0.3s ease, opacity 0.3s ease;
}

.preview-panel.hidden {
  flex: 0;
  opacity: 0;
  pointer-events: none;
  min-width: 0;
  width: 0;
  overflow: hidden;
}

@media (max-width: 768px) {
  .preview-panel {
    display: none;
  }
  .preview-panel.mobile-visible {
    display: flex;
    position: fixed;
    inset: var(--header-h) 0 var(--bottom-toolbar-h) 0;
    z-index: 50;
  }
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(4, 4, 20, 0.5);
  flex-shrink: 0;
}

.preview-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--purple);
  text-transform: uppercase;
}

.preview-title svg { width: 14px; height: 14px; }

.preview-actions {
  display: flex;
  gap: 4px;
}

.preview-frame-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#previewFrame {
  width: 100%; height: 100%;
  border: none;
  background: white;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(4, 4, 20, 0.9);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 1rem;
  transition: opacity 0.3s;
}

.preview-placeholder.hidden { opacity: 0; pointer-events: none; }

.placeholder-icon {
  font-size: 3rem;
  filter: drop-shadow(0 0 16px var(--cyan-glow));
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
}

/* ── Bottom Toolbar (Mobile) ─────────────────────────────────────────── */
.bottom-toolbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-toolbar-h);
  border-radius: 0;
  border-bottom: none;
  border-left: none;
  border-right: none;
  border-top: 1px solid var(--border-glass);
  z-index: 100;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
}

.bottom-toolbar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--purple), var(--cyan), transparent);
  opacity: 0.7;
}

@media (max-width: 768px) {
  .bottom-toolbar { display: flex; }
  .header-tabs { display: none; }
  .brand-tagline { display: none; }
  
  /* إخفاء قائمة الأدوات العلوية في الموبايل لإجبار الاستخدام السفلي */
  .app-header .dropdown { display: none; }
}

.bottom-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  transition: var(--transition);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  flex: 1;
  max-width: 70px;
}

.bottom-btn svg { width: 18px; height: 18px; }

.bottom-btn:hover, .bottom-btn.active {
  color: var(--cyan);
  background: var(--cyan-dim);
  border-color: rgba(0,245,255,0.2);
}

.bottom-btn.fab-center {
  width: 50px; height: 50px;
  border-radius: 50%;
  flex: 0;
  max-width: none;
  background: linear-gradient(135deg, rgba(0,255,136,0.25), rgba(0,245,255,0.15));
  border: 1.5px solid var(--green);
  color: var(--green);
  box-shadow: 0 0 20px rgba(0,255,136,0.3);
  padding: 0;
  gap: 0;
  font-size: 0;
}

.bottom-btn.fab-center svg {
  width: 22px; height: 22px;
  fill: currentColor;
  stroke: none;
}

.bottom-btn.fab-center:hover {
  background: linear-gradient(135deg, rgba(0,255,136,0.4), rgba(0,245,255,0.25));
  box-shadow: 0 0 32px rgba(0,255,136,0.5);
  transform: scale(1.08);
  border-color: var(--green);
  color: var(--green);
}

/* ── Mobile Menu ──────────────────────────────────────────────────────── */
.mobile-menu {
  display: none;
  position: fixed;
  bottom: var(--bottom-toolbar-h);
  left: 8px; right: 8px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 150;
  padding: 16px;
  opacity: 0;
  transform: translateY(20px);
  transition: var(--transition);
  pointer-events: none;
}

.mobile-menu.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (max-width: 768px) {
  .mobile-menu { display: block; }
}

.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cyan);
  text-transform: uppercase;
}

.mobile-menu-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.mobile-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  background: var(--bg-glass-light);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  transition: var(--transition-fast);
  cursor: pointer;
}

.mobile-tool-btn svg { width: 20px; height: 20px; }

.mobile-tool-btn:hover {
  color: var(--cyan);
  background: var(--cyan-dim);
  border-color: rgba(0,245,255,0.35);
  transform: translateY(-2px);
}

/* ── Attachments Panel ────────────────────────────────────────────────── */
.attachments-panel {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 12px;
  width: 260px;
  max-height: 320px;
  border-radius: var(--radius-lg);
  z-index: 90;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attachments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--cyan);
  font-weight: 700;
}

.attachments-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass-light);
  border: 1px solid var(--border-glass);
  font-family: var(--font-code);
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow: hidden;
}

.attachment-item .att-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-item .att-size {
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Modals ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 540px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: var(--transition);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-close {
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: var(--transition-fast);
  cursor: pointer;
  background: transparent;
  border: none;
}

.modal-close:hover {
  color: var(--pink);
  background: rgba(255,0,153,0.15);
}

.modal-body {
  padding: 20px 22px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border-glass);
  background: rgba(0,0,0,0.2);
  flex-shrink: 0;
}

/* Buttons */
.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 22px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(0,245,255,0.2), rgba(191,0,255,0.15));
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary svg { width: 14px; height: 14px; }

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(0,245,255,0.3), rgba(191,0,255,0.25));
  box-shadow: 0 0 20px var(--cyan-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  padding: 9px 22px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-ghost {
  padding: 9px 22px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-ghost:hover {
  color: var(--cyan);
  border-color: rgba(0,245,255,0.2);
}

.btn-danger {
  padding: 9px 22px;
  border-radius: var(--radius-md);
  background: rgba(255,0,153,0.15);
  border: 1px solid var(--pink);
  color: var(--pink);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:hover {
  background: rgba(255,0,153,0.25);
  box-shadow: 0 0 16px rgba(255,0,153,0.3);
}

.glow-cyan {
  box-shadow: 0 0 12px var(--cyan-glow);
}

/* ── Checkboxes ───────────────────────────────────────────────────────── */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cyber-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.cyber-checkbox:hover { color: var(--text-primary); }
.cyber-checkbox.accent { color: var(--cyan); }

.cyber-checkbox input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 20px; height: 20px;
  border-radius: 5px;
  border: 1.5px solid var(--border-hover);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  position: relative;
}

.cyber-checkbox input:checked + .checkmark {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-glow);
}

.cyber-checkbox input:checked + .checkmark::after {
  content: '✓';
  color: var(--cyan);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

.cyber-checkbox.accent .checkmark { border-color: var(--cyan); }
.cyber-checkbox.accent input:checked + .checkmark { background: rgba(0,245,255,0.25); }

.divider-line {
  height: 1px;
  background: var(--border-glass);
}

/* Merge preview */
.merge-preview-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.merge-preview-box {
  background: rgba(4, 4, 20, 0.9);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-code);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-code);
  overflow: auto;
  max-height: 160px;
  white-space: pre;
}

/* Alert icon */
.alert-icon {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 4px;
}

/* ── Dropzone ─────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(0,245,255,0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dropzone:hover, .dropzone.drag-over {
  border-color: var(--cyan);
  background: var(--cyan-dim);
  box-shadow: 0 0 24px var(--cyan-glow);
}

.dropzone-icon { font-size: 3rem; line-height: 1; }

.dropzone p {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 700;
}

.dropzone-sub { color: var(--text-muted) !important; font-size: 0.85rem !important; }

.upload-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass-light);
  border: 1px solid var(--border-glass);
  font-family: var(--font-code);
  font-size: 0.8rem;
}

.upload-item .ui-icon { font-size: 1rem; }
.upload-item .ui-name { color: var(--cyan); flex: 1; }
.upload-item .ui-dest { color: var(--text-muted); font-size: 0.75rem; }

/* ── Toast Notifications ─────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 12px; /* RTL - الإشعارات على اليسار */
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 500;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 220px;
  max-width: 340px;
  pointer-events: auto;
  animation: toastIn 0.3s ease forwards;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast.hiding { animation: toastOut 0.3s ease forwards; }

.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--pink); }
.toast.info    { border-color: var(--cyan); }
.toast.warning { border-color: var(--yellow); }

.toast-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast.success .toast-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.toast.error   .toast-dot { background: var(--pink);  box-shadow: 0 0 8px var(--pink); }
.toast.info    .toast-dot { background: var(--cyan);  box-shadow: 0 0 8px var(--cyan); }
.toast.warning .toast-dot { background: var(--yellow);box-shadow: 0 0 8px var(--yellow); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-20px); }
}

/* ── Scrollbar global ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0,245,255,0.2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0,245,255,0.4); }

/* ── Responsive Adjustments ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-header { padding: 0 12px; gap: 8px; }
  .header-actions { gap: 6px; }
  .run-btn span { display: none; }
  .run-btn { padding: 7px 12px; }
  .brand-icon svg { width: 30px; height: 30px; }
  .brand-name { font-size: 1rem; }

  /* إخفاء القائمة العلوية بالموبايل لإجبار استخدام القائمة السفلية المريحة */
  .app-header .dropdown { display: none; }

  .editor-panel {
    border: none;
    border-bottom: 1px solid var(--border-glass);
  }

  .workspace {
    flex-direction: column;
  }
}

@media (min-width: 769px) {
  .bottom-toolbar { display: none; }
  .mobile-menu { display: none !important; }
}

/* ── Focus visible ───────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ── Utility ─────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}