/* =====================================================================
   مكتبة ثانوية الإيمان — الواجهة العامة
   الألوان من شعار المدرسة: أزرق + برتقالي، على خلفية ورقية دافئة.
   ===================================================================== */

:root {
  --brand:        #1689d3;
  --brand-dark:   #0b5f98;
  --brand-ink:    #0a3b5e;
  --accent:       #f06a24;
  --accent-soft:  #fde5d6;
  --paper:        #fbf8f2;
  --paper-edge:   #efe8da;
  --ink:          #1f2a33;
  --muted:        #66727d;
  --radius:       18px;
  --font-body:    'Tajawal', system-ui, sans-serif;
  --font-display: 'El Messiri', 'Tajawal', serif;
}

html, body { min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
}
body > section:last-of-type { flex: 1 0 auto; }
h1, h2, h3, .brand span { font-family: var(--font-display); }

/* ---------- أزرار ---------- */

.btn-brand {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--brand-dark);
  --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-ink);
  --bs-btn-active-border-color: var(--brand-ink);
  --bs-btn-active-color: #fff;
  --bs-btn-focus-shadow-rgb: 22, 137, 211;
  border-radius: 999px;
  padding-inline: 1.25rem;
  font-weight: 700;
  box-shadow: 0 6px 18px -8px rgba(22, 137, 211, .8);
}
.btn-outline-brand {
  --bs-btn-color: var(--brand-dark);
  --bs-btn-border-color: rgba(22, 137, 211, .45);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand-dark);
  --bs-btn-active-color: #fff;
  border-radius: 999px;
}
.btn-user, .btn-child {
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--paper-edge);
  max-width: 260px;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.btn-child { background: var(--accent-soft); border-color: transparent; color: #8a3a0f; }
.btn-user .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 575.98px) {
  .btn-user .user-name { display: none; }
}

/* ---------- الشريط العلوي ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(251, 248, 242, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, .05);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--brand-ink);
  text-decoration: none;
  font-size: 1.15rem;
  min-width: 0;
}
.brand img { border-radius: 10px; flex-shrink: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) { .brand span { display: none; } }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }

/* ---------- البطل ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(3rem, 8vw, 6rem) 0 clamp(3rem, 7vw, 5rem);
}
.hero-compact { padding: 2.5rem 0 2rem; flex: 0 0 auto !important; }

.hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  align-items: center;
  gap: 3rem;
}
.hero-compact .hero-inner { grid-template-columns: 1fr; }
@media (max-width: 860px) {
  .hero-inner { grid-template-columns: 1fr; text-align: center; gap: 2.5rem; }
}

.hero-logo {
  border-radius: 22px;
  box-shadow: 0 14px 30px -14px rgba(11, 95, 152, .55);
  margin-bottom: 1.25rem;
  animation: pop-in .7s cubic-bezier(.2, .9, .3, 1.3) both;
}
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  color: var(--brand-ink);
  line-height: 1.25;
  margin-bottom: 1rem;
  animation: rise-in .8s .1s ease-out both;
}
.hero-compact h1 { font-size: 2rem; margin-bottom: .35rem; }
.hero .lead {
  color: var(--muted);
  font-size: 1.2rem;
  max-width: 34rem;
  margin-bottom: 2rem;
  animation: rise-in .8s .2s ease-out both;
}
@media (max-width: 860px) { .hero .lead { margin-inline: auto; } }
.hero .btn-lg { animation: rise-in .8s .3s ease-out both; }

/* خلفية متحركة: بقعتان لونيتان وحروف تطفو */
.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* تلاشٍ ناعم أسفل البطل بدل حافة حادة */
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, #000 70%, transparent);
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .35;
}
.blob-blue {
  width: 480px; height: 480px;
  background: var(--brand);
  top: -160px; right: -120px;
  animation: drift 18s ease-in-out infinite alternate;
}
.blob-orange {
  width: 380px; height: 380px;
  background: var(--accent);
  bottom: -180px; left: -80px;
  opacity: .25;
  animation: drift 22s ease-in-out infinite alternate-reverse;
}
.hero-compact .blob { opacity: .18; }

.float-letter {
  position: absolute;
  bottom: -15%;
  left: var(--x);
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  color: var(--brand);
  opacity: 0;
  animation: float-up var(--d) linear var(--delay) infinite;
}
.float-letter:nth-child(even) { color: var(--accent); }
.hero-compact .float-letter { display: none; }

/* ---------- الكتاب المفتوح (تُقلَّب صفحاته من اليسار إلى اليمين كالكتاب العربي) ---------- */

