/* ===============================
   GLOBAL RESET
   =============================== */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: #e0e0e0;
  font-family: Arial, sans-serif;
}

/* ===============================
   EPAPER ROOT
   =============================== */
.epaper-viewer {
  display: flex;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background: #e0e0e0;
}

/* ===============================
   SIDEBAR (DESKTOP ONLY)
   =============================== */
.epaper-sidebar {
  width: 220px;
  background: #ffffff;
  border-right: 1px solid #ccc;
  padding: 6px;
  overflow-y: auto;
  height: auto; /* IMPORTANT */
}

.thumb {
  margin-bottom: 8px;
  cursor: pointer;
}

.thumb canvas {
  width: 100%;
  border: 1px solid #ccc;
}

.thumb.active canvas {
  border: 2px solid #007cba;
}

/* ===============================
   MAIN AREA
   =============================== */
.epaper-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ===============================
   TOP CONTROLS BAR
   =============================== */
.epaper-controls {
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  padding: 8px 10px;
}

/* Side-by-side layout */
.epaper-controls-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Badge */
.epaper-badge {
  background: #2563eb;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

/* Navigation */
.epaper-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.epaper-nav button {
  padding: 4px 10px;
  font-size: 16px;
  cursor: pointer;
}

/* ===============================
   CANVAS SCROLL AREA
   =============================== */
.canvas-wrap {
  width: 100%;
  padding: 8px;
  background: #999;
}

/* ✅ THIS IS THE MOST IMPORTANT PART */
.canvas-wrap canvas {
  width: 100% !important;
  height: auto !important;
  display: block;
  margin: 0 auto;
}

/* ===============================
   MOBILE FIXES (CRITICAL)
   =============================== */
@media (max-width: 768px) {

  /* Remove sidebar */
  .epaper-sidebar {
    display: none;
  }

  /* Full width */
  .epaper-viewer {
    max-width: 100%;
    padding: 0;
  }

  /* Stack controls */
  .epaper-controls-flex {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .epaper-badge {
    font-size: 13px;
  }

  /* Let PAGE scroll, not container */
  .canvas-wrap {
    padding: 6px;
  }
}