/* Risalah Amaliyah — Islamic green, warm gold, elegant dark theme */
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;1,400&family=DM+Sans:wght@300;400;500&family=Amiri:wght@400;700&display=swap');

/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg: #0d1810;
  --bg-2: #142218;
  --bg-3: #1a2d20;
  --bg-card: #1e3326;
  --border: rgba(255,255,255,0.07);
  --border-gold: rgba(212,175,55,0.25);
  --green: #2d8a4e;
  --green-light: #3aaf64;
  --green-dim: rgba(45,138,78,0.15);
  --gold: #d4af37;
  --gold-dim: rgba(212,175,55,0.12);
  --gold-light: #f0d060;
  --text: #e8ede9;
  --text-2: #9ab89f;
  --text-3: #5a7a5f;
  --arabic-font: 'Amiri', 'Traditional Arabic', serif;
  --body-font: 'DM Sans', sans-serif;
  --heading-font: 'Lora', Georgia, serif;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --nav-h: 64px;
  --header-h: 56px;
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--body-font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + 16px);
  will-change: transform, opacity;
}

/* ─── Bottom Navigation ──────────────────────────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: rgba(14, 26, 17, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding: 0 8px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: 12px;
  color: var(--text-3);
  transition: color var(--transition), background var(--transition);
  min-width: 52px;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 10px; font-weight: 500; }
.nav-item.active { color: var(--green-light); }
.nav-item.active .nav-dot {
  width: 4px; height: 4px;
  background: var(--green-light);
  border-radius: 50%;
  margin-top: -2px;
}

/* ─── Page Transitions ───────────────────────────────────────────────────── */
.slide-out-left { animation: slideOutLeft 0.18s ease forwards; }
.slide-out-right { animation: slideOutRight 0.18s ease forwards; }
.slide-in { animation: slideIn 0.22s cubic-bezier(0.25,0.46,0.45,0.94) forwards; }

@keyframes slideOutLeft {
  to { transform: translateX(-30px); opacity: 0; }
}
@keyframes slideOutRight {
  to { transform: translateX(30px); opacity: 0; }
}
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Animate-in items ───────────────────────────────────────────────────── */
.animate-in {
  animation: fadeUp 0.4s cubic-bezier(0.25,0.46,0.45,0.94) both;
  animation-delay: var(--delay, 0ms);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Page Headers ───────────────────────────────────────────────────────── */
.page-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: var(--header-h);
  background: rgba(13, 24, 16, 0.95);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-family: var(--heading-font);
  font-size: 1.1rem;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Home Header */
.home-header {
  position: relative;
  height: auto;
  min-height: 200px;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 24px 20px 20px;
  background: transparent;
  border: none;
  overflow: hidden;
}
.home-header-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #0d2a18 0%, #142e1e 50%, #0f2215 100%);
  z-index: 0;
}
.home-header-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 80% at 80% 20%, rgba(212,175,55,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 10% 80%, rgba(45,138,78,0.12) 0%, transparent 50%);
}
.home-header-bg::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 200px; height: 200px;
  background: url("data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M100 10 L120 50 L160 50 L130 75 L145 115 L100 90 L55 115 L70 75 L40 50 L80 50 Z' fill='none' stroke='rgba(212,175,55,0.08)' stroke-width='1'/%3E%3C/svg%3E") center/contain no-repeat;
  opacity: 0.6;
}
.home-header-content { position: relative; z-index: 1; }
.home-bismillah {
  font-family: var(--arabic-font);
  font-size: 1.5rem;
  color: var(--gold);
  opacity: 0.9;
  margin-bottom: 10px;
  text-shadow: 0 2px 8px rgba(212,175,55,0.3);
}
.home-title {
  font-family: var(--heading-font);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.home-subtitle {
  font-size: 0.85rem;
  color: var(--text-2);
  margin-top: 4px;
}

/* ─── Search Bar ─────────────────────────────────────────────────────────── */
.search-bar-wrapper { padding: 16px 16px 8px; }
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-3);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.search-bar:active { background: var(--bg-card); border-color: var(--green); }
.search-bar svg { width: 18px; height: 18px; flex-shrink: 0; }
.search-input-wrap { flex: 1; position: relative; }
.search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  padding: 0;
}
.search-input::placeholder { color: var(--text-3); }
.search-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: 0.9rem;
}
.search-hint svg { width: 32px; height: 32px; opacity: 0.4; }

/* ─── Sections ───────────────────────────────────────────────────────────── */
.section { padding: 20px 16px 4px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title {
  font-family: var(--heading-font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.see-all { font-size: 0.8rem; color: var(--green-light); }

/* ─── Category Grid ──────────────────────────────────────────────────────── */
.category-grid { display: flex; flex-direction: column; gap: 8px; }
.category-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.category-card:active { transform: scale(0.98); background: var(--bg-3); }
.cat-icon { font-size: 1.5rem; width: 36px; text-align: center; }
.cat-info { flex: 1; }
.cat-name { display: block; font-weight: 500; font-size: 0.95rem; }
.cat-count { display: block; font-size: 0.78rem; color: var(--text-3); margin-top: 2px; }
.cat-arrow { color: var(--text-3); font-size: 1.4rem; line-height: 1; }

/* ─── Content Rows ───────────────────────────────────────────────────────── */
.content-list { display: flex; flex-direction: column; gap: 1px; }
.content-list.padded { padding: 0 16px; }
.content-row {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.content-row:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.content-row:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); border-bottom: none; }
.content-row:only-child { border-radius: var(--radius-sm); border-bottom: none; }
.content-row:active { background: var(--bg-3); }
.content-row-inner {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
}
.content-row-text { flex: 1; min-width: 0; }
.content-row-title {
  display: block;
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.content-row-ar {
  display: block;
  font-family: var(--arabic-font);
  font-size: 0.85rem;
  color: var(--gold);
  margin-top: 2px;
  opacity: 0.8;
  direction: rtl;
}
.content-row-cat {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--text-3);
  background: var(--bg-3);
  border-radius: 4px;
  padding: 1px 6px;
  margin-top: 4px;
}

/* ─── Bookmark Button ────────────────────────────────────────────────────── */
.bookmark-row-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition), transform 0.15s;
}
.bookmark-row-btn svg { width: 18px; height: 18px; }
.bookmark-row-btn:active { transform: scale(0.88); }
.bookmark-row-btn.bookmarked { color: var(--gold); }

