:root {
  --primary: #1a6cf7;
  --primary-light: #e8f0ff;
  --primary-dark: #0f4bc4;
  --accent: #f97316;
  --bg: #f5f7fb;
  --bg2: #ffffff;
  --bg3: #eef1f8;
  --text: #0f1623;
  --text2: #4a5568;
  --muted: #8a94a6;
  --border: #e2e8f4;
  --shadow-sm: 0 2px 8px rgba(26,108,247,0.08);
  --shadow: 0 8px 32px rgba(26,108,247,0.12);
  --shadow-lg: 0 20px 60px rgba(26,108,247,0.18);
  --radius: 14px;
  --radius-sm: 8px;
}

body.dark-mode {
  --bg: #0f172a; --bg2: #1e293b; --bg3: #334155;
  --text: #f8fafc; --text2: #cbd5e1; --muted: #94a3b8;
  --border: #334155; --primary-light: rgba(26,108,247,0.2);
}

* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: 'Sora', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; transition: background 0.3s; }
body.rtl { direction: rtl; font-family: 'Noto Naskh Arabic', sans-serif; }

.navbar {
  position: fixed; top:0; left:0; right:0; background: var(--bg2);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  height: 66px; display: flex; align-items: center; padding: 0 2rem; z-index: 1000;
}

.nav-logo { display: flex; align-items: center; gap: 0.8rem; text-decoration: none; color: var(--primary); font-weight: 700; }
.nav-center { flex: 1; display: flex; justify-content: center; }
.nav-search { 
  display: flex; align-items: center; background: var(--bg); 
  border: 1.5px solid var(--border); border-radius: 100px; padding: 0.4rem 1rem; gap: 0.6rem; width: 400px; 
}
.nav-search input { border:none; background:transparent; outline:none; color:var(--text); width:100%; }

.hero { margin-top: 66px; background: linear-gradient(135deg, #1a6cf7 0%, #0f4bc4 100%); padding: 4rem 2rem; text-align: center; color: white; }
.hero-tag { display: inline-flex; align-items: center; gap: 0.5rem; background: rgba(255,255,255,0.1); padding: 0.4rem 1rem; border-radius: 100px; font-size: 0.8rem; margin-bottom: 1rem; }
.hero h1 { font-size: 3rem; margin-bottom: 1rem; }
.hero-stats { display: flex; justify-content: center; gap: 3rem; margin-top: 2rem; }
.hero-stat-num { font-size: 2rem; font-weight: 700; }

.main { max-width: 1200px; margin: 0 auto; padding: 2rem; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.doc-card { 
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); 
  padding: 1.5rem; transition: transform 0.2s, box-shadow 0.2s; position: relative;
}
.doc-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }

.doc-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; margin-bottom: 1rem; }
.icon-pdf { background: #fee2e2; color: #dc2626; }
.icon-word { background: #e0f2fe; color: #0284c7; }
.icon-ppt { background: #ffedd5; color: #ea580c; }

.doc-title { font-weight: 600; margin-bottom: 0.5rem; line-height: 1.4; }
.doc-desc { color: var(--text2); font-size: 0.85rem; margin-bottom: 1.5rem; height: 3rem; overflow: hidden; }
.doc-footer { display: flex; gap: 0.5rem; }

.btn-primary, .btn-secondary { 
  padding: 0.6rem 1rem; border-radius: var(--radius-sm); border: none; cursor: pointer; 
  font-weight: 600; display: flex; align-items: center; gap: 0.4rem; transition: 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--bg3); color: var(--text); }

.modal-overlay { 
  position: fixed; inset:0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); 
  display: none; align-items: center; justify-content: center; z-index: 2000; 
}
.modal-overlay.open { display: flex; }
.modal { background: var(--bg2); width: 90%; max-width: 900px; border-radius: var(--radius); overflow: hidden; }
.modal-header { padding: 1rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; }
.modal-body { height: 70vh; }
.modal-body iframe { width: 100%; height: 100%; border: none; }

/* Admin */
.admin-overlay { position: fixed; inset:0; background: var(--bg); z-index: 3000; display: none; flex-direction: column; }
.admin-overlay.open { display: flex; }
.admin-header { background: var(--primary); color: white; padding: 1rem 2rem; display: flex; justify-content: space-between; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.admin-table th, .admin-table td { padding: 1rem; border-bottom: 1px solid var(--border); text-align: left; }

/* Toasts */
.toast { 
  position: fixed; bottom: 2rem; right: 2rem; background: var(--text); color: var(--bg); 
  padding: 1rem 2rem; border-radius: var(--radius-sm); transform: translateY(200%); transition: 0.3s; 
}
.toast.show { transform: translateY(0); }

@media (max-width: 768px) {
  .nav-search { width: 100%; }
  .hero h1 { font-size: 2rem; }
  .hero-stats { gap: 1rem; }
}

/* Theme Toggles & Icons */
.theme-toggle { 
  background: var(--bg3); 
  border: 1px solid var(--border); 
  color: var(--text); 
  cursor: pointer; 
  width: 40px; 
  height: 40px; 
  border-radius: 10px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  transition: all 0.2s;
}
.theme-toggle:hover {
  border-color: var(--primary);
  background: var(--bg2);
}
.lang-pill { display: flex; background: var(--bg3); border-radius: 100px; padding: 0.2rem; }
.lang-opt { background: none; border: none; padding: 0.3rem 0.8rem; border-radius: 100px; cursor: pointer; color: var(--muted); }
.lang-opt.active { background: var(--primary); color: white; }

/* Upload progress */
.upload-progress-container { width: 100%; height: 8px; background: var(--bg3); border-radius: 10px; overflow: hidden; }
.upload-progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s; }

.doc-badge {
  font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: 4px; font-weight: 700; text-transform: uppercase;
}
.badge-pdf { background: #fee2e2; color: #dc2626; }
.badge-word { background: #e0f2fe; color: #0284c7; }
.badge-ppt { background: #ffedd5; color: #ea580c; }

.cats-scroll { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 1rem; }
.cat-btn { 
  white-space: nowrap; padding: 0.5rem 1rem; border-radius: 100px; border: 1px solid var(--border);
  background: var(--bg2); cursor: pointer; color: var(--text2);
}
.cat-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.form-group { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.4rem; text-align: left;}
.form-input, .form-select, .form-textarea { 
  padding: 0.8rem; border-radius: var(--radius-sm); border: 1px solid var(--border); 
  background: var(--bg); color: var(--text); outline: none;
}