/* Modern PDF Slide Viewer Styles */
:root {
  --bg-color: #0f1117;
  --surface-bg: rgba(26, 29, 39, 0.85);
  --border-color: rgba(255, 255, 255, 0.12);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --btn-hover-bg: rgba(255, 255, 255, 0.1);
  --btn-active-bg: rgba(255, 255, 255, 0.18);
  --shadow-elevation: 0 10px 30px -5px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
  user-select: none;
}

/* Viewer Main Container */
.viewer-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  outline: none;
  cursor: default;
}

.viewer-container.is-pannable {
  cursor: grab;
}

.viewer-container.is-panning,
.viewer-container.is-panning * {
  cursor: grabbing !important;
  user-select: none;
}

/* Slide Stage & Transition System */
.slide-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slide-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  will-change: transform, opacity;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}

.slide-card.active {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
  transform: translate3d(0, 0, 0);
  z-index: 2;
}

.slide-card.animating {
  visibility: visible;
}

.slide-card canvas {
  display: block;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: #ffffff;
  max-width: none;
  user-select: none;
  will-change: transform;
}

/* Floating Top Header Controls Bar */
.controls-bar {
  position: relative;
  top: 25px;
  left: 50%;
  width: 550px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  box-shadow: var(--shadow-elevation);
  z-index: 100;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Auto-hide controls state */
.controls-bar.idle-hidden {
  opacity: 0.15;
}

.controls-bar:hover,
.controls-bar:focus-within {
  opacity: 1 !important;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.divider {
  width: 1px;
  height: 22px;
  background: var(--border-color);
  margin: 0 4px;
}

/* Buttons */
.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  background: transparent;
  color: var(--text-main);
  border: none;
  border-radius: 9999px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, color 0.15s ease;
  outline: none;
}

.ctrl-btn.icon-only {
  width: 36px;
  padding: 0;
}

.ctrl-btn:hover:not(:disabled) {
  background: var(--btn-hover-bg);
  color: #ffffff;
}

.ctrl-btn:active:not(:disabled) {
  background: var(--btn-active-bg);
  transform: scale(0.96);
}

.ctrl-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Page Indicator */
.page-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  min-width: 72px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

.page-sep {
  color: var(--text-muted);
  margin: 0 4px;
}

.zoom-value-btn {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  min-width: 58px;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 50;
  transition: opacity 0.3s ease;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3.5px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading-text {
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

/* Error Card Screen */
.error-screen {
  position: absolute;
  inset: 0;
  background: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}

.error-card {
  max-width: 440px;
  width: 100%;
  padding: 32px;
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  text-align: center;
  box-shadow: var(--shadow-elevation);
}

.error-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.error-card h2 {
  font-size: 20px;
  margin-bottom: 10px;
  font-weight: 600;
}

.error-card p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.error-card code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  color: #60a5fa;
  font-family: monospace;
}

.file-upload-btn {
  display: inline-block;
  background: var(--accent-color);
  color: #ffffff;
  padding: 10px 22px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.file-upload-btn:hover {
  background: var(--accent-hover);
}

.file-upload-btn input {
  display: none;
}

.hidden {
  display: none !important;
}

/* Responsive Mobile Tweaks */
@media (max-width: 640px) {
  .controls-bar {
    top: 14px;
    padding: 6px 10px;
    gap: 4px;
  }
  .btn-label {
    display: none;
  }
  .ctrl-btn {
    padding: 0 8px;
  }
  .slide-card {
    padding: 12px;
  }
}
