/* ═══════════════════════════════════════════════════════════════════════════════
   Himalayan Express ePaper Viewer — Frontend Styles
   ═══════════════════════════════════════════════════════════════════════════════ */
:root{
  --red:#E31E24;
  --red-dark:#C4181D;
  --blue:#2563eb;
  --amber:#f59e0b;

  --bg:#e9ebec;
  --surface:#ffffff;
  --border:#e3e3e6;
  --text:#1c1c1e;
  --text-muted:#6b6b70;
  --shadow:0 4px 24px rgba(20,20,22,.10);

  --radius:14px;
  --radius-sm:9px;

  --hdr-h:56px;
  --ftr-h:52px;
  --cpy-h:36px;
}
html[data-theme="dark"]{
  --bg:#0c0c0e;
  --surface:#1a1a1d;
  --border:#2c2c30;
  --text:#f1f1f2;
  --text-muted:#a7a7ac;
  --shadow:0 4px 24px rgba(0,0,0,.4);
}

*{box-sizing:border-box;}
html,body{margin:0; padding:0; height:100%;}
body{
  font-family:'Inter',sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  display:flex; flex-direction:column; min-height:100vh;
  transition:background-color .2s ease, color .2s ease;
  overscroll-behavior-y:none;
}
button{font-family:inherit; cursor:pointer; color:inherit; border:none; background:none;}
input{font-family:inherit;}
a{color:inherit; text-decoration:none;}
::selection{background:var(--red); color:#fff;}
@media (prefers-reduced-motion:reduce){ *{animation:none !important; transition:none !important;} }
:focus-visible{outline:2.5px solid var(--red); outline-offset:2px; border-radius:4px;}

/* ===================== LOGO ===================== */
.logo-block{display:flex; align-items:center; gap:9px; flex-shrink:0;}
.hdr-logo-img{max-height:56px; width:auto; border-radius:6px; flex-shrink:0;}
.logo-text-col{display:flex; flex-direction:column; line-height:1;}
.logo-himalayan{font-weight:800; font-size:12.5px; letter-spacing:.5px; color:var(--red);}
.logo-express-wrap{display:flex; align-items:center; background:#000; margin-top:2px; width:fit-content; border-radius:2px;}
.logo-express{font-family:'Anton',sans-serif; font-size:18px; letter-spacing:.5px; color:#fff; padding:1px 6px 1px 8px;}
.logo-nib{width:18px; display:flex; align-items:center; justify-content:center; color:#fff; font-size:10px; margin-right:4px;}

/* ===================== HEADER TOOLBAR ===================== */
.app-header{
  position:sticky; top:0; z-index:50;
  background:var(--surface); border-bottom:1px solid var(--border);
  padding:10px 16px;
  display:flex; align-items:center; gap:10px;
  transition:background-color .2s ease, border-color .2s ease, transform .2s ease;
  height:var(--hdr-h);
}
.header-spacer{flex:1;}
.toolbar-icon-btn{
  width:42px; height:42px; border-radius:11px;
  display:flex; align-items:center; justify-content:center;
  font-size:16px; color:#fff; flex-shrink:0;
  box-shadow:0 2px 6px rgba(0,0,0,.25);
}
.toolbar-icon-btn:hover{filter:brightness(1.1); transform:translateY(-1px);}
.toolbar-icon-btn:active{transform:translateY(0);}
.toolbar-icon-btn.calendar{background:var(--blue);}
.toolbar-icon-btn.download{background:var(--red);}
.toolbar-icon-btn.theme{background:var(--amber);}
.toolbar-icon-btn.maximize{background:var(--text-muted);}

/* ===================== MAIN / PDF VIEWER ===================== */
.app-main{flex:1; display:flex; flex-direction:column; align-items:center; padding:18px 14px 24px; min-height:0;}

.pdf-card{
  width:100%; max-width:860px;
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); box-shadow:var(--shadow);
  overflow:hidden; display:flex; flex-direction:column;
  flex:1;
}

.pdf-page-wrap{
  position:relative; width:100%;
  background:#4b4b4e;
  display:flex; align-items:flex-start; justify-content:center;
  overflow:auto;
  flex:1;
  min-height:300px;
}
html[data-theme="dark"] .pdf-page-wrap{background:#222225;}

#pdfCanvas{display:block; background:#fff; margin:0 auto;}
#pdfCanvas.page-fade{animation:pageFade .22s ease;}
@keyframes pageFade{from{opacity:.35;} to{opacity:1;}}

.pdf-notfound{
  position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px;
  color:#c9c9cc; background:#4b4b4e; z-index:5;
}
html[data-theme="dark"] .pdf-notfound{background:#222225;}
.pdf-notfound i{font-size:40px; opacity:.6;}
.pdf-notfound span{font-size:15px; font-weight:600; opacity:.7;}

.pdf-loading{
  position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:12px; color:#e7e7e9; background:#4b4b4e; z-index:5; pointer-events:none;
}
html[data-theme="dark"] .pdf-loading{background:#222225;}
.spinner{
  width:34px; height:34px; border-radius:50%;
  border:3px solid rgba(255,255,255,.25); border-top-color:var(--red);
  animation:spin .8s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg);}}
.pdf-loading span{font-size:13px; color:#c9c9cc;}

.page-nav-arrow{
  position:absolute; top:50%; transform:translateY(-50%);
  width:42px; height:42px; border-radius:50%;
  background:rgba(20,20,22,.45); color:#fff;
  display:flex; align-items:center; justify-content:center; font-size:16px;
  z-index:6; backdrop-filter:blur(2px);
}
.page-nav-arrow:hover{background:rgba(20,20,22,.7);}
.page-nav-arrow.left{left:10px;}
.page-nav-arrow.right{right:10px;}
.page-nav-arrow[disabled]{opacity:.25; pointer-events:none;}

.pdf-fallback-frame{width:100%; height:78vh; border:none; display:block; background:#fff;}

.page-indicator{
  text-align:center; padding:8px 0 2px; font-size:12px; color:var(--text-muted); font-weight:600; letter-spacing:.3px;
}

/* ===================== FOOTER TOOLBAR ===================== */
.app-footer{
  background:var(--surface); border-top:1px solid var(--border);
  display:flex; align-items:stretch; justify-content:space-between;
  padding:2px 2px;
  transition:background-color .2s ease, border-color .2s ease;
  height:var(--ftr-h);
}
.footer-btn{
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:2px; padding:4px 2px; border-radius:10px; color:var(--text-muted);
  min-width:0;
}
.footer-btn i{font-size:15px;}
.footer-btn span{font-size:10.5px; font-weight:600; letter-spacing:.2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%;}
.footer-btn:hover{background:var(--bg); color:var(--text);}
.footer-btn.accent span, .footer-btn.accent i{color:var(--red);}
.footer-btn[disabled]{opacity:.3; pointer-events:none;}

.copyright-bar{background:var(--surface); border-top:1px solid var(--border); color:var(--text-muted); text-align:center; font-size:11.5px; padding:9px 10px; transition:background-color .2s ease; height:var(--cpy-h);}

/* ===================== MAXIMIZED MODE ===================== */
body.cev-maximized .app-header,
body.cev-maximized .app-footer,
body.cev-maximized .copyright-bar{display:none;}
body.cev-maximized .app-main{padding:0;}
body.cev-maximized .pdf-card{max-width:100%; border:none; border-radius:0; box-shadow:none;}
body.cev-maximized .pdf-page-wrap{min-height:0; max-height:none;}
body.cev-maximized .page-indicator{display:none;}
body.cev-maximized .minimize-fab{display:flex;}

.minimize-fab{
  position:fixed; bottom:24px; right:24px; z-index:200;
  width:44px; height:44px; border-radius:50%;
  background:var(--red); color:#fff; font-size:18px;
  display:none; align-items:center; justify-content:center;
  box-shadow:0 4px 16px rgba(0,0,0,.35);
  transition:transform .15s ease;
}
.minimize-fab:hover{transform:scale(1.08);}
.minimize-fab:active{transform:scale(.96);}

/* ===================== MODALS ===================== */
.modal-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:100;
  display:flex; align-items:center; justify-content:center; padding:20px;
  opacity:0; pointer-events:none; transition:opacity .18s ease;
}
.modal-overlay.open{opacity:1; pointer-events:auto;}
.modal-card{
  width:min(340px,100%); background:var(--surface); border-radius:var(--radius);
  box-shadow:0 20px 60px rgba(0,0,0,.35); padding:16px 18px 20px;
  transform:scale(.95); transition:transform .18s ease;
}
.modal-overlay.open .modal-card{transform:scale(1);}
.modal-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:12px;}
.modal-title{font-size:14.5px; font-weight:800;}
.modal-close{width:28px; height:28px; border-radius:50%; background:var(--bg); display:flex; align-items:center; justify-content:center; font-size:12px;}
.pages-card{width:min(420px,100%);}

/* ── Calendar ──────────────────────────────────────────────────────────────── */
.cal-nav{display:flex; align-items:center; justify-content:space-between; margin-bottom:10px;}
.cal-nav-btn{width:26px; height:26px; border-radius:6px; color:var(--text-muted); display:flex; align-items:center; justify-content:center; font-size:11px;}
.cal-nav-btn:hover{background:var(--bg); color:var(--text);}
.cal-month{font-size:13.5px; font-weight:700;}
.cal-grid{display:grid; grid-template-columns:repeat(7,1fr); row-gap:6px;}
.cal-weekday{text-align:center; font-size:10px; font-weight:700; color:var(--red); padding-bottom:4px;}
.cal-day{text-align:center; font-size:13px; color:var(--text); border-radius:50%; cursor:pointer; justify-self:center; width:30px; height:30px; display:flex; align-items:center; justify-content:center;}
.cal-day:hover:not(.muted):not(.selected){background:var(--bg);}
.cal-day.muted{color:var(--border); cursor:default;}
.cal-day.selected{background:var(--red); color:#fff; font-weight:700;}
.cal-day.today{box-shadow:inset 0 0 0 2px var(--red);}

/* ── Pages grid (thumbnails) ───────────────────────────────────────────────── */
.pages-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:6px;
  max-height:50vh;
  overflow-y:auto;
  padding:2px;
}
.page-tile{
  aspect-ratio:3/4;
  border-radius:8px;
  background:var(--bg);
  border:2px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  overflow:hidden;
  font-size:14px;
  font-weight:700;
  color:var(--text-muted);
  transition:border-color .15s ease;
}
.page-tile:hover{border-color:var(--red);}
.page-tile.current{border-color:var(--red); box-shadow:0 0 0 1.5px var(--red);}
.thumb-canvas{display:block; width:100%; height:100%; object-fit:contain;}
.tile-num,
.thumb-badge{
  position:absolute; top:4px; right:4px; z-index:2;
  background:var(--red); color:#fff; font-size:11px; font-weight:700;
  width:22px; height:22px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 1px 4px rgba(0,0,0,.3);
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast{
  position:fixed; left:50%; bottom:96px; transform:translateX(-50%) translateY(8px);
  background:#1a1a1d; color:#fff; font-size:13px; font-weight:600;
  padding:10px 18px; border-radius:30px; box-shadow:0 8px 24px rgba(0,0,0,.35);
  z-index:200; opacity:0; pointer-events:none; transition:opacity .2s ease, transform .2s ease;
}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

/* ===================== RESPONSIVE ===================== */
@media (min-width:640px){
  .app-header{padding:12px 24px;}
  .app-main{padding:26px 24px 32px;}
  .footer-btn span{font-size:11.5px;}
  .footer-btn i{font-size:16px;}
  .app-footer{padding:8px 10px;}
}
@media (min-width:1024px){
  :root{
    --hdr-h:48px;
    --ftr-h:44px;
    --cpy-h:32px;
  }
  .app-header{padding:6px 20px; gap:8px;}
  .app-main{padding:16px 24px;}
  .toolbar-icon-btn{width:36px; height:36px; font-size:14px; border-radius:9px;}
  .hdr-logo-img{max-height:40px;}
  .logo-express{font-size:16px;}
  .logo-himalayan{font-size:11px;}
  .pdf-card{max-width:920px;}
  .app-footer{padding:2px 4px;}
  .footer-btn{flex:0 0 auto; min-width:80px; padding:2px 4px; gap:1px;}
  .footer-btn i{font-size:14px;}
  .footer-btn span{font-size:10px;}
  .page-nav-arrow{width:38px; height:38px;}
  .pages-card{width:min(520px,100%);}
  .pages-grid{grid-template-columns:repeat(5,1fr); gap:8px; max-height:55vh;}
}
@media (max-width:640px){
  .app-header{padding:8px 12px;}
  .toolbar-icon-btn{width:38px; height:38px; font-size:14px;}
  .logo-express{font-size:15px;}
  .logo-himalayan{font-size:11px;}
  .hdr-logo-img{max-height:40px;}
  .app-main{padding:12px 10px 18px;}
  .page-nav-arrow{width:36px; height:36px; font-size:14px;}
  .page-nav-arrow.left{left:6px;}
  .page-nav-arrow.right{right:6px;}
  .footer-btn i{font-size:14px;}
  .footer-btn span{font-size:9.5px;}
  .app-footer{padding:6px 2px;}
  .pages-grid{grid-template-columns:repeat(3,1fr); gap:5px;}
}
@media (pointer:coarse){
  .page-nav-arrow{opacity:.7;}
  .page-nav-arrow:active{opacity:1;}
  .footer-btn:active{transform:scale(.97);}
  .page-tile:active{transform:scale(.97);}
}