.hero-book {
  display: flex;
  flex-direction: column;
  align-items: center;
  perspective: 1600px;
  animation: rise-in 1s .25s ease-out both;
}
.book {
  --w: min(400px, 82vw);
  --h: calc(var(--w) * .64);
  position: relative;
  width: var(--w);
  height: var(--h);
  transform-style: preserve-3d;
  transform: rotateX(28deg) rotateZ(-2deg);
  animation: bob 6s ease-in-out infinite;
}
/* الغلاف تحت الصفحات */
.book::before {
  content: "";
  position: absolute;
  inset: -10px -12px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--brand-dark), var(--brand) 49%, var(--brand-ink) 50%, var(--brand) 51%, var(--brand-dark));
  transform: translateZ(-2px);
  box-shadow: 0 2px 0 var(--brand-ink);
}
.book-half, .page {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
}
.book-half {
  background: linear-gradient(90deg, #fffdf8, #f6f0e3);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04);
}
.book-left  { left: 0;  border-radius: 6px 0 0 6px; background: linear-gradient(90deg, #f4ede0, #fffdf8 18%, #fbf6ec 88%, #e9e0cf); }
.book-right { right: 0; border-radius: 0 6px 6px 0; background: linear-gradient(90deg, #e9e0cf, #fbf6ec 12%, #fffdf8 82%, #f4ede0); }

.page {
  left: 0;
  transform-origin: right center;   /* حافة الكعب */
  transform-style: preserve-3d;
  transform: translateZ(calc(1px + var(--i) * .5px));
  animation: page-turn 6s cubic-bezier(.45, .05, .35, 1) calc(var(--i) * 2s) infinite;
}
.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 6px 0 0 6px;
  background: linear-gradient(90deg, #f4ede0, #fffdf8 18%, #fbf6ec 88%, #e9e0cf);
}
.face.back {
  transform: rotateY(180deg);
  border-radius: 0 6px 6px 0;
  background: linear-gradient(90deg, #e9e0cf, #fbf6ec 12%, #fffdf8 82%, #f4ede0);
}
/* أسطر النص على الصفحة */
.lines {
  position: absolute;
  inset: 16% 14% 18% 14%;
  background:
    linear-gradient(var(--accent), var(--accent)) top right / 45% 6px no-repeat,
    repeating-linear-gradient(to bottom, rgba(10, 59, 94, .16) 0 4px, transparent 4px 13px) 0 20px / 100% calc(100% - 20px) no-repeat;
  border-radius: 2px;
  opacity: .9;
}
.book-shadow {
  width: min(380px, 78vw);
  height: 26px;
  margin-top: 26px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(10, 59, 94, .28), transparent);
  animation: shadow-bob 6s ease-in-out infinite;
}

/* ---------- المزايا ---------- */

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  padding-bottom: 4rem;
}
@media (max-width: 860px) { .features { grid-template-columns: 1fr; } }
.feature {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.6rem 1.5rem;
  box-shadow: 0 10px 30px -22px rgba(10, 59, 94, .6);
  border: 1px solid rgba(0, 0, 0, .04);
  transition: transform .25s ease, box-shadow .25s ease;
  animation: rise-in .7s ease-out both;
}
.feature:nth-child(1) { animation-delay: .35s; }
.feature:nth-child(2) { animation-delay: .45s; }
.feature:nth-child(3) { animation-delay: .55s; }
.feature:hover { transform: translateY(-4px); box-shadow: 0 18px 36px -22px rgba(10, 59, 94, .7); }
.feature i {
  display: inline-grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 14px;
  font-size: 1.5rem;
  color: var(--brand-dark);
  background: rgba(22, 137, 211, .1);
  margin-bottom: 1rem;
}
.feature:nth-child(2) i { color: #b44812; background: var(--accent-soft); }
.feature h2 { font-size: 1.3rem; color: var(--brand-ink); }
.feature p { color: var(--muted); margin: 0; }

/* ---------- قائمة الكتب (للمستخدم المسجّل) ---------- */

.catalog { padding-bottom: 4rem; }
.search-bar {
  position: relative;
  max-width: 640px;
  margin: 0 auto 2rem;
}
.search-bar i {
  position: absolute;
  right: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.search-bar .form-control {
  border-radius: 999px;
  padding: .85rem 2.8rem .85rem 1.2rem;
  border: 1px solid var(--paper-edge);
  box-shadow: 0 8px 24px -18px rgba(10, 59, 94, .6);
}
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}
.empty-state i { font-size: 3rem; color: rgba(22, 137, 211, .45); display: block; margin-bottom: .75rem; }

.catalog-filters { margin-bottom: 1.25rem; }
.catalog-filters .search-bar { margin-bottom: .9rem; }
.filter-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .5rem; }
.filter-row .form-select { width: auto; max-width: 220px; border-radius: 999px; }
.avail-switch { display: inline-flex; align-items: center; gap: .5rem; margin: 0 .5rem; padding: 0; }
.avail-switch .form-check-input { margin: 0; float: none; cursor: pointer; }
.avail-switch .form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.catalog-count { color: var(--muted); font-size: .92rem; margin-bottom: .75rem; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 1.4rem 1.1rem; }
.book-grid-sm { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
@media (max-width: 575.98px) { .book-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem .8rem; } }
.book-card { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); animation: rise-in .45s calc(var(--i, 0) * 30ms) ease-out both; }
.book-card-cover {
  position: relative; aspect-ratio: 2 / 3; border-radius: 4px 10px 10px 4px; overflow: hidden;
  background: var(--paper-edge);
  box-shadow: 0 14px 24px -16px rgba(10, 30, 50, .6), inset 4px 0 0 rgba(0, 0, 0, .08);
  transition: transform .2s ease, box-shadow .2s ease;
}
.book-card:hover .book-card-cover, .book-card:focus-visible .book-card-cover { transform: translateY(-5px) rotate(-.6deg); box-shadow: 0 22px 30px -18px rgba(10, 30, 50, .7); }
.book-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-blank {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem;
  width: 100%; height: 100%; padding: 1rem; text-align: center;
  background: linear-gradient(160deg, #1d8fd8, var(--brand-ink)); color: #fff;
  font-family: var(--font-display); font-size: 1rem; line-height: 1.4;
}
.cover-blank i { font-size: 1.8rem; opacity: .7; }
.book-card:nth-child(3n+2) .cover-blank { background: linear-gradient(160deg, #f58a4f, #b44812); }
.book-card:nth-child(3n) .cover-blank { background: linear-gradient(160deg, #3f9a6b, #1f5a3d); }
.cover-tag { position: absolute; top: .5rem; left: .5rem; font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--brand-dark); font-weight: 700; }
.book-card-body { padding-top: .6rem; }
.book-card-body h3 { font-family: var(--font-body); font-size: .98rem; font-weight: 700; margin: 0; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card:hover h3 { color: var(--brand-dark); }
.book-card-author { color: var(--muted); font-size: .84rem; margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avail { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; margin-top: .3rem; }
.avail i { font-size: .45rem; }
.avail.is-yes { color: #1d7a45; }
.avail.is-no { color: #9a4313; }

.my-summary { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.my-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .9rem; border-radius: 999px; background: #fff; border: 1px solid var(--paper-edge); color: var(--ink); text-decoration: none; font-size: .92rem; }
.my-pill:hover { border-color: var(--brand); }
.my-pill.is-ready { background: #e3f4ea; border-color: #b7e0c6; color: #1d7a45; font-weight: 700; }
.my-pill.is-late { background: #fde8e8; border-color: #f3c1c1; color: #a12a2a; }

.btn-my { border-radius: 999px; background: #fff; border: 1px solid var(--paper-edge); position: relative; display: inline-flex; align-items: center; gap: .35rem; }
.btn-my:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn-bell { padding-inline: .7rem; }
.btn-bell .top-badge { margin-inline-start: -.15rem; }
.notif-menu { width: min(360px, 92vw); padding: 0; overflow: hidden; border-radius: 14px; }
.notif-menu-head { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid rgba(0, 0, 0, .07); }
.notif-menu .notif-item { border-radius: 0; border: 0; border-bottom: 1px solid rgba(0, 0, 0, .05); }
.notif-empty { padding: 1.5rem 1rem; text-align: center; color: var(--muted); }
.notif-all { display: block; text-align: center; padding: .6rem; font-size: .9rem; text-decoration: none; background: #faf8f3; }
.notif-list { display: flex; flex-direction: column; gap: .4rem; }
.notif-item { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem 1rem; text-decoration: none; color: var(--ink);
  background: #fff; border-radius: 12px; border: 1px solid rgba(0, 0, 0, .05); position: relative; }
.notif-item:hover { background: #f8fbfe; color: var(--ink); }
.notif-item.is-unread { background: #f1f8fd; }
.notif-item.is-unread::before { content: ''; position: absolute; inset-inline-end: .7rem; top: 1rem; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.notif-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; font-size: 1.05rem; }
.notif-icon.is-good { background: #e3f4ea; color: #1d7a45; }
.notif-icon.is-warn { background: #fff3d6; color: #8a5a00; }
.notif-icon.is-bad  { background: #fde8e8; color: #a12a2a; }
.notif-icon.is-muted { background: #eceae4; color: #6b6458; }
.notif-text { display: flex; flex-direction: column; min-width: 0; padding-inline-end: .8rem; }
.notif-text strong { font-weight: 700; font-size: .93rem; line-height: 1.4; }
.notif-text span { color: var(--muted); font-size: .88rem; }
.notif-text small { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.nav-count { margin-inline-start: auto; min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: rgba(22, 137, 211, .14); color: var(--brand-dark); font-size: .78rem; font-weight: 700; text-align: center; }
.nav-count.is-alert { background: var(--accent); color: #fff; }
.admin-nav a.active .nav-count { background: rgba(255, 255, 255, .25); color: #fff; }
.top-badge { min-width: 1.25rem; height: 1.25rem; padding: 0 .3rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; }

/* صفحة الكتاب */
.book-page { padding: 2rem 0 4rem; }
.book-detail { display: grid; grid-template-columns: 240px 1fr 280px; gap: 2rem; align-items: start; margin-top: .5rem; }
@media (max-width: 991.98px) { .book-detail { grid-template-columns: 180px 1fr; } .book-detail-side { grid-column: 1 / -1; } }
@media (max-width: 575.98px) { .book-detail { grid-template-columns: 1fr; } .book-detail-cover { max-width: 200px; margin: 0 auto; } }
.book-detail-cover { aspect-ratio: 2 / 3; border-radius: 4px 12px 12px 4px; overflow: hidden; background: var(--paper-edge);
  box-shadow: 0 24px 40px -22px rgba(10, 30, 50, .7), inset 5px 0 0 rgba(0, 0, 0, .08); animation: rise-in .5s ease-out both; }
.book-detail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-detail-cover .cover-blank { font-size: 1.3rem; }
.book-detail-info h1 { font-size: 2rem; color: var(--brand-ink); margin-bottom: .25rem; }
.book-subtitle { color: var(--muted); font-size: 1.1rem; margin-bottom: .5rem; }
.book-authors { font-weight: 500; margin-bottom: 1rem; }
.book-desc { line-height: 1.9; margin-bottom: 1.25rem; max-width: 42rem; }
.book-facts { font-size: .95rem; }
.stock-card { background: #fff; border-radius: var(--radius); padding: 1.25rem; border: 1px solid rgba(0, 0, 0, .06); box-shadow: 0 14px 34px -26px rgba(10, 59, 94, .8); position: sticky; top: 88px; }
.stock-line { font-weight: 700; display: flex; align-items: center; gap: .45rem; }
.stock-line.is-yes { color: #1d7a45; }
.stock-line.is-no { color: #9a4313; }
.stock-line.is-none { color: var(--muted); }
.stock-shelf { color: var(--muted); font-size: .9rem; margin-top: .35rem; }
.my-state { display: flex; gap: .75rem; align-items: flex-start; padding: .8rem; border-radius: 12px; font-size: .92rem; }
.my-state > i { font-size: 1.4rem; }
.my-state.is-mine { background: rgba(22, 137, 211, .08); color: var(--brand-ink); }
.my-state.is-ready { background: #e3f4ea; color: #1d5c37; }
.my-state.is-wait { background: #fff6e5; color: #7a5300; }
.my-state.is-late { background: #fde8e8; color: #8d2323; }
.related-title { font-size: 1.3rem; color: var(--brand-ink); margin: 3rem 0 1rem; }

.read-card { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; padding: 1rem 1.1rem; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand), var(--brand-ink)); color: #fff; text-decoration: none;
  box-shadow: 0 16px 30px -18px rgba(10, 59, 94, .9); transition: transform .15s; }
.read-card:hover { color: #fff; transform: translateY(-2px); }
.read-card > i { font-size: 1.8rem; }
.read-card span { display: flex; flex-direction: column; }
.read-card small { opacity: .8; }

/* رفع النسخة الرقمية */
.digital-current { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.digital-thumb { width: 140px; border-radius: 4px 10px 10px 4px; box-shadow: 0 14px 26px -16px rgba(10, 30, 50, .7); background: var(--paper-edge); }
.pdf-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 2rem 1rem; text-align: center;
  border: 2px dashed #cfc7b6; border-radius: var(--radius); cursor: pointer; color: var(--muted); transition: border-color .15s, background .15s; }
.pdf-drop:hover, .pdf-drop.is-drag { border-color: var(--brand); background: rgba(22, 137, 211, .04); }
.pdf-drop.is-busy { pointer-events: none; opacity: .55; }
.pdf-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pdf-drop > i { font-size: 2.4rem; color: #c0392b; }
.pdf-drop strong { color: var(--ink); }
.pdf-drop small { max-width: 34rem; }
.upload-status { margin-top: 1rem; padding: 1rem; border-radius: 14px; background: #f8f6f1; }
.upload-status .progress { height: 10px; border-radius: 99px; }
.upload-status .progress-bar { background: var(--brand); transition: width .3s; }
.upload-preview { border: 1px solid #ddd; border-radius: 4px; background: #fff; max-height: 130px; }

/* القارئ */
.reader-body { background: radial-gradient(ellipse at top, #2c3a47, #151c23 70%); color: #e8eef3; height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.reader-bar { display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; background: rgba(0, 0, 0, .25); border-bottom: 1px solid rgba(255, 255, 255, .06); flex: 0 0 auto; }
.reader-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.reader-title strong { font-family: var(--font-display); font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-title small { color: #9fb0bf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-nav { display: flex; align-items: center; gap: .35rem; }
.reader-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .08); color: #e8eef3; display: inline-grid; place-items: center; text-decoration: none; font-size: 1.1rem; }
.reader-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.reader-goto { display: flex; align-items: center; gap: .35rem; font-size: .9rem; color: #9fb0bf; }
.reader-goto input { width: 4.2rem; text-align: center; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .15); background: rgba(0, 0, 0, .25); color: #fff; padding: .3rem; }
.reader-stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 16px; position: relative; }
.reader-book { margin: 0 auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.reader-page { background: #fdfcf8; overflow: hidden; }
.reader-page img { width: 100%; height: 100%; object-fit: contain; display: block; opacity: 0; transition: opacity .3s; pointer-events: none; }
.reader-page.is-loaded img { opacity: 1; }
.reader-page-num { position: absolute; inset: 0; display: grid; place-items: center; color: #c9c1b0; font-size: 2rem; font-family: var(--font-display); z-index: -1; }
.reader-page.is-loaded .reader-page-num { display: none; }
.reader-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: .75rem; color: #9fb0bf; }
@media (max-width: 575.98px) {
  .reader-title small { display: none; }
  .reader-goto span { display: none; }
  .reader-bar { padding: .4rem .6rem; gap: .4rem; }
  .reader-btn { width: 36px; height: 36px; }
}

/* شاشة قصيرة (هاتف بالعرض): شريط أنحف لإفساح المجال للصفحات */
@media (max-height: 500px) {
  .reader-bar { padding: .2rem .6rem; gap: .4rem; }
  .reader-btn { width: 32px; height: 32px; border-radius: 9px; font-size: 1rem; }
  .reader-title strong { font-size: .95rem; }
  .reader-title small { display: none; }
  .reader-goto input { padding: .1rem; }
}

/* وضع السحب (أجهزة اللمس): تمرير أصلي مع نقاط توقف */
.reader-swipe .reader-stage { padding: 0; }
.swipe-book {
  position: absolute; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.swipe-book::-webkit-scrollbar { display: none; }
.swipe-slide { flex: 0 0 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  scroll-snap-align: start; scroll-snap-stop: always; }
.swipe-page { position: relative; width: var(--page-w); height: var(--page-h); background: #fdfcf8; overflow: hidden;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .7); }
.swipe-page img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .25s; pointer-events: none; }
.swipe-page.is-loaded img { opacity: 1; }
.swipe-page .reader-page-num { z-index: 0; }
.swipe-page.is-loaded .reader-page-num { display: none; }
/* ظلّ الكعب بين الصفحتين المتقابلتين */
.swipe-slide.is-spread .swipe-page:first-child { box-shadow: inset -18px 0 22px -18px rgba(0, 0, 0, .35), 0 10px 30px -12px rgba(0, 0, 0, .7); }
.swipe-slide.is-spread .swipe-page:last-child { box-shadow: inset 18px 0 22px -18px rgba(0, 0, 0, .35), 0 10px 30px -12px rgba(0, 0, 0, .7); }
.swipe-book[dir="rtl"] .swipe-slide.is-spread .swipe-page:first-child { box-shadow: inset 18px 0 22px -18px rgba(0, 0, 0, .35), 0 10px 30px -12px rgba(0, 0, 0, .7); }
.swipe-book[dir="rtl"] .swipe-slide.is-spread .swipe-page:last-child { box-shadow: inset -18px 0 22px -18px rgba(0, 0, 0, .35), 0 10px 30px -12px rgba(0, 0, 0, .7); }

/* مكتبتي */
.my-page { padding: 2rem 0 4rem; }
.section-title { font-size: 1.2rem; color: var(--brand-ink); margin: 2rem 0 .9rem; display: flex; gap: .5rem; align-items: center; }
.section-title i { color: var(--brand); }
.my-list { display: flex; flex-direction: column; gap: .6rem; }
.my-item { display: flex; align-items: center; gap: 1rem; background: #fff; border-radius: 14px; padding: .8rem 1rem; border: 1px solid rgba(0, 0, 0, .05); }
.my-item .book-cover-sm { width: 52px; flex-shrink: 0; }
.my-item.is-late { border-color: #f3c1c1; background: #fffafa; }
.my-item.is-soon { border-color: #f6dca5; }
.my-item.is-ready { border-color: #b7e0c6; background: #f7fcf9; }
.my-main { flex: 1; min-width: 0; }
.my-title { font-weight: 700; color: var(--ink); text-decoration: none; }
a.my-title:hover { color: var(--brand-dark); }
.my-due { text-align: center; min-width: 150px; }
@media (max-width: 575.98px) { .my-item { flex-wrap: wrap; } .my-due { text-align: start; min-width: 0; } }
.my-history a { color: var(--ink); text-decoration: none; }
.my-history a:hover { color: var(--brand-dark); }

/* ---------- نافذة الدخول ---------- */

.modal-backdrop.show { opacity: .45; backdrop-filter: blur(2px); }
.signin-card {
  border: 0;
  border-radius: 24px;
  padding: 2rem 2rem 1.5rem;
  box-shadow: 0 30px 60px -20px rgba(10, 59, 94, .5);
}
.signin-close { position: absolute; top: 1rem; left: 1rem; }
.signin-head { text-align: center; margin-bottom: 1.5rem; }
.signin-head img { border-radius: 16px; margin-bottom: .75rem; }
.modal.show .signin-head img { animation: pop-in .5s cubic-bezier(.2, .9, .3, 1.3) both; }
.signin-head h2 { font-size: 1.6rem; color: var(--brand-ink); margin-bottom: .25rem; }
.signin-head p { color: var(--muted); margin: 0; font-size: .95rem; }
.signin-form .form-control { border-radius: 12px; }
.signin-form .form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(22, 137, 211, .18); }
.password-field .form-control { padding-left: 3rem; }
.toggle-pass {
  position: absolute;
  left: .5rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: .4rem .5rem;
  z-index: 5;
}
.toggle-pass:hover { color: var(--brand-dark); }
.btn-brand.is-loading { pointer-events: none; opacity: .8; }

/* ---------- اختيار الطالب ---------- */

.choose-child { padding: 3rem 0 4rem; text-align: center; }
.choose-child h1 { color: var(--brand-ink); }
.child-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  max-width: 860px;
  margin: 2rem auto 0;
}
.child-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: 1.5rem 1rem;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: #fff;
  box-shadow: 0 10px 30px -22px rgba(10, 59, 94, .6);
  transition: transform .2s ease, border-color .2s ease;
  animation: rise-in .5s ease-out both;
  animation-delay: calc(var(--i) * 80ms);
}
.child-card:hover, .child-card:focus-visible { transform: translateY(-4px); border-color: var(--brand); outline: none; }
.child-card.is-current { border-color: var(--accent); }
.child-card .avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  margin-bottom: .4rem;
}
.child-card:nth-child(even) .avatar { background: linear-gradient(135deg, #f58a4f, var(--accent)); }
.child-name { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.child-grade { color: var(--muted); font-size: .92rem; }

/* ---------- لوحة الإدارة ---------- */

body.is-admin { background: #f5f3ee; }
.admin-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 2rem;
  padding-top: 2rem;
  padding-bottom: 4rem;
  flex: 1 0 auto;
}
.admin-nav {
  position: sticky;
  top: 88px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.admin-nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .85rem;
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.admin-nav a i { font-size: 1.1rem; color: var(--muted); }
.admin-nav a:hover { background: rgba(22, 137, 211, .08); }
.admin-nav a.active { background: var(--brand); color: #fff; font-weight: 700; box-shadow: 0 8px 20px -12px rgba(22, 137, 211, .9); }
.admin-nav a.active i { color: #fff; }
.admin-nav .nav-secondary { margin-top: .75rem; border-top: 1px solid rgba(0, 0, 0, .06); border-radius: 0 0 12px 12px; padding-top: .9rem; color: var(--muted); }
.admin-main { min-width: 0; }

@media (max-width: 991.98px) {
  .admin-shell { grid-template-columns: 1fr; gap: 1rem; padding-top: 1rem; }
  .admin-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: calc(var(--bs-gutter-x) * -.5);
    padding-inline: calc(var(--bs-gutter-x) * .5);
    padding-bottom: .25rem;
  }
  .admin-nav::-webkit-scrollbar { display: none; }
  .admin-nav a { white-space: nowrap; flex-shrink: 0; background: #fff; }
  .admin-nav .nav-secondary { margin-top: 0; border-top: 0; border-radius: 12px; padding-top: .6rem; }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-head h1 { font-size: 1.75rem; color: var(--brand-ink); margin-bottom: .25rem; }
.page-head p { color: var(--muted); margin: 0; max-width: 46rem; }

.panel {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  border: 1px solid rgba(0, 0, 0, .05);
  box-shadow: 0 10px 30px -26px rgba(10, 59, 94, .7);
  margin-bottom: 1rem;
}
.panel-title {
  font-size: 1.15rem;
  color: var(--brand-ink);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.panel-title i { color: var(--brand); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr));
  gap: 1rem;
}
@media (max-width: 575.98px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: .5rem; padding: .9rem; }
}
.stat-card {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: #fff;
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  border: 1px solid rgba(0, 0, 0, .05);
  animation: rise-in .5s ease-out both;
}
.stat-card:nth-child(2) { animation-delay: .05s; }
.stat-card:nth-child(3) { animation-delay: .1s; }
.stat-card:nth-child(4) { animation-delay: .15s; }
.stat-card:nth-child(5) { animation-delay: .2s; }
.stat-card:nth-child(6) { animation-delay: .25s; }
.stat-card > i {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  background: rgba(22, 137, 211, .1);
  color: var(--brand-dark);
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-card.is-alert > i { background: var(--accent-soft); color: #b44812; }
.stat-num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: var(--brand-ink); }
.stat-card.is-alert .stat-num { color: #b44812; }
.stat-label { color: var(--muted); font-size: .9rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.25rem; margin-bottom: 1.25rem; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; }

.list-plain { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.list-plain li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, .05);
}
.list-plain li:last-child { border-bottom: 0; }

/* الصلاحيات */
.priv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: .6rem;
}
.priv-option {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  padding: .75rem .9rem;
  border-radius: 12px;
  border: 1px solid var(--paper-edge);
  background: #fffdf9;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.priv-option .form-check-input { margin: .2rem 0 0; flex-shrink: 0; }
.priv-option span { display: flex; flex-direction: column; }
.priv-option small { color: var(--muted); font-size: .82rem; line-height: 1.4; }
.priv-option:has(input:checked) { border-color: var(--brand); background: rgba(22, 137, 211, .06); }

.librarian-list { display: flex; flex-direction: column; gap: .25rem; }
.librarian.is-disabled { opacity: .7; }
.librarian-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.librarian-head h2 { font-size: 1.15rem; margin: 0; color: var(--ink); }
.librarian-head .meta { color: var(--muted); font-size: .9rem; display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.librarian-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.avatar-sm {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  flex-shrink: 0;
}
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.chip {
  font-size: .85rem;
  padding: .25rem .7rem;
  border-radius: 999px;
  background: rgba(22, 137, 211, .08);
  color: var(--brand-dark);
}

/* الإعدادات */
.help { color: var(--muted); font-size: .92rem; margin: .75rem 0 0; }
.switch-lg { padding-inline-start: 3.25em; min-height: 1.75rem; }
.switch-lg .form-check-input { width: 2.6em; height: 1.4em; margin-inline-start: -3.25em; cursor: pointer; }
.switch-lg .form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.switch-lg .form-check-label { padding-top: .15rem; font-weight: 500; cursor: pointer; }
.form-actions { position: sticky; bottom: 1rem; display: flex; justify-content: flex-start; padding-top: .5rem; }

.limit-form { display: flex; gap: .4rem; align-items: center; }
.limit-form .form-control { width: 80px; }
.table > :not(caption) > * > * { background: transparent; }

/* ---------- عناصر مشتركة ---------- */

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.btn-icon:hover:not(:disabled) { background: rgba(22, 137, 211, .1); color: var(--brand-dark); }
.btn-icon.text-danger:hover:not(:disabled) { background: rgba(220, 53, 69, .1); }
.btn-icon:disabled { opacity: .3; }
.req { color: #c0392b; }
.back-link { display: inline-flex; gap: .3rem; align-items: center; color: var(--muted); text-decoration: none; font-size: .9rem; margin-bottom: .35rem; }
.back-link:hover { color: var(--brand-dark); }
.badge-soft-success { background: #e3f4ea; color: #1d7a45; font-weight: 500; }
.badge-soft-muted { background: #eceae4; color: #6b6458; font-weight: 500; }
.badge-outline { border: 1px dashed #bdb7aa; color: var(--muted); font-weight: 400; }
.sticky-panel { position: sticky; top: 88px; }
.panel.has-error { border-color: rgba(220, 53, 69, .5); }

/* ---------- شجرة التصنيفات ---------- */

.cat-tree { list-style: none; margin: 0; padding: 0; }
.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .55rem 1rem .55rem .75rem;
  padding-inline-start: calc(1rem + var(--depth) * 1.6rem);
  border-bottom: 1px solid rgba(0, 0, 0, .05);
  position: relative;
  scroll-margin-top: 100px;
}
.cat-row:last-child { border-bottom: 0; }
.cat-row:hover { background: #fcfbf8; }
.cat-row.is-editing { background: rgba(22, 137, 211, .06); }
.cat-row:target { animation: flash-row 1.6s ease-out; }
.cat-row[style*="--depth: 0"] { font-weight: 700; }
.cat-name { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; min-width: 0; }
.cat-name i { color: var(--brand); }
.cat-actions { display: flex; align-items: center; gap: .1rem; flex-shrink: 0; }
.cat-actions .form-select { width: auto; }
@keyframes flash-row { from { background: var(--accent-soft); } to { background: transparent; } }

/* ---------- قائمة الكتب ---------- */

.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: 1rem; }
.filter-bar .form-select { width: auto; max-width: 200px; }
.filter-search { position: relative; flex: 1 1 260px; }
.filter-search i { position: absolute; right: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filter-search .form-control { padding-right: 2.4rem; }

.book-list { display: flex; flex-direction: column; gap: .6rem; }
.book-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 1rem;
  align-items: start;
  background: #fff;
  border-radius: var(--radius);
  padding: .9rem 1rem;
  border: 1px solid rgba(0, 0, 0, .05);
}
.book-row.is-hidden { background: #faf9f6; }
.book-row.is-hidden .book-cover-sm, .book-row.is-hidden h2 a { opacity: .6; }
.book-cover-sm { width: 64px; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: var(--paper-edge); box-shadow: 0 4px 10px -6px rgba(0, 0, 0, .4); }
.book-cover-sm img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-placeholder { display: grid; place-items: center; width: 100%; height: 100%; color: #b8ad97; font-size: 1.5rem;
  background: linear-gradient(135deg, #f3ede1, #e7dfcf); }
.book-main { min-width: 0; }
.book-main h2 { font-size: 1.1rem; margin: 0 0 .15rem; font-family: var(--font-body); font-weight: 700; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.book-main h2 a { color: var(--ink); text-decoration: none; }
.book-main h2 a:hover { color: var(--brand-dark); }
.book-meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--muted); font-size: .88rem; margin-top: .25rem; }
.chips-sm { margin-top: .5rem; gap: .3rem; }
.chips-sm .chip { font-size: .78rem; padding: .15rem .55rem; }
.chip-accent { background: var(--accent-soft); color: #9a4313; }
.chip-subject { background: #eef3e6; color: #4d6a20; }
.chip-category { background: #f0ecf6; color: #5b4687; }
a.chip { text-decoration: none; }
a.chip:hover { filter: brightness(.95); }
.book-side { display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; }
.book-stock { display: flex; gap: .75rem; font-size: .9rem; color: var(--ink); white-space: nowrap; }
.reserve-form .form-select { min-width: 170px; }
.book-actions { display: flex; gap: .1rem; }
@media (max-width: 767.98px) {
  .book-row { grid-template-columns: 52px 1fr; }
  .book-cover-sm { width: 52px; }
  .book-side { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
}

/* ---------- نموذج الكتاب ---------- */

.author-rows { display: flex; flex-direction: column; gap: .4rem; }
.author-row { display: flex; gap: .3rem; align-items: center; }
.audience-flags { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem; }
.flag-option {
  display: flex; gap: .65rem; align-items: flex-start;
  padding: .75rem .9rem; border-radius: 12px; border: 1px solid var(--paper-edge); background: #fffdf9; cursor: pointer;
}
.flag-option .form-check-input { margin: .2rem 0 0; flex-shrink: 0; }
.flag-option span { display: flex; flex-direction: column; }
.flag-option small { color: var(--muted); font-size: .82rem; }
.flag-option:has(input:checked) { border-color: var(--accent); background: #fff6f0; }

.quick-select { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.check-grid { display: flex; flex-wrap: wrap; gap: .4rem; }
.check-pill { position: relative; cursor: pointer; margin: 0; }
.check-pill input { position: absolute; opacity: 0; pointer-events: none; }
.check-pill span {
  display: inline-block;
  padding: .35rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--paper-edge);
  background: #fff;
  font-size: .9rem;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  user-select: none;
}
.check-pill:hover span { border-color: rgba(22, 137, 211, .5); }
.check-pill input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.check-pill input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.cat-picker {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--paper-edge);
  border-radius: 12px;
  padding: .4rem 0;
  background: #fffdf9;
}
.cat-pick {
  display: flex; gap: .55rem; align-items: center;
  padding: .3rem .9rem;
  padding-inline-start: calc(.9rem + var(--depth) * 1.4rem);
  cursor: pointer; margin: 0;
}
.cat-pick:hover { background: rgba(22, 137, 211, .05); }
.cat-pick .form-check-input { margin: 0; flex-shrink: 0; }
.cat-pick:has(input:checked) { color: var(--brand-dark); font-weight: 700; }

.cover-drop {
  position: relative;
  aspect-ratio: 2 / 3;
  max-width: 240px;
  margin: 0 auto;
  border: 2px dashed var(--paper-edge);
  border-radius: 14px;
  background: #fffdf9;
  overflow: hidden;
  display: grid;
  place-items: center;
  transition: border-color .15s ease, background .15s ease;
}
.cover-drop.is-drag, .cover-drop:hover { border-color: var(--brand); background: rgba(22, 137, 211, .04); }
.cover-drop.has-cover { border-style: solid; }
.cover-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cover-empty { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: 1rem; text-align: center; color: var(--muted); }
.cover-empty i { font-size: 2rem; color: var(--brand); }
.cover-empty small { font-size: .78rem; }

.form-actions.gap-2 { gap: .5rem; flex-wrap: wrap; align-items: center; }
.book-form .form-actions { background: linear-gradient(transparent, #f5f3ee 35%); padding: 1rem 0 .5rem; margin-top: .5rem; z-index: 5; }

/* ---------- النسخ والإعارة والحجوزات ---------- */

a.stat-card { text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
a.stat-card:hover { transform: translateY(-2px); box-shadow: 0 12px 26px -20px rgba(10, 59, 94, .8); }
.stock-link { color: inherit; text-decoration: none; }
.stock-link:hover { color: var(--brand-dark); }
.copy-table tr.is-editing td { background: rgba(22, 137, 211, .05); }
.copy-table tr:target td { animation: flash-row 1.6s ease-out; }

.seg-tabs { display: inline-flex; flex-wrap: wrap; gap: .25rem; background: #fff; padding: .3rem; border-radius: 14px; border: 1px solid rgba(0, 0, 0, .05); }
.seg-tabs a { padding: .45rem 1rem; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; }
.seg-tabs a:hover { color: var(--brand-dark); background: rgba(22, 137, 211, .06); }
.seg-tabs a.active { background: var(--brand); color: #fff; }
.seg-count { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: .78rem; text-align: center; }

.desk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.desk-grid .panel { margin-bottom: 0; }
@media (max-width: 991.98px) { .desk-grid { grid-template-columns: 1fr; } }
.desk-grid + * { margin-top: 1rem; }
.scan-form { position: relative; display: flex; gap: .5rem; align-items: center; }
.scan-form > i { position: absolute; right: .9rem; color: var(--muted); pointer-events: none; }
.scan-form .form-control { padding-right: 2.5rem; }
.scan-form .form-control-lg { font-size: 1.1rem; }
.scan-form .btn { white-space: nowrap; display: inline-flex; align-items: center; gap: .35rem; flex-shrink: 0; }
.scan-lend > i { font-size: 1.2rem; }
.pick-list { list-style: none; margin: .75rem 0 0; padding: 0; max-height: 300px; overflow-y: auto; }
.pick-list a { display: flex; flex-direction: column; padding: .55rem .75rem; border-radius: 10px; text-decoration: none; color: var(--ink); }
.pick-list a:hover { background: rgba(22, 137, 211, .07); }

.borrower-card { border-color: rgba(22, 137, 211, .35); box-shadow: 0 14px 34px -24px rgba(22, 137, 211, .9); }
.borrower-head { display: flex; align-items: center; gap: 1rem; }
.borrower-head h2 { font-size: 1.3rem; margin: 0; color: var(--ink); }
.borrower-head .avatar-sm { width: 52px; height: 52px; font-size: 1.4rem; }
.min-w-0 { min-width: 0; }
.usage { text-align: center; min-width: 110px; }
.usage-num { font-weight: 700; font-size: 1.15rem; color: var(--brand-ink); }
.usage-bar { height: 6px; border-radius: 99px; background: #ece8df; overflow: hidden; margin: .2rem 0; }
.usage-bar span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.usage-bar span.is-full { background: var(--accent); }

.loan-list { display: flex; flex-direction: column; }
.loan-row { display: grid; grid-template-columns: 1fr auto auto; gap: 1rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid rgba(0, 0, 0, .06); }
.loan-row:last-child { border-bottom: 0; }
.loan-row.is-late { background: linear-gradient(90deg, transparent, rgba(220, 53, 69, .05)); }
.loan-due { text-align: center; min-width: 120px; }
.loan-actions { display: flex; gap: .35rem; align-items: center; }
.loan-more { min-width: 270px; }
@media (max-width: 767.98px) {
  .loan-row { grid-template-columns: 1fr auto; }
  .loan-actions { grid-column: 1 / -1; }
  .borrower-head { flex-wrap: wrap; }
}
.loans-table tr.is-late td { background: rgba(220, 53, 69, .04); }

/* استيراد الكتب */
.import-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 991.98px) { .import-steps { grid-template-columns: 1fr; } }
.import-steps .panel { position: relative; margin: 0; }
.step-num { position: absolute; top: 1.1rem; inset-inline-end: 1.2rem; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: #b44812; font-weight: 700; }
.import-summary { display: flex; flex-wrap: wrap; gap: .5rem; }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .8rem; border-radius: 999px; background: #f1efe9; font-weight: 500; font-size: .92rem; }
.pill-ok { background: #e3f4ea; color: #1d7a45; }
.pill-bad { background: #fde8e8; color: #a12a2a; }
.pill-warn { background: #fff3d6; color: #7a5300; }
.import-table tr.row-bad td { background: #fffafa; }
.import-table tr.row-skip td { background: #fffdf5; color: var(--muted); }
.import-msgs { margin: .3rem 0 0; padding-inline-start: 1rem; }
.import-table .chip { white-space: nowrap; display: inline-block; margin-bottom: .2rem; }
.import-table td:nth-child(4) { min-width: 140px; }

/* التقارير */
.report-bar { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.seg-tabs a i { margin-inline-end: .25rem; }
.seg-sm a { padding: .3rem .8rem; font-size: .9rem; }
.report-range { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.report-range .form-control { width: auto; }
.range-chip { padding: .3rem .75rem; border-radius: 999px; border: 1px solid #ddd7cb; background: #fff; color: var(--ink); text-decoration: none; font-size: .88rem; }
.range-chip:hover { border-color: var(--brand); }
.range-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.stat-sub { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.report-table-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.report-table td.num { font-variant-numeric: tabular-nums; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; font-family: var(--font-body); }
.chart .grid { stroke: #ece8df; stroke-width: 1; }
.chart .axis { stroke: #cfc8b8; stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .val { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart .bar { fill: var(--brand); transition: fill .12s; }
.chart .hit { fill: transparent; }
.chart .bar-group:hover .bar { fill: var(--brand-dark); }
.chart .bar-group:hover .hit { fill: rgba(22, 137, 211, .06); }
.chart-tip { position: fixed; z-index: 50; pointer-events: none; padding: .35rem .6rem; border-radius: 8px; background: var(--ink); color: #fff;
  font-size: .82rem; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .6); }
.hbars { display: flex; flex-direction: column; gap: .35rem; }
.hbar { display: grid; grid-template-columns: minmax(110px, 30%) 1fr; align-items: center; gap: .75rem; padding: .15rem .25rem; border-radius: 6px; }
.hbar:hover { background: rgba(22, 137, 211, .05); }
.hbar-label { font-size: .88rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { display: flex; align-items: center; gap: .4rem; }
.hbar-fill { height: 16px; background: var(--brand); border-radius: 0 4px 4px 0; min-width: 3px; }
[dir="rtl"] .hbar-fill { border-radius: 4px 0 0 4px; }
.hbar-val { font-size: .82rem; color: var(--ink); font-variant-numeric: tabular-nums; }

/* البحث عن كتاب في مكتب الإعارة */
.found-books { display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; }
.found-book { border: 1px solid rgba(0, 0, 0, .07); border-radius: 14px; padding: .9rem 1rem; }
.found-head { display: flex; gap: .9rem; align-items: flex-start; }
.found-head .book-cover-sm { width: 46px; flex-shrink: 0; }
.found-head h3 { font-family: var(--font-body); font-size: 1.05rem; font-weight: 700; margin: 0; }
.access-ok, .access-no { font-size: .88rem; margin-top: .4rem; padding: .3rem .6rem; border-radius: 8px; display: inline-block; }
.access-ok { background: #e3f4ea; color: #1d7a45; }
.access-no { background: #fff3cd; color: #7a5300; }
.copy-picks { list-style: none; margin: .75rem 0 0; padding: 0; }
.copy-picks li { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; padding: .45rem .5rem; border-top: 1px dashed rgba(0, 0, 0, .08); }
.copy-picks li.is-available { background: rgba(46, 160, 90, .04); }
.copy-picks li.is-lost, .copy-picks li.is-damaged { opacity: .6; }
.copy-id { display: flex; flex-direction: column; min-width: 90px; line-height: 1.2; }
.copy-id small { color: var(--muted); font-size: .78rem; }
.copy-who { flex: 1 1 200px; }
.copy-picks .btn-outline-warning { color: #8a5a00; border-color: #e0a800; }
.copy-picks .btn-outline-warning:hover { background: #ffc107; color: #3d2a00; }

.override-panel { border: 2px solid #f0ad4e; background: #fffaf0; }
.override-panel .panel-title, .override-panel .panel-title i { color: #8a5a00; }
.badge-override { background: #fff3cd; color: #7a5300; border: 1px solid #f0c36d; font-weight: 500; }
.override-note { margin-top: .25rem; padding: .25rem .5rem; border-radius: 6px; background: #f6f3ec; color: var(--ink); }

/* عنصر الاختيار بالبحث */
.picker { position: relative; }
.picker-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.picker-chips:not(:empty) { margin-bottom: .5rem; }
.picker-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .4rem .3rem .75rem; border-radius: 999px;
  background: rgba(22, 137, 211, .1); color: var(--brand-ink); font-weight: 500; font-size: .92rem; }
.picker-chip small { color: var(--muted); font-weight: 400; }
.picker-x { border: 0; background: rgba(0, 0, 0, .06); width: 22px; height: 22px; border-radius: 50%; line-height: 1; color: var(--muted); padding: 0; }
.picker-x:hover { background: #dc3545; color: #fff; }
.picker-box { position: relative; }
.picker-results { position: absolute; z-index: 20; inset-inline: 0; top: calc(100% + 4px); list-style: none; margin: 0; padding: .3rem;
  background: #fff; border-radius: 12px; border: 1px solid rgba(0, 0, 0, .08); box-shadow: 0 16px 36px -18px rgba(10, 59, 94, .6); max-height: 320px; overflow-y: auto; }
.picker-option { display: flex; flex-direction: column; padding: .45rem .7rem; border-radius: 8px; cursor: pointer; }
.picker-option small { color: var(--muted); }
.picker-option.is-active { background: rgba(22, 137, 211, .09); }
.picker-option.is-chosen strong::after { content: ' ✓'; color: #1d7a45; }
.picker-empty { padding: .5rem .7rem; color: var(--muted); }

.seg-radio { display: flex; flex-wrap: wrap; gap: .5rem; }
.seg-radio label { margin: 0; cursor: pointer; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1rem; border-radius: 12px; border: 1px solid #ddd7cb; background: #fff; }
.seg-radio input:checked + span { border-color: var(--brand); background: rgba(22, 137, 211, .08); color: var(--brand-dark); font-weight: 700; }
.seg-radio input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.grant-list { display: flex; flex-direction: column; gap: .6rem; }
.grant-card { display: grid; grid-template-columns: 240px 1fr auto; gap: 1rem; align-items: start; background: #fff; border-radius: 14px;
  padding: 1rem 1.1rem; border: 1px solid rgba(0, 0, 0, .06); }
.grant-card:target { animation: flash-row 1.6s ease-out; }
.grant-card.is-ended { opacity: .75; background: #faf9f6; }
@media (max-width: 767.98px) { .grant-card { grid-template-columns: 1fr; } }
.grant-who { display: flex; gap: .7rem; align-items: flex-start; }
.grant-who > i { font-size: 1.3rem; color: var(--brand); background: rgba(22, 137, 211, .1); width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.grant-who div { display: flex; flex-direction: column; }
.grant-who small { color: var(--muted); }
.grant-scope { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.grant-scope .dim { color: var(--muted); font-size: .85rem; }
.grant-scope .dim.and { font-weight: 700; color: var(--accent); margin: 0 .2rem; }
.grant-meta { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; color: var(--muted); font-size: .84rem; margin-top: .35rem; }
.grant-actions { display: flex; gap: .1rem; }

.res-book { display: flex; gap: 1rem; align-items: center; margin-bottom: .75rem; }
.res-book .book-cover-sm { width: 48px; }
.res-book h2 { font-size: 1.1rem; margin: 0 0 .2rem; font-family: var(--font-body); font-weight: 700; }
.res-queue { margin: 0; padding: 0 1.4rem 0 0; }
.res-queue li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; padding: .6rem 0; border-top: 1px solid rgba(0, 0, 0, .06); }
.res-queue li::marker { color: var(--brand); font-weight: 700; }
.res-actions { display: flex; gap: .35rem; align-items: center; }
.res-actions .form-select { min-width: 150px; }

/* ---------- التذييل ---------- */

.site-footer {
  padding: 1.5rem 0;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
  border-top: 1px solid rgba(0, 0, 0, .05);
}
.site-footer .sep { margin: 0 .5rem; }

/* ---------- الحركات ---------- */

@keyframes page-turn {
  0%, 12%   { transform: translateZ(calc(1px + var(--i) * .5px)) rotateY(0); }
  50%, 100% { transform: translateZ(calc(1px + var(--i) * .5px)) rotateY(180deg); }
}
@keyframes bob {
  0%, 100% { transform: rotateX(28deg) rotateZ(-2deg) translateY(0); }
  50%      { transform: rotateX(28deg) rotateZ(-2deg) translateY(-10px); }
}
@keyframes shadow-bob {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(.9);  opacity: .7; }
}
@keyframes float-up {
  0%   { transform: translateY(0) rotate(0);        opacity: 0; }
  10%  { opacity: .12; }
  85%  { opacity: .12; }
  100% { transform: translateY(-120vh) rotate(25deg); opacity: 0; }
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-60px, 40px) scale(1.12); }
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(.6); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .float-letter { display: none; }
}
