*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f1f5f9;
  direction: rtl;
  color: #1f2937;
  min-height: 100vh;
}

.editor-header {
  background: #1e293b;
  color: #fff;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-header h1 { font-size: 1.2rem; font-weight: 700; }
.editor-header span { font-size: 0.85rem; color: #94a3b8; }

.editor-body {
  max-width: 780px;
  margin: 40px auto;
  padding: 0 20px 130px;
}

.section-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  padding: 28px 28px 24px;
  margin-bottom: 24px;
}

.section-card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #f1f5f9;
}

.field-row {
  margin-bottom: 18px;
}

.field-row label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.field-row input[type="text"],
.field-row input[type="url"],
.field-row input[type="email"],
.field-row textarea {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.97rem;
  font-family: inherit;
  color: #1f2937;
  direction: rtl;
  transition: border-color 0.2s;
}

.field-row input:focus,
.field-row textarea:focus {
  outline: none;
  border-color: #2563eb;
}

.field-row textarea { min-height: 80px; resize: vertical; }

.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.color-row label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #374151;
  min-width: 120px;
}

.color-row input[type="color"] {
  width: 48px;
  height: 36px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}

.color-row .color-hex {
  font-size: 0.85rem;
  color: #6b7280;
  font-family: monospace;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.save-bar {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 16px 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}

.save-bar-note {
  order: -1;
  flex-basis: 100%;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 8px 14px;
}

.save-bar .preview-link {
  font-size: 0.9rem;
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}

.save-btn {
  background: #2563eb;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 36px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.save-btn:hover { background: #1e40af; }
.save-btn:disabled { background: #93c5fd; cursor: not-allowed; }

.undo-btn {
  background: transparent;
  border: 2px solid #e2e8f0;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 50px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.undo-btn:hover:not(:disabled) { border-color: #f87171; color: #ef4444; }
.undo-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* THEME PICKER */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 4px;
  max-width: 400px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #2563eb;
}

.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.theme-card {
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.theme-card:hover { border-color: #94a3b8; transform: translateY(-2px); }
.theme-card.active { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

.theme-preview {
  height: 90px;
  position: relative;
  overflow: hidden;
}

.theme-preview--1 { background: #111; }
.theme-preview--2 { background: #fff; border-bottom: 1px solid #e2e8f0; }
.theme-preview--3 { background: #2c1a0e; }
.theme-preview--4 { background: #1f1c16; position: relative; overflow: hidden; }
.theme-preview--5 { background: #f6f2ea; position: relative; overflow: hidden; }

.tp-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
}

.tp-bar--1 { background: rgba(255,255,255,0.05); border-top: 1px solid rgba(255,255,255,0.07); }
.tp-bar--2 { background: #f9fafb; border-top: 1px solid #e5e7eb; }
.tp-bar--3 { background: rgba(255,255,255,0.06); border-top: 1px solid rgba(255,255,255,0.08); }

.tp-dot { width: 6px; height: 6px; border-radius: 50%; }
.tp-line-h { height: 2px; border-radius: 2px; flex: 1; }

.tp-hero-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.tp-title-line { height: 3px; border-radius: 2px; }
.tp-sub-line { height: 2px; border-radius: 1px; opacity: 0.4; }
.tp-btn-line { height: 14px; width: 50px; border-radius: 2px; margin-top: 2px; }

.theme-info { padding: 10px 12px; }
.theme-name { font-size: 0.85rem; font-weight: 700; color: #1e293b; }
.theme-desc { font-size: 0.75rem; color: #64748b; margin-top: 2px; }

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: #065f46;
  color: #fff;
  padding: 12px 28px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.3s ease;
  z-index: 999;
}

.toast.show { transform: translateX(-50%) translateY(0); }

.image-preview {
  margin-top: 10px;
  max-width: 100%;
  max-height: 160px;
  border-radius: 8px;
  object-fit: cover;
  display: none;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-btn {
  background: #f1f5f9;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}
.upload-btn:hover { background: #e2e8f0; border-color: #94a3b8; color: #1e293b; }

.upload-btn-cancel {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  color: #dc2626;
  font-size: 0.8rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
}
.upload-btn-cancel:hover { background: #fecaca; }

.upload-status {
  font-size: 0.82rem;
  color: #64748b;
}

.gallery-upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 4px;
}

.gallery-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.gallery-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px dashed #e2e8f0;
  background-size: cover;
  background-position: center;
  background-color: #f8fafc;
}
.gallery-thumb.has-img { border-color: #94a3b8; }

.upload-btn-sm {
  width: 100%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.78rem;
  font-family: inherit;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}
.upload-btn-sm:hover { background: #f1f5f9; color: #1e293b; }

.gallery-del-btn {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  color: #dc2626;
  font-size: 0.75rem;
  padding: 4px 7px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.gallery-del-btn:hover { background: #fecaca; }

@media (max-width: 600px) {
  .two-col { grid-template-columns: 1fr; }
  .editor-body { margin-top: 24px; }
  .section-card { padding: 20px; }
}
