/* ==========================================================================
   EDITORA TOOLS — TOOL PAGE INTERACTIVE STYLES
   ========================================================================== */

/* Breadcrumbs */
.tool-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.tool-breadcrumb a {
  color: var(--text-muted);
}

.tool-breadcrumb a:hover {
  color: var(--primary);
}

.tool-breadcrumb span.separator {
  color: var(--text-light);
}

.tool-breadcrumb span.current {
  color: var(--text-main);
  font-weight: 600;
}

/* Tool Header */
.tool-page-header {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 2.5rem;
}

.tool-page-title {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.tool-page-desc {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Main Workspace Card */
.tool-workspace {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 2.5rem;
  max-width: 860px;
  margin: 0 auto 4rem;
  transition: all var(--transition-normal);
}

/* 1. Upload Dropzone State */
.upload-zone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 3.5rem 2rem;
  text-align: center;
  background: #fafafa;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.005);
}

.upload-zone-icon {
  width: 64px;
  height: 64px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.upload-zone:hover .upload-zone-icon {
  transform: translateY(-2px);
}

.upload-zone-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.upload-zone-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.file-input-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* 2. File Preview & List */
.file-preview-container {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}

.file-preview-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.file-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  transition: all var(--transition-fast);
}

.file-preview-item:hover {
  background: #ffffff;
  border-color: var(--border-hover);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  overflow: hidden;
}

.file-type-icon {
  width: 36px;
  height: 36px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.file-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-name {
  font-weight: 600;
  font-size: 0.925rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.file-size {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-remove-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-remove-btn:hover {
  color: var(--accent-rose);
  background: #fee2e2;
}

/* 3. Settings & Options Panel */
.tool-options-panel {
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.25rem;
}

.options-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
}

.option-val-display {
  color: var(--primary);
  font-weight: 700;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.range-slider {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  height: 6px;
  border-radius: 3px;
  background: #cbd5e1;
}

.pill-radios {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pill-radio-label {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.pill-radio-label input {
  display: none;
}

.pill-radio-label.active, .pill-radio-label input:checked + span {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* 4. Processing State */
.processing-state {
  display: none;
  text-align: center;
  padding: 3rem 1.5rem;
}

.spinner-pulse {
  width: 60px;
  height: 60px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.5rem;
}

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

.processing-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.processing-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.progress-track {
  width: 100%;
  max-width: 420px;
  height: 8px;
  background: var(--bg-alt);
  border-radius: 9999px;
  overflow: hidden;
  margin: 0 auto;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent-cyan) 100%);
  transition: width 0.3s ease;
  border-radius: 9999px;
}

/* 5. Result Card */
.result-card {
  display: none;
  text-align: center;
  padding: 2.5rem 1.5rem;
  animation: fadeIn 0.4s ease;
}

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

.result-success-icon {
  width: 64px;
  height: 64px;
  background: #ecfdf5;
  color: var(--accent-emerald);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}

.result-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.result-stats-box {
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin: 1.75rem auto 2rem;
  max-width: 520px;
  flex-wrap: wrap;
  gap: 1rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-val {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.savings-badge {
  background: #ecfdf5;
  color: var(--accent-emerald);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-weight: 800;
  font-size: 0.9rem;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* 6. Zero White Screen Error Boundary Card */
.error-card {
  display: none;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  margin-top: 1.5rem;
}

.error-card-icon {
  width: 48px;
  height: 48px;
  background: #ffe4e6;
  color: var(--accent-rose);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.error-card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: #9f1239;
  margin-bottom: 0.5rem;
}

.error-card-desc {
  font-size: 0.925rem;
  color: #881337;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

/* Educational Rich Text Sections on Tool Pages */
.tool-content-section {
  max-width: 860px;
  margin: 0 auto 4rem;
}

.tool-content-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 3rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2.5rem;
}

.tool-content-card h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 1.25rem;
}

.tool-content-card h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 1.5rem 0 0.75rem;
}

.tool-content-card p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.tool-content-card ul, .tool-content-card ol {
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.tool-content-card li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

/* ==========================================================================
   INTERACTIVE CROP & MULTI-PAGE STYLES
   ========================================================================== */

/* Mode Switcher Tabs */
.mode-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-alt, #f1f5f9);
  padding: 0.35rem;
  border-radius: var(--radius-lg, 12px);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-subtle, #e2e8f0);
}

.mode-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  background: transparent;
  border: none;
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  transition: all var(--transition-fast, 0.2s ease);
}

.mode-tab:hover {
  color: var(--text-main, #0f172a);
}

.mode-tab.active {
  background: #ffffff;
  color: var(--primary, #4f46e5);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.1));
}

/* Aspect Ratio Preset Pills */
.aspect-presets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.aspect-pill {
  padding: 0.4rem 0.85rem;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  background: #f8fafc;
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 9999px;
  cursor: pointer;
  transition: all var(--transition-fast, 0.2s ease);
}

.aspect-pill:hover {
  border-color: var(--primary, #4f46e5);
  color: var(--primary, #4f46e5);
}

.aspect-pill.active {
  background: var(--primary, #4f46e5);
  color: #ffffff;
  border-color: var(--primary, #4f46e5);
}

/* Interactive Crop Canvas Stage */
.crop-workspace-stage {
  background: #0f172a;
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  margin: 1rem 0;
  min-height: 280px;
  max-height: 480px;
  user-select: none;
  touch-action: none;
}

.crop-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 440px;
  line-height: 0;
}

.crop-source-img {
  display: block;
  max-width: 100%;
  max-height: 440px;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

/* Crop Box & Dimming Mask */
.crop-box {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.65);
  border: 2px solid #ffffff;
  cursor: move;
  box-sizing: border-box;
  touch-action: none;
}

/* Rule of Thirds Grid */
.crop-grid-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.crop-grid-h1 { top: 33.333%; left: 0; right: 0; height: 1px; }
.crop-grid-h2 { top: 66.666%; left: 0; right: 0; height: 1px; }
.crop-grid-v1 { left: 33.333%; top: 0; bottom: 0; width: 1px; }
.crop-grid-v2 { left: 66.666%; top: 0; bottom: 0; width: 1px; }

/* 8 Resize Handles */
.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border: 2px solid var(--primary, #4f46e5);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  z-index: 10;
}

.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-n  { top: -6px; left: calc(50% - 6px); cursor: ns-resize; }
.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-e  { top: calc(50% - 6px); right: -6px; cursor: ew-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.handle-s  { bottom: -6px; left: calc(50% - 6px); cursor: ns-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-w  { top: calc(50% - 6px); left: -6px; cursor: ew-resize; }

.crop-dim-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary, #4f46e5);
  background: var(--primary-subtle, #eef2ff);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
}

/* Multi-Page PDF Result Grid */
.multi-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.page-result-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.05));
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.page-result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,0.1));
}

.page-thumb-wrapper {
  width: 100%;
  height: 160px;
  background: #f8fafc;
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  border: 1px solid #f1f5f9;
}

.page-thumb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.page-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.85rem;
  width: 100%;
}

.page-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main, #0f172a);
}

.page-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted, #64748b);
}

.page-download-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
}

@media (max-width: 768px) {
  .tool-workspace {
    padding: 1.5rem;
  }
  .tool-content-card {
    padding: 1.75rem;
  }
  .tool-page-title {
    font-size: 2rem;
  }
  .mode-tabs {
    flex-direction: column;
  }
  .crop-workspace-stage {
    min-height: 220px;
    padding: 0.75rem;
  }
  .multi-page-grid {
    grid-template-columns: 1fr;
  }
}
