/* =============================================================
   PDF Blue Reader Web — stylesheet
   Brand palette: navy #0B1A40, royal blue #1E5FE0, accent #4FA3FF
   ============================================================= */

* {
  box-sizing: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* HTML hidden attribute MUST win over class display rules.
   Without this, modals with display:flex stay visible even when [hidden] is set. */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: 'Inter', 'Manrope', -apple-system, BlinkMacSystemFont,
               'Segoe UI', Roboto, sans-serif;
  background: #f4f6fb;
  color: #0B1A40;
  overflow: hidden;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

a { color: #1E5FE0; text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: #e7ecf5;
  padding: 0 .4em;
  border-radius: 4px;
  font-size: .95em;
}

/* ---------- header ---------- */
.rw-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: #0B1A40;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 10;
}
.rw-logo {
  display: flex; align-items: center; gap: 12px;
  color: #fff; font-weight: 700; font-size: 1.05rem;
  text-decoration: none;
  letter-spacing: 0.2px;
}
.rw-logo:hover { color: #fff; text-decoration: none; }
.rw-logo img,
.rw-logo .rw-logo-mark { height: 34px; width: 34px; flex-shrink: 0; }
.rw-header-info {
  font-size: .85rem; opacity: 0.85;
  display: flex; gap: 8px; align-items: center;
}
.rw-sep { color: rgba(255,255,255,0.35); }

/* ---------- generic state ---------- */
.rw-state { display: none; }
.rw-state.rw-active { display: flex; }

#state-upload, #state-login {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: calc(100vh - 56px);
  padding: 24px;
  overflow-y: auto;
}

.rw-card {
  background: #fff;
  padding: 40px;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(11,26,64,0.08);
  width: 100%;
  max-width: 600px;
  text-align: center;
}
.rw-card-narrow { max-width: 420px; }
.rw-card h1 {
  margin: 0 0 8px;
  color: #0B1A40;
  font-size: 1.6rem;
}
.rw-subtitle {
  color: #5a667c;
  margin: 0 0 24px;
}