/* ─── Detail Page ────────────────────────────────────────────────────────── */
.page-detail {}
.detail-header-title {
  font-size: 1rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-content { padding: 20px 16px; display: flex; flex-direction: column; gap: 20px; }
.detail-category {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--green-light);
  background: var(--green-dim);
  border: 1px solid rgba(58,175,100,0.2);
  border-radius: 6px;
  padding: 3px 10px;
  align-self: flex-start;
}
.arabic-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(30,51,38,0.8) 100%);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.arabic-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(212,175,55,0.06) 0%, transparent 60%);
}
.arabic-text {
  font-family: var(--arabic-font);
  font-size: 1.8rem;
  line-height: 2.2;
  color: var(--text);
  direction: rtl;
  text-align: center;
  position: relative;
}
.detail-section {}
.detail-section-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.transliteration-text {
  font-style: italic;
  color: var(--text-2);
  line-height: 1.7;
  font-size: 0.95rem;
}
.translation-text {
  color: var(--text);
  line-height: 1.75;
  font-size: 0.95rem;
}
.notes-card {
  background: var(--gold-dim);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.notes-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.notes-text { font-size: 0.88rem; color: var(--text-2); line-height: 1.6; }

/* ─── Icon Button ─────────────────────────────────────────────────────────── */
.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: var(--text-2);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { background: var(--bg-3); color: var(--text); }
.icon-btn.bookmarked { color: var(--gold); }
.icon-btn.danger { color: #e05555; }
.back-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); border-radius: 10px;
  flex-shrink: 0;
}
.back-btn svg { width: 22px; height: 22px; }
.back-btn:active { background: var(--bg-3); }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--green);
  color: white;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), transform 0.15s;
}
.btn-primary:active { background: var(--green-light); transform: scale(0.97); }
.btn-primary.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-secondary {
  background: var(--bg-3);
  color: var(--text-2);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
}

/* ─── Category Tabs ──────────────────────────────────────────────────────── */
.category-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.category-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  white-space: nowrap;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg-3);
  color: var(--text-3);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.cat-tab.active {
  background: var(--green-dim);
  color: var(--green-light);
  border-color: rgba(58,175,100,0.3);
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 440px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1e3a26;
  border: 1px solid rgba(58,175,100,0.2);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-error { background: #3a1e1e; border-color: rgba(224,85,85,0.3); }
.toast.toast-success { background: #1e3326; border-color: rgba(58,175,100,0.3); }
.toast.toast-info { background: #1e2a3a; border-color: rgba(85,130,224,0.3); }

/* ─── Loading ─────────────────────────────────────────────────────────────── */
.loading-dots {
  display: flex; gap: 6px; justify-content: center; padding: 40px;
}
.loading-dots span {
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
  font-size: 0.9rem;
  line-height: 1.6;
}
.empty-icon, .login-prompt-icon { font-size: 2.5rem; margin-bottom: 12px; }
.login-prompt { display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ─── Admin Panel ─────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.admin-tab {
  padding: 14px 20px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.admin-tab.active { color: var(--green-light); border-bottom-color: var(--green-light); }
.admin-tab-panel { padding: 16px; }
.admin-tab-panel.hidden { display: none; }
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.admin-toolbar h2 { font-family: var(--heading-font); font-size: 1rem; }
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-row {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  gap: 12px;
}
.admin-row-info { flex: 1; min-width: 0; }
.admin-row-title { display: block; font-weight: 500; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-row-meta { display: block; font-size: 0.76rem; color: var(--text-3); margin-top: 2px; }
.admin-row-actions { display: flex; gap: 4px; }
.badge-draft {
  display: inline-block;
  background: rgba(212,175,55,0.15);
  color: var(--gold);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.7rem;
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-end; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); opacity: 0; transition: opacity 0.25s; }
.modal.open .modal-backdrop { opacity: 1; }
.modal-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-2);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.25,0.46,0.45,0.94);
}
.modal.open .modal-panel { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-family: var(--heading-font); font-size: 1rem; flex: 1; }
.modal-body { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.78rem; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.form-group input, .form-group textarea, .form-group select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--green);
}
.form-group .arabic-input {
  font-family: var(--arabic-font);
  font-size: 1.2rem;
  line-height: 1.8;
  direction: rtl;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── User Avatar ─────────────────────────────────────────────────────────── */
#user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--green-dim);
  border: 2px solid var(--border-gold);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
  flex-shrink: 0;
}
#user-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ─── Responsive (tablet+) ───────────────────────────────────────────────── */
@media (min-width: 480px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  #bottom-nav { border-radius: 0; }
}
