/* ── GLOBAL ALIGNMENT ── */
.tool-header {
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 900px;
  margin: 0 auto 40px auto;
}

.tool-layout {
  display: flex;
  justify-content: center;
  margin: 0 auto !important;
  max-width: 900px;
  width: 100%;
}

.p2w-panel {
  width: 100%;
  padding: 40px;
  min-height: 500px;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.workbench-container {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  width: 100%;
}

.p2w-dropzone, .loading-view, .rotate-editor, .success-panel {
  grid-area: 1 / 1 / 2 / 2;
  transition: opacity 0.3s ease;
  width: 100%;
}

@media (max-width: 768px) {
  .p2w-panel {
    padding: 25px;
  }
}

/* ── DROPZONE ── */
.p2w-dropzone {
  width: 100% !important;
  box-sizing: border-box;
  border: 2px dashed var(--glass-border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
  padding: 60px 20px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.p2w-dropzone:hover,
.p2w-dropzone.drag-over {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--red);
  transform: translateY(-2px);
}

.drop-icon {
  font-size: 64px;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 20px rgba(249, 115, 22, 0.2));
  transition: transform 0.3s ease;
}

.p2w-dropzone h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.p2w-dropzone p {
  color: var(--text-3);
  margin-bottom: 30px;
}

.privacy-badge {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-3);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: inline-block;
}

/* ── ELITE LOADER ── */
.loading-view {
  padding: 80px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.loader-percentage {
  font-family: 'Outfit', sans-serif;
  font-size: 48px;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 10px;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.loading-view h3 {
  font-size: 18px;
  color: var(--text);
  margin-bottom: 25px;
  font-weight: 600;
}

.elite-progress-container {
  width: 100%;
  max-width: 400px;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
  margin: 0 auto;
}

.elite-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), #f97316);
  box-shadow: 0 0 15px rgba(249, 115, 22, 0.4);
  width: 0%;
  transition: width 0.3s ease;
}

.loader-hint {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-3);
  font-style: italic;
}

/* ── GLASS BUTTONS ── */
.rb-btn {
  background: rgba(255, 255, 255, 0.03) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: var(--text) !important;
  padding: 14px 36px !important;
  border-radius: 12px !important;
  font-weight: 600 !important;
  letter-spacing: 0.5px !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.rb-btn:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
}

.rb-btn-primary {
  background: rgba(239, 68, 68, 0.1) !important;
  border-color: rgba(239, 68, 68, 0.2) !important;
  color: var(--red) !important;
}

.rb-btn-primary:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  color: var(--red) !important;
}

/* ── EDITOR HEADER & FOOTER CONTROLS ── */
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--glass-border);
  flex-wrap: wrap;
  gap: 15px;
}

.file-info {
  display: flex;
  flex-direction: column;
}

.file-name {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}

.file-meta {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.header-actions .rb-btn {
  padding: 8px 16px !important;
  font-size: 13px !important;
  border-radius: 8px !important;
}

.editor-footer-controls {
  margin-top: 30px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 800px) {
  .editor-footer-controls {
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
  }
  .editor-footer-controls > div {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
  }
  .editor-footer-controls .rb-btn {
    width: 100%;
  }
}

/* ── PAGE GRID & THUMBNAILS (ROTATE SPECIFIC) ── */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 25px;
  max-height: 500px;
  overflow-y: auto;
  padding: 10px;
  margin-bottom: 30px;
  /* Scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}

.page-grid::-webkit-scrollbar {
  width: 6px;
}

.page-grid::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 10px;
}

.page-thumb-wrapper {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.page-thumb-wrapper:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.page-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  margin-bottom: 12px;
}

.canvas-container {
  width: 100%;
  aspect-ratio: 1 / 1.414;
  background: #1e1e2e;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  position: relative;
}

.page-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  /* Smooth visual rotation */
}

/* Hover Controls Overlay */
.thumb-controls {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: 8px;
}

.page-thumb-wrapper:hover .thumb-controls {
  opacity: 1;
}

.rotate-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
}

.rotate-btn:hover {
  background: var(--red);
  border-color: var(--red);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* ── SUCCESS PANEL ── */
.success-panel {
  text-align: center;
  padding: 40px 0;
}

.success-icon {
  font-size: 64px;
  margin-bottom: 24px;
  filter: drop-shadow(0 0 30px rgba(249, 115, 22, 0.3));
}

.success-panel h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 32px;
  margin-bottom: 12px;
  letter-spacing: -1px;
}

.success-panel p {
  color: var(--text-2);
  margin-bottom: 30px;
}

.action-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 600px) {
  .page-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  .editor-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .action-buttons {
    flex-direction: column;
    gap: 15px;
  }

  .header-actions {
    width: 100%;
    display: flex;
    gap: 10px;
  }

  .header-actions .rb-btn {
    flex: 1;
  }

  .editor-footer-controls {
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
  }

  .editor-footer-controls > div {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
  }

  .editor-footer-controls .rb-btn {
    width: 100%;
  }
}