/* =============================================
   Ztoonir CMS - Main Stylesheet
   RTL, Dark/Light Mode, Responsive
   No external dependencies
   ============================================= */

/* ─── CSS Variables ─── */
:root {
  --bg:          #0f0f0f;
  --bg2:         #1a1a1a;
  --bg3:         #242424;
  --card:        #1e1e1e;
  --border:      #2e2e2e;
  --text:        #e8e8e8;
  --text2:       #a0a0a0;
  --text3:       #6a6a6a;
  --accent:      #7c3aed;
  --accent2:     #9f67ff;
  --accent-bg:   rgba(124, 58, 237, 0.12);
  --success:     #10b981;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --info:        #3b82f6;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --radius:      12px;
  --radius-sm:   8px;
  --transition:  all 0.2s ease;
  --font:        'Segoe UI', Tahoma, 'Arial', sans-serif;
}

[data-theme="light"] {
  --bg:          #f5f5f5;
  --bg2:         #ffffff;
  --bg3:         #f0f0f0;
  --card:        #ffffff;
  --border:      #e0e0e0;
  --text:        #1a1a1a;
  --text2:       #555555;
  --text3:       #888888;
  --accent:      #7c3aed;
  --accent2:     #6d28d9;
  --accent-bg:   rgba(124, 58, 237, 0.08);
  --shadow:      0 4px 20px rgba(0,0,0,0.1);
}

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

html {
  direction: rtl;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

a { color: var(--accent2); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent); }

img { max-width: 100%; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ─── Layout ─── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* ─── Header / Navbar ─── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
}

.navbar-brand .logo-icon { font-size: 1.5rem; }

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.navbar-nav a {
  color: var(--text2);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  white-space: nowrap;
}

.navbar-nav a:hover, .navbar-nav a.active { color: var(--text); background: var(--bg3); }

.navbar-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.theme-toggle:hover { background: var(--accent-bg); border-color: var(--accent); }

.hamburger {
  display: none;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.2rem;
  align-items: center; justify-content: center;
  transition: var(--transition);
}

/* ─── Hero Section ─── */
.hero {
  padding: 80px 0 60px;
  text-align: center;
  background: radial-gradient(ellipse at top, var(--accent-bg), transparent 70%);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: 100px;
  color: var(--accent2);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text2);
  max-width: 600px;
  margin: 0 auto 32px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
}

.hero-stat { text-align: center; }
.hero-stat .num { font-size: 2rem; font-weight: 800; color: var(--accent2); }
.hero-stat .lbl { font-size: 0.85rem; color: var(--text3); }

/* ─── Section Cards ─── */
.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 40px 0;
}

.section-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
}

.section-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0;
  transition: var(--transition);
}

.section-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow); color: inherit; }
.section-card:hover::before { opacity: 1; }

.section-card-icon { font-size: 2.5rem; margin-bottom: 12px; display: block; }
.section-card h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.section-card p { font-size: 0.88rem; color: var(--text2); margin-bottom: 12px; }
.section-card-meta { display: flex; align-items: center; gap: 12px; font-size: 0.8rem; color: var(--text3); }
.section-card-count { background: var(--bg3); padding: 3px 10px; border-radius: 100px; }

/* ─── Page Header ─── */
.page-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header p { color: var(--text2); margin-top: 8px; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text3);
  margin-bottom: 12px;
}
.breadcrumb a { color: var(--text3); }
.breadcrumb a:hover { color: var(--accent2); }
.breadcrumb-sep { opacity: 0.5; }

/* ─── Post Cards ─── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.posts-list { display: flex; flex-direction: column; gap: 16px; }

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: var(--transition);
  position: relative;
}

.post-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }

.post-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text2);
}

.post-card-content {
  font-size: 0.95rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.post-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text3);
}

.post-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-web { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-tg  { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-admin { background: rgba(245,158,11,0.15); color: #fbbf24; }

.media-img  { border-radius: var(--radius-sm); margin-top: 12px; max-height: 300px; object-fit: cover; }
.media-audio{ width: 100%; margin-top: 12px; }
.media-video{ width: 100%; border-radius: var(--radius-sm); margin-top: 12px; max-height: 320px; }

/* ─── Submit Form ─── */
.submit-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 680px;
  margin: 0 auto;
}

.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text2);
}
.form-label .req { color: var(--danger); }

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  outline: none;
  transition: var(--transition);
  direction: rtl;
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus { border-color: var(--accent); background: var(--bg2); box-shadow: 0 0 0 3px var(--accent-bg); }

.form-textarea { resize: vertical; min-height: 120px; }

.form-select option { background: var(--bg2); }

.form-hint { font-size: 0.8rem; color: var(--text3); margin-top: 5px; }

