/* ACASEN Library -- online reader (application/views/library/reader.php) */
:root {
  --rd-bg: #e9e7e2; --rd-bar: #ffffff; --rd-ink: #1c1b29; --rd-muted: #6c6b7d; --rd-line: #e3e0d8;
  --rd-brand: #3c30c8; --rd-soft: #ecebfc; --rd-page-shadow: 0 1px 3px rgba(0,0,0,.12), 0 8px 24px -12px rgba(0,0,0,.3);
  color-scheme: light;
}
body.rd[data-theme="dark"] { --rd-bg: #0f0e15; --rd-bar: #1b1a25; --rd-ink: #ecebf3; --rd-muted: #a09fb2; --rd-line: #2f2e3d; --rd-brand: #8d84ff; --rd-soft: rgba(141,132,255,.16); color-scheme: dark; }
body.rd[data-theme="sepia"] { --rd-bg: #e7dcc4; --rd-bar: #f6efdf; --rd-ink: #3b2f1e; --rd-muted: #7a6a50; --rd-line: #dccfb2; --rd-soft: #ece1c8; }
*, *::before, *::after { box-sizing: border-box; }
html, body.rd { height: 100%; margin: 0; }
body.rd { background: var(--rd-bg); color: var(--rd-ink); font: 14.5px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; overflow: hidden; }
[dir="rtl"] body.rd { font-family: "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif; }
.lib-ic { flex: none; }
[dir="rtl"] .rd-flip { display: inline-flex; transform: scaleX(-1); }
.rd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--rd-brand); outline-offset: 1px; border-radius: 6px; }

.rd-bar { flex: none; height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 10px; padding-top: env(safe-area-inset-top); background: var(--rd-bar); border-bottom: 1px solid var(--rd-line); z-index: 5; }
.rd-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.rd-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.rd-tag { flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; background: #fbf0dc; color: #8a5300; padding: 2px 8px; border-radius: 999px; }
.rd-pos { flex: none; display: flex; align-items: center; gap: 6px; color: var(--rd-muted); font-variant-numeric: tabular-nums; }
.rd-pos input { width: 52px; height: 32px; text-align: center; border: 1px solid var(--rd-line); border-radius: 8px; background: transparent; color: var(--rd-ink); font: inherit; font-weight: 600; }
.rd-tools { flex: none; display: flex; align-items: center; gap: 2px; }
.rd-btn { height: 38px; min-width: 38px; padding: 0 8px; border-radius: 9px; border: 0; background: transparent; color: var(--rd-ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none; }
.rd-btn:hover { background: var(--rd-soft); }
.rd-btn.on { background: var(--rd-soft); color: var(--rd-brand); }
.rd-btn-solid { background: var(--rd-brand); color: #fff; }
.rd-btn-solid:hover { background: var(--rd-brand); opacity: .9; }
.rd-zoom { min-width: 58px; font-size: 13px; font-variant-numeric: tabular-nums; }
.rd-sep { width: 1px; height: 22px; background: var(--rd-line); margin: 0 4px; }
.rd-progress { flex: none; height: 3px; background: var(--rd-line); }
.rd-progress span { display: block; height: 100%; width: 0; background: var(--rd-brand); transition: width .25s; }
.rd-note { flex: none; text-align: center; padding: 7px 12px; background: #fbf0dc; color: #6e4300; font-size: 13.5px; font-weight: 600; }
.rd-note a { color: inherit; }

.rd-stage { position: relative; flex: 1; min-height: 0; display: flex; }
.rd-pages { flex: 1; overflow: auto; padding: 18px 12px 40px; outline: 0; -webkit-overflow-scrolling: touch; }
.rd-page { position: relative; margin: 0 auto 14px; background: #fff; box-shadow: var(--rd-page-shadow); }
.rd-page canvas { display: block; width: 100%; height: 100%; }
.rd-page .num { position: absolute; bottom: -1px; inset-inline-end: 6px; transform: translateY(100%); font-size: 11px; color: var(--rd-muted); padding-top: 1px; }
body.rd[data-theme="dark"] .rd-page canvas { filter: invert(.9) hue-rotate(180deg); }

.rd-epub { flex: 1; min-width: 0; margin: 12px 0; }

/* Word + spreadsheets: one scrolling HTML document */
.rd-doc { flex: 1; min-width: 0; overflow: auto; outline: 0; -webkit-overflow-scrolling: touch; }
body.rd[data-family="word"] .rd-doc-inner { padding: 18px 12px 40px; }
body.rd[data-family="word"] .docx-wrapper { background: transparent !important; padding: 0 !important; }
body.rd[data-family="word"] .docx-wrapper > section.docx { margin: 0 auto 14px !important; box-shadow: var(--rd-page-shadow) !important; }
body.rd[data-family="word"][data-theme="dark"] .docx-wrapper > section.docx { filter: invert(.9) hue-rotate(180deg); }

.rd-grid { border-collapse: collapse; background: #fff; color: #1c1b29; font-size: 13px; margin: 0; }
.rd-grid th, .rd-grid td { border: 1px solid #dcdad3; padding: 3px 8px; white-space: nowrap; vertical-align: top; }
.rd-grid td.num { text-align: end; font-variant-numeric: tabular-nums; }
.rd-grid td.hit { outline: 2px solid var(--rd-brand); outline-offset: -2px; background: #fef3c7; }
.rd-grid .hid { display: none; }
.rd-grid thead th { position: sticky; top: 0; z-index: 2; background: #f1efe9; color: #6c6b7d; font-weight: 600; font-size: 12px; text-align: center; }
.rd-grid tbody th { position: sticky; inset-inline-start: 0; z-index: 1; background: #f1efe9; color: #6c6b7d; font-weight: 600; font-size: 12px; text-align: center; min-width: 42px; }
.rd-grid thead th.corner { inset-inline-start: 0; z-index: 3; }
.rd-grid a { color: #3c30c8; }
body.rd[data-theme="dark"] .rd-grid { background: #1b1a25; color: #e6e5ee; }
body.rd[data-theme="dark"] .rd-grid th, body.rd[data-theme="dark"] .rd-grid td { border-color: #34333f; }
body.rd[data-theme="dark"] .rd-grid thead th, body.rd[data-theme="dark"] .rd-grid tbody th { background: #24232f; color: #a09fb2; }
body.rd[data-theme="dark"] .rd-grid td.hit { background: rgba(141,132,255,.25); }
body.rd[data-theme="dark"] .rd-grid a { color: #b3adff; }
.rd-trunc { position: sticky; inset-inline-start: 0; padding: 8px 12px; background: #fbf0dc; color: #6e4300; font-size: 13px; font-weight: 600; }
.rd-tabs { flex: none; display: flex; gap: 2px; overflow-x: auto; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); background: var(--rd-bar); border-top: 1px solid var(--rd-line); }
.rd-tabs.single { display: none; }
.rd-tab { flex: none; border: 0; background: transparent; color: var(--rd-muted); padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.rd-tab:hover { background: var(--rd-soft); color: var(--rd-ink); }
.rd-tab.on { background: var(--rd-soft); color: var(--rd-brand); }

/* Slides */
.rd-slides { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; outline: 0; padding: 8px; }
.rd-slides > div { box-shadow: var(--rd-page-shadow); background: #fff; }
.rd-slides .pptx-preview-wrapper-next, .rd-slides .pptx-preview-wrapper-pre, .rd-slides .pptx-preview-wrapper-pagination { display: none !important; }
body.rd[data-family="slides"][data-theme="dark"] { --rd-bg: #000; }
.rd-turn { flex: none; width: 56px; border: 0; background: transparent; color: var(--rd-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.rd-turn:hover { color: var(--rd-brand); background: rgba(0,0,0,.03); }

.rd-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--rd-bg); text-align: center; padding: 24px; z-index: 3; }
.rd-state.hidden { display: none; }
.rd-state p { margin: 0; color: var(--rd-muted); max-width: 420px; }
.rd-state b { display: block; color: var(--rd-ink); font-size: 17px; margin-bottom: 6px; }
.rd-state a { color: var(--rd-brand); font-weight: 600; }
.rd-spin { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--rd-line); border-top-color: var(--rd-brand); animation: rdspin .8s linear infinite; }
.rd-state.error .rd-spin { display: none; }
@keyframes rdspin { to { transform: rotate(360deg); } }

.rd-panel { position: fixed; top: 56px; bottom: 0; inset-inline-start: 0; width: min(360px, 92vw); background: var(--rd-bar); border-inline-end: 1px solid var(--rd-line); box-shadow: 0 20px 50px -20px rgba(0,0,0,.4); transform: translateX(-102%); transition: transform .2s; z-index: 6; display: flex; flex-direction: column; }
[dir="rtl"] .rd-panel { transform: translateX(102%); }
.rd-panel.open { transform: none !important; }
.rd-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--rd-line); }
.rd-search { display: flex; gap: 6px; padding: 12px; border-bottom: 1px solid var(--rd-line); }
.rd-search input { flex: 1; height: 38px; border-radius: 9px; border: 1px solid var(--rd-line); background: transparent; color: var(--rd-ink); padding: 0 12px; font: inherit; min-width: 0; }
.rd-panel-body { flex: 1; overflow: auto; padding: 8px; }
.rd-panel-body .msg { color: var(--rd-muted); padding: 12px; }
.rd-item { display: block; width: 100%; text-align: start; border: 0; background: transparent; color: var(--rd-ink); padding: 10px 12px; border-radius: 8px; cursor: pointer; font: inherit; }
.rd-item:hover { background: var(--rd-soft); }
.rd-item small { display: block; color: var(--rd-muted); font-size: 12.5px; margin-top: 2px; }
.rd-item mark { background: #fde68a; color: inherit; border-radius: 2px; }
.rd-item.l2 { padding-inline-start: 26px; }
.rd-item.l3 { padding-inline-start: 40px; }

.rd-bm { display: flex; align-items: center; gap: 4px; }
.rd-bm .rd-item { flex: 1; }
.rd-toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--rd-ink); color: var(--rd-bar); padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 9; }
.rd-toast.show { opacity: 1; }

@media (max-width: 720px) {
  .rd-hide-sm { display: none !important; }
  .rd-bar { gap: 4px; padding: 0 4px; }
  .rd-title b { font-size: 14px; }
  .rd-turn { width: 34px; }
  .rd-pages { padding: 10px 6px 30px; }
}
@media (max-width: 420px) {
  .rd-title { display: none; }
  .rd-pos { margin-inline-end: auto; }
}
@media print { body.rd { display: none; } }
@media (prefers-reduced-motion: reduce) { .rd-panel, .rd-progress span { transition: none; } .rd-spin { animation-duration: 3s; } }
