:root {
  --primary: #7C3AED;
  --primary-dark: #6D28D9;
  --bg: #F1F5F9;
  --sidebar: #1E1B4B;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --muted: #64748B;
  --success: #059669;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Vazirmatn', Tahoma, sans-serif; direction: rtl; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; }
.hidden { display: none !important; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar); color: #E0E7FF; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-brand { padding: 1.25rem; font-weight: 700; font-size: 1.1rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-sub { font-size: 0.75rem; opacity: 0.7; font-weight: 400; margin-top: 0.25rem; }
.sidebar-nav { flex: 1; padding: 0.5rem 0; overflow-y: auto; }
.nav-link { display: block; width: 100%; text-align: right; padding: 0.7rem 1.25rem; background: none; border: none; color: #E0E7FF; cursor: pointer; font-size: 0.95rem; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,0.1); }
.nav-link.active { border-right: 3px solid var(--primary); }
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.1); }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: white; border-bottom: 1px solid var(--border); padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar h1 { font-size: 1.15rem; }
.topbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.content { flex: 1; padding: 1.5rem; overflow: auto; }

/* Buttons */
.btn { padding: 0.55rem 1rem; border-radius: 8px; border: none; cursor: pointer; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 0.35rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: white; border: 1px solid var(--border); color: var(--text); }
.btn-success { background: var(--success); color: white; }
.btn-ghost-light { background: transparent; border: 1px solid rgba(255,255,255,0.25); color: #E0E7FF; width: 100%; padding: 0.6rem; border-radius: 8px; cursor: pointer; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; }
.grid-sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.site-card { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; cursor: pointer; transition: box-shadow 0.2s; }
.site-card:hover { box-shadow: 0 8px 24px rgba(30,27,75,0.1); }
.site-card h3 { margin-bottom: 0.35rem; }
.site-card .tag { color: var(--muted); font-size: 0.85rem; direction: ltr; text-align: right; }
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.72rem; }
.badge-draft { background: #FEF3C7; color: #D97706; }
.badge-published { background: #D1FAE5; color: var(--success); }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1E1B4B 0%, #7C3AED 100%); padding: 1rem; }
.login-box { background: white; border-radius: 16px; padding: 2rem; width: 100%; max-width: 420px; }
.login-box h2 { text-align: center; margin-bottom: 0.25rem; }
.login-box .subtitle { text-align: center; color: var(--muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* Onboarding wizard */
.wizard { max-width: 900px; margin: 0 auto; }
.wizard-steps { display: flex; gap: 0.5rem; margin-bottom: 2rem; flex-wrap: wrap; }
.wizard-step { flex: 1; min-width: 120px; text-align: center; padding: 0.75rem; border-radius: 8px; background: white; border: 1px solid var(--border); font-size: 0.85rem; color: var(--muted); }
.wizard-step.active { border-color: var(--primary); color: var(--primary); font-weight: 600; background: #F5F3FF; }
.wizard-step.done { border-color: var(--success); color: var(--success); }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.template-card { border: 2px solid var(--border); border-radius: 12px; overflow: hidden; cursor: pointer; background: white; transition: border-color 0.2s, transform 0.2s; }
.template-card:hover { transform: translateY(-2px); }
.template-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,58,237,0.2); }
.template-preview { height: 100px; display: flex; align-items: center; justify-content: center; color: white; font-size: 2rem; }
.template-info { padding: 0.85rem; }
.template-info h4 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.template-info p { font-size: 0.8rem; color: var(--muted); }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; color: var(--muted); }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 0.7rem; border: 1px solid var(--border); border-radius: 8px; }
.form-hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }
.wizard-actions { display: flex; justify-content: space-between; margin-top: 1.5rem; gap: 1rem; }

/* Editor */
.editor-layout { display: grid; grid-template-columns: 240px 1fr 320px; gap: 1rem; min-height: calc(100vh - 120px); }
.editor-panel { background: white; border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.editor-panel-header { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600; background: #F8FAFC; font-size: 0.9rem; }
.editor-panel-body { padding: 0.75rem; overflow-y: auto; flex: 1; }
.section-item { padding: 0.75rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.5rem; cursor: pointer; font-size: 0.9rem; }
.section-item:hover, .section-item.active { border-color: var(--primary); background: #F5F3FF; }
.preview-wrap { position: relative; min-height: 500px; }
.preview-frame { width: 100%; height: 100%; min-height: 500px; border: none; background: white; }
.preview-overlay { position: absolute; inset: 0; pointer-events: none; border: 2px dashed transparent; border-radius: 12px; }
.color-input { width: 48px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.repeater-item { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; margin-bottom: 0.5rem; background: #F8FAFC; }
.empty { color: var(--muted); text-align: center; padding: 2rem; font-size: 0.9rem; }
.toast { position: fixed; bottom: 24px; left: 24px; background: #1E1B4B; color: white; padding: 0.75rem 1.25rem; border-radius: 8px; z-index: 9999; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