.captcha-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.captcha-question {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: monospace;
  color: var(--accent2);
  letter-spacing: 2px;
  white-space: nowrap;
}
.captcha-input { width: 100px !important; text-align: center; }

.media-type-select {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.media-type-option {
  flex: 1;
  min-width: 100px;
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  color: var(--text2);
}
.media-type-option:hover { border-color: var(--accent); color: var(--accent2); }
.media-type-option.selected { border-color: var(--accent); background: var(--accent-bg); color: var(--accent2); }
.media-type-option .icon { font-size: 1.4rem; display: block; margin-bottom: 4px; }

#file-upload-area { display: none; }
#file-upload-area.show { display: block; }
#text-area.hidden { display: none; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); color: #fff; transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--accent);
  color: var(--accent2);
}
.btn-outline:hover { background: var(--accent-bg); }

.btn-ghost {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-full { width: 100%; }

/* ─── Alerts ─── */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: 16px;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); color: #34d399; }
.alert-danger   { background: rgba(239,68,68,0.1);  border-color: rgba(239,68,68,0.3);  color: #f87171; }
.alert-warning  { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: #fbbf24; }
.alert-info     { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); color: #60a5fa; }

/* ─── Pagination ─── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 32px 0;
  flex-wrap: wrap;
}
.page-btn {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 0.9rem;
  transition: var(--transition);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent2); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── Footer ─── */
.footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 80px;
  text-align: center;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.footer-links a { color: var(--text3); font-size: 0.88rem; }
.footer-links a:hover { color: var(--accent2); }
.footer-copy { font-size: 0.82rem; color: var(--text3); }

/* ─── Admin Layout ─── */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0; top: 0; bottom: 0;
  z-index: 50;
  transition: transform 0.3s;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav { flex: 1; padding: 16px 12px; }

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 0.9rem;
  transition: var(--transition);
  margin-bottom: 4px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.sidebar-nav-item:hover, .sidebar-nav-item.active {
  background: var(--accent-bg);
  color: var(--accent2);
}
.sidebar-nav-item .icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-badge {
  margin-right: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 100px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.admin-main {
  flex: 1;
  margin-right: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.admin-topbar-title { font-weight: 700; font-size: 1rem; }

.admin-content { flex: 1; padding: 28px 24px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
}

/* ─── Dashboard Stats ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--accent); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-num { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-lbl { font-size: 0.82rem; color: var(--text3); margin-top: 3px; }

/* ─── Admin Table ─── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th {
  background: var(--bg3);
  color: var(--text2);
  padding: 10px 14px;
  text-align: right;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--bg3); }
.data-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

/* ─── Section headers ─── */
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  margin-right: 10px;
}

/* ─── Modal ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }
.modal-close {
  position: absolute;
  top: 14px;
  left: 14px;
  background: var(--bg3);
  border: none;
  color: var(--text);
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--danger); color: #fff; }

/* ─── Badge / Status ─── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-pending  { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-approved { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-rejected { background: rgba(239,68,68,0.15);  color: #f87171; }

/* ─── Login Page ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, var(--accent-bg), transparent 60%);
}
.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.login-box h1 {
  text-align: center;
  margin-bottom: 28px;
  font-size: 1.6rem;
  font-weight: 800;
}

/* ─── Installer ─── */
.installer-wrap {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  background: radial-gradient(ellipse at top, var(--accent-bg), transparent 60%);
}
.installer-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow);
}
.installer-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  justify-content: center;
}
.installer-step {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg3);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text3);
}
.installer-step.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.installer-step.done { background: var(--success); border-color: var(--success); color: #fff; }

/* ─── Content truncation ─── */
.truncate-text {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.read-more-btn {
  background: none;
  border: none;
  color: var(--accent2);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 0;
  display: block;
  margin-top: 4px;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state .icon { font-size: 4rem; display: block; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; color: var(--text2); }
.empty-state p { font-size: 0.9rem; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .navbar-nav { display: none; position: fixed; top: 60px; right: 0; left: 0;
    background: var(--bg2); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: 12px; gap: 4px; z-index: 99; }
  .navbar-nav.open { display: flex; }
  .hamburger { display: flex; }

  .hero { padding: 40px 0 30px; }
  .hero h1 { font-size: 1.8rem; }
  .hero-stats { gap: 20px; }
  .hero-stat .num { font-size: 1.4rem; }

  .sections-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
  .posts-grid { grid-template-columns: 1fr; }

  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .admin-main { margin-right: 0; }
  .admin-content { padding: 16px; }

  .submit-box { padding: 20px; }
  .captcha-box { flex-direction: column; align-items: flex-start; }
  .captcha-input { width: 100% !important; }

  .data-table-wrap { font-size: 0.82rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .sections-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .media-type-select { flex-direction: column; }
  .login-box, .installer-box { padding: 24px 16px; }
}