/* ---------- dropzone ---------- */
.rw-dropzone {
  border: 2px dashed #c2cde0;
  border-radius: 12px;
  padding: 40px 20px;
  background: #fafbfd;
  transition: all 0.2s;
  cursor: pointer;
}
.rw-dropzone.dragover {
  border-color: #1E5FE0;
  background: #eef3fc;
  transform: scale(1.01);
}
.rw-dropzone svg { margin-bottom: 8px; }
.rw-dropzone-text { margin: 8px 0 4px; color: #0B1A40; }
.rw-dropzone-or { margin: 4px 0 12px; color: #8a96aa; font-size: .9rem; }

/* ---------- buttons ---------- */
.rw-btn {
  display: inline-block;
  padding: 10px 22px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.rw-btn-primary {
  background: #1E5FE0;
  color: #fff;
}
.rw-btn-primary:hover { background: #1751c4; transform: translateY(-1px); }
.rw-btn-primary:disabled { background: #b6c2dc; cursor: not-allowed; transform: none; }
.rw-btn-secondary {
  background: #f1f4fa;
  color: #0B1A40;
}
.rw-btn-secondary:hover { background: #e5ebf5; }
.rw-btn-link {
  background: none; border: none;
  color: #1E5FE0; cursor: pointer;
  font-size: .95rem; margin-top: 12px;
}
.rw-btn-link:hover { text-decoration: underline; }

/* ---------- form ---------- */
.rw-label {
  display: block;
  text-align: left;
  margin-bottom: 16px;
  font-size: .9rem;
  color: #5a667c;
  font-weight: 500;
}
.rw-label input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 14px;
  border: 1px solid #d0d8e6;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}
.rw-label input:focus {
  outline: none; border-color: #1E5FE0;
  box-shadow: 0 0 0 3px rgba(30,95,224,0.15);
}

/* ---------- progress ---------- */
.rw-progress {
  margin-top: 24px;
}
.rw-progress-bar {
  height: 6px;
  background: #e7ecf5;
  border-radius: 4px;
  overflow: hidden;
}
.rw-progress-fill {
  height: 100%;
  width: 0%;
  background: #1E5FE0;
  transition: width 0.2s;
}
.rw-progress-text {
  margin-top: 8px; font-size: .9rem; color: #5a667c;
}

/* ---------- errors ---------- */
.rw-error {
  background: #fef0ef;
  border: 1px solid #f5c2c1;
  color: #c0392b;
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 16px;
  font-size: .9rem;
  text-align: left;
  white-space: pre-line;   /* render \n in messages (incl. technical details) */
}

/* ---------- footnote ---------- */
.rw-footnote {
  margin-top: 24px;
  font-size: .85rem;
  color: #8a96aa;
}

/* ---------- viewer state ---------- */
.rw-viewer {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
}
.rw-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e3e8f1;
  flex-shrink: 0;
}
.rw-tb-btn {
  background: #f1f4fa;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 1.1rem;
  cursor: pointer;
  font-family: inherit;
  color: #0B1A40;
  transition: background 0.15s;
}
.rw-tb-btn:hover { background: #e5ebf5; }
.rw-tb-btn:disabled { color: #b6c2dc; cursor: not-allowed; }
.rw-tb-gap { width: 16px; }
.rw-tb-print { background: #fff7e0; }
.rw-tb-print:hover { background: #ffeec0; }
.rw-tb-close { background: #fee; margin-left: auto; }
.rw-tb-close:hover { background: #fdd; }
.rw-page-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .95rem; color: #5a667c;
}
.rw-page-indicator input {
  width: 58px;
  padding: 5px 8px;
  border: 1px solid #c2cde0;
  border-radius: 6px;
  font-size: .95rem;
  font-weight: 600;
  text-align: center;
  font-family: inherit;
  color: #0B1A40;
  background: #fff;
  cursor: text;
  transition: border-color .15s, box-shadow .15s;
}
.rw-page-indicator input:hover {
  border-color: #1E5FE0;
}
.rw-page-indicator input:focus {
  outline: none;
  border-color: #1E5FE0;
  box-shadow: 0 0 0 3px rgba(30,95,224,0.15);
}
/* Hide spinner arrows on Webkit/Blink — we use type=text now anyway */
.rw-page-indicator input::-webkit-outer-spin-button,
.rw-page-indicator input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.rw-zoom-indicator {
  display: inline-block;
  min-width: 50px;
  text-align: center;
  font-size: .9rem;
  color: #5a667c;
}

/* ---------- stage / page ---------- */
.rw-stage {
  flex: 1;
  overflow: auto;
  background: #d5dde9;
  padding: 24px;
  /* Block + text-align centering (NOT flex): lets the page grow wider than the
     viewport when zoomed and stay fully scrollable. Flexbox justify-center
     would shrink the page back to fit the screen, breaking zoom on mobile. */
  display: block;
  text-align: center;
  /* One-finger pan/scroll handled natively; two-finger pinch handled in JS. */
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;   /* smooth momentum scroll on iOS */
}
.rw-page-wrap {
  display: inline-block;     /* grows with explicit width; horizontally scrollable */
  vertical-align: top;
  text-align: left;
  background: #fff;
  box-shadow: 0 6px 24px rgba(11,26,64,0.12);
  position: relative;
  min-height: 200px;
  min-width: 200px;
}
.rw-page-wrap img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;  /* prevent right-click+save dialog actions */
}
.rw-page-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #5a667c; font-size: .9rem;
  background: #fafbfd;
}

/* ---------- modal ---------- */
.rw-modal {
  position: fixed; inset: 0;
  background: rgba(11,26,64,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.rw-modal-card {
  background: #fff;
  padding: 32px;
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}
.rw-modal-card h2 {
  margin: 0 0 12px;
  color: #0B1A40;
  font-size: 1.3rem;
}
.rw-modal-card p {
  color: #5a667c;
  margin: 0 0 20px;
  line-height: 1.5;
}
.rw-modal-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: flex-end;
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .rw-card { padding: 24px; }
  .rw-card h1 { font-size: 1.3rem; }
  .rw-toolbar { gap: 4px; padding: 8px; flex-wrap: wrap; }
  .rw-tb-gap { width: 8px; }
  .rw-header-info { display: none; }
  .rw-stage { padding: 12px; }
}
