/* ==========================================================================
   PDF TO IMAGE CONVERTER — Stylesheet
   Matrix Runway — PDF Tools Category
   ========================================================================== */

/* ── Container Layout ── */
.pdf-to-image-wrapper {
  width: 100%;
  min-height: calc(100vh - 140px);
  padding-top: 0;
  padding-bottom: 60px;
  background: var(--bg-primary);
}

.tool-main-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 8px 0;
  letter-spacing: -0.02em;
}

.tool-main-subtitle {
  font-size: 0.98rem;
  color: var(--text-secondary);
  max-width: 760px;
  margin: 0 !important;
  line-height: 1.5;
}

/* ── Dual Panel Layout (Grid) ── */
.converter-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  align-items: start;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

/* ── Left Workspace Panel ── */
.left-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 100px);
  max-height: 720px;
  min-height: 480px;
  box-sizing: border-box;
}

.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.toolbar-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.title-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.count-badge {
  font-size: 0.76rem;
  font-weight: 800;
  background: var(--purple-600);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 9999px;
}

.btn-settings-icon-only {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--purple-600);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-settings-icon-only:hover {
  background: var(--purple-600);
  color: #ffffff;
  border-color: var(--purple-600);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-tool-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-tool-icon:hover {
  background: rgba(139, 92, 246, 0.12);
  color: var(--purple-600);
  border-color: var(--purple-500);
}

.btn-add-primary {
  background: var(--purple-600) !important;
  color: #ffffff !important;
  border-color: var(--purple-600) !important;
}

.btn-add-primary:hover {
  background: var(--purple-700) !important;
  border-color: var(--purple-700) !important;
}

.btn-add-primary .icon {
  background-color: #ffffff !important;
}

/* ── Dropzone Box ── */
.dropzone-box {
  border: 2px dashed var(--purple-400);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 12px;
  padding: 50px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.dropzone-box:hover,
.dropzone-box.drag-over {
  border-color: var(--purple-600);
  background: rgba(139, 92, 246, 0.08);
  color: var(--purple-600);
}

.dropzone-main-icon {
  width: 44px;
  height: 44px;
  background-color: var(--purple-600);
  margin-bottom: 12px;
}

.dropzone-headline {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.dropzone-subtext {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.dropzone-desktop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dropzone-mobile-content {
  display: none;
  width: 100%;
}

.btn-select-pdfs-big {
  width: 100%;
  max-width: 340px;
  padding: 16px 24px;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  border-radius: 10px;
  border: none;
  background: var(--purple-600);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}

.btn-select-pdfs-big .icon {
  background-color: #ffffff;
}

/* ── PDF Cards Grid (Uploaded Files) ── */
.pdf-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  overflow-y: auto;
  padding: 8px 6px 14px 6px;
  flex: 1;
  min-height: 0;
  align-content: start;
}

.pdf-card {
  position: relative;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
  width: 100%;
}

.pdf-card:hover {
  border-color: var(--purple-500);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.16);
}

/* Card Top Bar with Index and Actions (Rotate + Delete) */
.pdf-card-top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.pdf-card-index {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--purple-600);
  background: rgba(139, 92, 246, 0.12);
  padding: 1px 7px;
  border-radius: 4px;
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
}

.pdf-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pdf-card-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.pdf-card-btn:hover {
  background: var(--purple-600);
  color: #ffffff;
  border-color: var(--purple-600);
}

.pdf-card-btn:hover .icon {
  background-color: #ffffff;
}

.pdf-card-btn-danger:hover {
  background: #ef4444 !important;
  color: #ffffff !important;
  border-color: #ef4444 !important;
}

.pdf-card-btn-danger:hover .icon {
  background-color: #ffffff !important;
}

.pdf-card-btn .icon {
  background-color: currentColor;
  width: 13px;
  height: 13px;
}

/* Document Thumbnail Box */
.pdf-card-preview {
  width: 100%;
  height: 135px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  box-sizing: border-box;
  position: relative;
}

.pdf-card-thumb-sheet {
  max-width: 100%;
  max-height: 100%;
  height: 100%;
  width: auto;
  object-fit: contain;
  border-radius: 3px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.08);
  display: block;
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.pdf-card-loading,
.pdf-card-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.76rem;
}

/* Card Info Footer */
.pdf-card-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  width: 100%;
}

.pdf-card-title {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  line-height: 1.3;
}

.pdf-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.pdf-card-pages-badge {
  font-weight: 700;
  color: var(--purple-600);
  background: rgba(139, 92, 246, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.pdf-card-size {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Right Options Panel ── */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 90px;
  height: calc(100vh - 100px);
  max-height: 720px;
  overflow-y: auto;
  box-sizing: border-box;
}

.options-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-bottom: 4px;
  border: none !important;
  border-bottom: none !important;
  background: transparent !important;
}

.options-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 2px 0;
  padding: 0;
  border: none !important;
  background: transparent !important;
}

.btn-close-options {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
}

.option-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--purple-600);
  margin: 0 0 4px 0;
  display: block;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-theme="dark"] .section-label {
  color: #a78bfa;
}

/* Segmented Buttons (Quality) */
.segmented-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.segmented-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.segment-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.segment-tile:hover {
  border-color: var(--purple-400);
  background: var(--bg-tertiary);
}

.segment-tile.active {
  border-color: var(--purple-600);
  background: rgba(139, 92, 246, 0.08);
  color: var(--purple-600);
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--purple-600);
}

.segment-title {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
}

/* Custom Select Dropdown */
.custom-select-control {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 11px 34px 11px 12px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b5cf6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}

.custom-select-control:focus {
  border-color: var(--purple-600);
}

