/* ═══════════════════════════════════════════════════════
   KEPHIC PDF Viewer — pdf_viewer.css
   Runs inside the dashboard layout (extends base_dashboard.html).
   Toolbar is sticky within .dashboard-content; pages flow naturally.
═══════════════════════════════════════════════════════ */

/* ── Toolbar ───────────────────────────────────────────────────────────── */
.pv-toolbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 52px;
  background: linear-gradient(135deg, #0D47A1, #1565C0);
  display: flex;
  align-items: center;
  gap: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
  padding: 0 12px;
  user-select: none;
  /* Pull the toolbar edge-to-edge inside .dashboard-content */
  margin: -1.5rem -1.5rem 0;   /* cancel dashboard-content padding */
}

/* Back button */
.pv-btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s;
  flex-shrink: 0;
  text-decoration: none;
}
.pv-btn-back:hover { background: rgba(255,255,255,.22); color: #fff; }
.pv-btn-back i { font-size: 1rem; }

/* Title */
.pv-title {
  flex: 1;
  min-width: 0;
  padding: 0 16px;
}
.pv-title-text {
  font-size: .88rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .2px;
}
.pv-title-sub {
  font-size: .72rem;
  color: rgba(255,255,255,.6);
  margin-top: 1px;
}

/* Page navigation */
.pv-page-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.pv-nav-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: .95rem;
  transition: background .15s;
  flex-shrink: 0;
}
.pv-nav-btn:hover:not([disabled]) { background: rgba(255,255,255,.25); }
.pv-nav-btn[disabled] { opacity: .35; cursor: not-allowed; }

.pv-page-indicator {
  font-size: .82rem;
  color: rgba(255,255,255,.9);
  white-space: nowrap;
  min-width: 80px;
  text-align: center;
}
.pv-page-indicator input {
  width: 38px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 5px;
  color: #fff;
  font-size: .82rem;
  text-align: center;
  padding: 2px 4px;
}
.pv-page-indicator input:focus { outline: none; background: rgba(255,255,255,.22); }

/* Separator */
.pv-sep {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,.2);
  margin: 0 10px;
  flex-shrink: 0;
}

/* Zoom */
.pv-zoom {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.pv-zoom-select {
  width: 110px;
  background: rgba(255,255,255,.12) !important;
  border: 1px solid rgba(255,255,255,.25) !important;
  color: #fff !important;
  font-size: .78rem !important;
  border-radius: 6px !important;
  padding: 3px 6px !important;
}
.pv-zoom-select option { background: #1565C0; color: #fff; }

/* Action buttons */
.pv-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  color: #fff;
  padding: 6px 12px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
  text-decoration: none;
}
.pv-action-btn:hover { background: rgba(255,255,255,.22); color: #fff; }
.pv-action-btn.print-btn {
  background: rgba(249,168,37,.22);
  border-color: rgba(249,168,37,.45);
  color: #FFD54F;
}
.pv-action-btn.print-btn:hover { background: rgba(249,168,37,.35); color: #FFD54F; }
.pv-action-btn i { font-size: .9rem; }

/* ── PDF canvas area ───────────────────────────────────────────────────── */
.pdf-canvas-area {
  background: #3a3a3a;
  padding: 24px 20px 40px;
  margin: 0 -1.5rem;   /* match toolbar edge-to-edge */
  min-height: 60vh;
}

.pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Individual page */
.pdf-page-wrapper {
  position: relative;
  box-shadow: 0 6px 32px rgba(0,0,0,.55);
  border-radius: 2px;
  line-height: 0;
}
.pdf-page-wrapper canvas {
  display: block;
  border-radius: 2px;
}
.pdf-page-num {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: .7rem;
  color: rgba(255,255,255,.35);
  white-space: nowrap;
}

/* ── Loading / error states ────────────────────────────────────────────── */
.pv-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 20px;
  color: rgba(255,255,255,.5);
  font-size: .95rem;
  background: #3a3a3a;
  margin: 0 -1.5rem;
}
.pv-spinner {
  width: 42px; height: 42px;
  border: 4px solid rgba(255,255,255,.12);
  border-top-color: #90CAF9;
  border-radius: 50%;
  animation: pv-spin .7s linear infinite;
}
@keyframes pv-spin { to { transform: rotate(360deg); } }

.pv-error-icon { font-size: 2.5rem; color: #EF9A9A; }
.pv-error-msg  { color: #EF9A9A; font-size: .9rem; text-align: center; max-width: 320px; }

/* ── Print ─────────────────────────────────────────────────────────────── */
@media print {
  /* Hide everything except the PDF pages */
  .kephic-navbar,
  .sidebar,
  .sidebar-overlay,
  .pv-toolbar,
  .pv-state { display: none !important; }

  .dashboard-layout { display: block !important; }
  .dashboard-content { padding: 0 !important; overflow: visible !important; }

  .pdf-canvas-area {
    background: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .pdf-pages { gap: 0; }

  .pdf-page-wrapper {
    box-shadow: none !important;
    border-radius: 0 !important;
    page-break-after: always;
    break-after: page;
  }
  .pdf-page-wrapper:last-child {
    page-break-after: avoid;
    break-after: avoid;
  }
  .pdf-page-wrapper canvas {
    width: 100% !important;
    height: auto !important;
  }
  .pdf-page-num { display: none !important; }
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .pv-toolbar { margin: -1rem -1rem 0; }
  .pdf-canvas-area { margin: 0 -1rem; }
  .pv-title-sub { display: none; }
  .pv-action-btn span { display: none; }
  .pv-action-btn { padding: 6px 8px; }
}
