/**
 * ToolFlux Lab — PDF Studio Stylesheet
 * High-performance, accessible, responsive styling with full Dark/Light and RTL support.
 */

.pdf-studio-workspace {
  margin-block: var(--space-8);
}

.pdf-studio-header {
  text-align: center;
  max-width: 820px;
  margin-inline: auto;
  margin-bottom: var(--space-8);
}

.pdf-studio-title {
  font-size: var(--text-3xl);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
  margin-bottom: var(--space-3);
}

.pdf-studio-lead {
  font-size: var(--text-lg);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
}

.pdf-privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 14px;
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  margin-bottom: var(--space-4);
}

/* Tool Navigation Tabs */
.pdf-tabs-container {
  overflow-x: auto;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-6);
  -webkit-overflow-scrolling: touch;
}

.pdf-tabs-nav {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  min-width: max-content;
  padding: 4px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.pdf-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.pdf-tab-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-input);
}

.pdf-tab-btn.active {
  background-color: var(--color-brand);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.pdf-tab-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Studio Workspace Shell */
.pdf-workspace-shell {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  position: relative;
}

/* Drop Zone */
.pdf-drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-6);
  text-align: center;
  background-color: var(--bg-input);
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.pdf-drop-zone:hover,
.pdf-drop-zone.dragover {
  border-color: var(--color-brand);
  background-color: rgba(37, 99, 235, 0.04);
}

.pdf-drop-icon {
  width: 56px;
  height: 56px;
  color: var(--color-brand);
  margin-inline: auto;
  margin-bottom: var(--space-4);
}

.pdf-drop-text {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: var(--space-2);
}

.pdf-drop-subtext {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

/* Active File Bar */
.pdf-active-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.pdf-active-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.pdf-file-icon {
  width: 36px;
  height: 36px;
  color: #ef4444;
  flex-shrink: 0;
}

.pdf-active-name {
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--text-main);
  word-break: break-all;
}

.pdf-active-details {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.pdf-active-actions {
  display: flex;
  gap: var(--space-2);
}

/* Tool Controls Layout */
.pdf-tool-panel {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.pdf-tool-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.pdf-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.pdf-control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.pdf-control-group label {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-main);
}

.pdf-control-group input[type="text"],
.pdf-control-group input[type="number"],
.pdf-control-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-size: var(--text-sm);
  transition: border-color var(--transition-fast);
}

.pdf-control-group input:focus,
.pdf-control-group select:focus {
  outline: none;
  border-color: var(--color-brand);
}

/* Visual Pages Grid (for Reorder, Rotate, Delete) */
.pdf-pages-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.pdf-pages-title {
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--text-main);
}

.pdf-pages-actions {
  display: flex;
  gap: var(--space-2);
}

.pdf-pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-4);
  max-height: 480px;
  overflow-y: auto;
  padding: var(--space-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background-color: var(--bg-input);
  margin-bottom: var(--space-6);
}

.pdf-page-card {
  background-color: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all var(--transition-fast);
  position: relative;
  user-select: none;
}

.pdf-page-card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-sm);
}

.pdf-page-card.deleted {
  opacity: 0.45;
  border-color: #ef4444;
  background-color: rgba(239, 68, 68, 0.05);
}

.pdf-page-card.selected {
  border-color: var(--color-brand);
  background-color: rgba(37, 99, 235, 0.05);
}

.pdf-page-thumb-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1.414;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  margin-bottom: var(--space-2);
}

.pdf-page-thumb-wrapper canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform var(--transition-fast);
}

.pdf-page-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.pdf-page-controls {
  display: flex;
  gap: 4px;
  width: 100%;
  justify-content: center;
}

.pdf-page-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.pdf-page-btn:hover {
  background-color: var(--bg-input);
  color: var(--color-brand);
  border-color: var(--color-brand);
}

.pdf-page-btn.btn-delete:hover {
  color: #ef4444;
  border-color: #ef4444;
}

/* File List Queue for Merge */
.pdf-queue-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  max-height: 380px;
  overflow-y: auto;
}

.pdf-queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.pdf-queue-item:hover {
  border-color: var(--color-brand);
}

.pdf-queue-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  overflow: hidden;
}

.pdf-queue-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.pdf-queue-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.pdf-queue-actions {
  display: flex;
  gap: var(--space-2);
}

/* Action Execution Bar */
.pdf-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.pdf-stats-summary {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.pdf-stat-item strong {
  color: var(--text-main);
}

/* Progress & Toast Notification */
.pdf-progress-bar-container {
  display: none;
  width: 100%;
  height: 6px;
  background-color: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.pdf-progress-bar-fill {
  width: 0%;
  height: 100%;
  background-color: var(--color-brand);
  transition: width 0.2s ease;
}

/* Toast */
.pdf-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background-color: #1e293b;
  color: #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  z-index: 9999;
  display: none;
  align-items: center;
  gap: var(--space-3);
  animation: slideUp 0.3s ease;
}

[dir="rtl"] .pdf-toast {
  right: auto;
  left: 24px;
}

.pdf-toast.error {
  background-color: #ef4444;
}

.pdf-toast.success {
  background-color: #10b981;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .pdf-workspace-shell {
    padding: var(--space-4);
  }
  
  .pdf-action-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .pdf-action-bar button {
    width: 100%;
  }

  .pdf-pages-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