.custom-select-control option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ── Summary Card in Options Panel ── */
.options-summary-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.82rem;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
}

.summary-row strong {
  color: var(--text-primary);
}

/* ── Convert Button Row ── */
.convert-btn-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
  margin-bottom: 24px;
  width: 100%;
}

.btn-convert-primary {
  width: 100%;
  max-width: 320px;
  padding: 14px 28px;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, var(--purple-600) 0%, #d946ef 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.35);
  text-decoration: none;
  box-sizing: border-box;
}

.btn-convert-primary .icon {
  background-color: #ffffff;
}

.btn-convert-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}

.btn-convert-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  pointer-events: none !important;
}

/* ── Conversion Progress & Success View Cards ── */
.conversion-view-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 580px;
  margin: 20px auto 0 auto;
  box-sizing: border-box;
}

.large-spinner {
  width: 52px;
  height: 52px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--purple-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.progress-view-headline,
.success-view-headline {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.progress-view-status,
.success-view-subtext {
  font-size: 0.94rem;
  color: var(--text-secondary);
  margin: 0 0 20px 0;
  max-width: 480px;
}

.progress-bar-track {
  width: 100%;
  max-width: 400px;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
  margin-bottom: 12px;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--purple-600) 0%, #d946ef 100%);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.progress-pct-text {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--purple-600);
}

.success-icon-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.06);
}

.success-icon-badge .icon {
  background-color: #22c55e;
}

/* Single image preview inside success card */
.success-single-preview {
  max-width: 280px;
  max-height: 220px;
  margin-bottom: 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  object-fit: contain;
  background: var(--bg-tertiary);
}

.btn-success-download {
  width: 100% !important;
  max-width: 340px !important;
  margin: 0 auto 16px auto !important;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.success-actions-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 440px;
  margin: 8px auto 0 auto;
}

.btn-sub-action {
  flex: 1 1 0%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap !important;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.btn-sub-action:hover {
  background: var(--bg-tertiary);
  border-color: var(--purple-400);
}

.btn-sub-action-primary {
  background: var(--purple-600);
  color: #ffffff;
  border-color: var(--purple-600);
}

.btn-sub-action-primary:hover {
  background: var(--purple-700);
  border-color: var(--purple-700);
}

.btn-sub-action-primary .icon {
  background-color: #ffffff;
}

/* ── Mobile Options Drawer & Backdrop ── */
.options-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  z-index: 998;
  pointer-events: none;
}

.options-backdrop.active {
  display: block;
  pointer-events: auto;
}

/* ── Utility Classes ── */
.hidden-element {
  display: none !important;
}

/* ── Responsive Refinements (Tablet & Mobile <= 960px) ── */
@media (max-width: 960px) {
  .converter-grid {
    grid-template-columns: 1fr;
  }

  .left-panel {
    height: calc(100vh - 80px) !important;
    max-height: 840px !important;
    min-height: 560px !important;
  }

  .dropzone-box {
    border: none !important;
    background: transparent !important;
    padding: 16px 0 !important;
    margin-bottom: 8px !important;
  }

  .dropzone-desktop-content {
    display: none !important;
  }

  .dropzone-mobile-content {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Fixed Floating Settings Button on Tablet & Mobile */
  .btn-settings-icon-only {
    position: fixed !important;
    top: 80px !important;
    right: 14px !important;
    z-index: 99999 !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 12px !important;
    background: var(--bg-card) !important;
    border: 1.5px solid var(--purple-500) !important;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--purple-600) !important;
    transition: all var(--transition-fast) !important;
  }

  .btn-settings-icon-only:hover {
    background: var(--purple-600) !important;
    color: #ffffff !important;
    border-color: var(--purple-600) !important;
  }

  .btn-settings-icon-only:hover .icon {
    background-color: #ffffff !important;
  }

  .btn-settings-icon-only.has-no-files {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  .right-panel {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 320px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    z-index: 999999 !important;
    border-radius: 0 !important;
    border-left: 1px solid var(--border) !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.25) !important;
    transform: translate3d(100%, 0, 0) !important;
    will-change: transform !important;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
    background: var(--bg-card) !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
  }

  .right-panel.mobile-open {
    transform: translate3d(0, 0, 0) !important;
  }

  .btn-close-options {
    display: block !important;
  }

  .pdf-grid-container {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    gap: 12px !important;
    padding: 8px 4px 14px 4px !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }

  .pdf-card-preview {
    height: 130px !important;
  }

  .btn-convert-primary {
    width: 100% !important;
    max-width: 320px !important;
    padding: 13px 20px !important;
    margin: 0 auto !important;
  }
}


/* ── Small Mobile Screen Refinement (<= 600px) ── */
@media (max-width: 600px) {
  .left-panel {
    height: calc(100vh - 120px) !important;
    max-height: 660px !important;
    min-height: 440px !important;
    padding: 12px 10px !important;
  }
}

/* ── Responsive Refinements (Phones <= 520px) ── */
@media (max-width: 520px) {
  .pdf-grid-container {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .pdf-card-preview {
    height: 120px !important;
  }
}

/* Custom Scrollbars */
.right-panel::-webkit-scrollbar,
.pdf-grid-container::-webkit-scrollbar {
  width: 5px;
}

.right-panel::-webkit-scrollbar-track,
.pdf-grid-container::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.right-panel::-webkit-scrollbar-thumb,
.pdf-grid-container::-webkit-scrollbar-thumb {
  background: var(--purple-400);
  border-radius: 4px;
}

.right-panel::-webkit-scrollbar-thumb:hover,
.pdf-grid-container::-webkit-scrollbar-thumb:hover {
  background: var(--purple-600);
}
