/* ============================================
   EditPro Hub — Tool Page Layout Styles
   ============================================ */

/* ---------- Tool Page Layout ---------- */
.tool-page {
  padding-top: calc(var(--nav-height) + var(--space-8));
  min-height: 100vh;
}

.tool-header {
  text-align: center;
  padding: var(--space-8) 0 var(--space-6);
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.tool-header .breadcrumb {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

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

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

.tool-header h1 {
  font-size: clamp(1.75rem, 4vw, var(--text-4xl));
  margin-bottom: var(--space-3);
}

.tool-header .tool-tagline {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ---------- Tool Container ---------- */
.tool-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding) var(--space-12);
}

/* ---------- Upload Zone ---------- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-2xl);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  transition: all var(--transition-base);
  background: var(--bg-secondary);
  cursor: pointer;
  position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-50);
}

[data-theme="dark"] .upload-zone.dragover {
  background: rgba(99,102,241,0.1);
}

.upload-zone .upload-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  color: var(--primary);
  transition: transform var(--transition-spring);
}

.upload-zone:hover .upload-icon {
  transform: translateY(-5px) scale(1.1);
}

.upload-zone h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
}

.upload-zone p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.upload-zone .file-types {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ---------- Tool Workspace ---------- */
.tool-workspace {
  display: none;
  gap: var(--space-6);
}

.tool-workspace.active {
  display: grid;
  grid-template-columns: 1fr 300px;
}

/* ---------- Preview Area ---------- */
.preview-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.preview-area canvas,
.preview-area img {
  max-width: 100%;
  max-height: 500px;
  object-fit: contain;
  border-radius: var(--radius-md);
}

/* Checkerboard background for transparency */
.preview-area.has-transparency {
  background-image: linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.preview-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  width: 100%;
}

.preview-comparison .preview-side {
  text-align: center;
}

.preview-comparison .preview-side label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  display: block;
}

.preview-comparison .preview-side img,
.preview-comparison .preview-side canvas {
  max-width: 100%;
  max-height: 350px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* ---------- Controls Panel ---------- */
.controls-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-height: 600px;
  overflow-y: auto;
}

.controls-panel h3 {
  font-size: var(--text-base);
  font-weight: 600;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

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

.control-group label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-group label .value {
  font-weight: 600;
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* Range slider */
.control-group input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid var(--white);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast);
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.control-group input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid var(--white);
  box-shadow: var(--shadow-md);
}

/* Number input */
.control-group input[type="number"] {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text-primary);
  font-size: var(--text-sm);
}

.control-group input[type="number"]:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-100);
}

/* Select */
.control-group select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text-primary);
  font-size: var(--text-sm);
  cursor: pointer;
}

.control-group select:focus {
  border-color: var(--primary);
  outline: none;
}

/* Color input */
.control-group input[type="color"] {
  width: 44px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 2px;
}

/* Checkbox / Toggle */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.toggle-group label {
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: 0;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ---------- Action Buttons ---------- */
.tool-actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.tool-actions .btn {
  flex: 1;
}

/* ---------- Before/After Slider ---------- */
.before-after-slider {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-lg);
  cursor: col-resize;
  user-select: none;
}

.before-after-slider img {
  display: block;
  width: 100%;
}

.before-after-slider .overlay {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  overflow: hidden;
  width: 50%;
}

.before-after-slider .overlay img {
  width: auto;
  min-width: 100%;
  height: 100%;
  object-fit: cover;
}

.before-after-slider .divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: white;
  transform: translateX(-50%);
  z-index: 2;
  box-shadow: 0 0 8px rgba(0,0,0,0.3);
}

.before-after-slider .handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  color: var(--gray-700);
}

/* ---------- Textarea for text tools ---------- */
.tool-textarea {
  width: 100%;
  min-height: 200px;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  resize: vertical;
}

.tool-textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-100);
}

.tool-output {
  width: 100%;
  min-height: 150px;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* ---------- Text Tool Layout ---------- */
.text-tool-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

.text-tool-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.text-tool-panel h3 {
  font-size: var(--text-base);
  font-weight: 600;
}

.text-tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ---------- Info Sections ---------- */
.tool-info {
  max-width: var(--max-width-narrow);
  margin: var(--space-12) auto;
  padding: 0 var(--container-padding);
}

.tool-info section {
  margin-bottom: var(--space-10);
}

.tool-info h2 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-4);
}

.tool-info h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
}

.tool-info p {
  font-size: var(--text-base);
  line-height: 1.8;
}

.tool-info ul {
  padding-left: var(--space-6);
}

.tool-info ul li {
  list-style: disc;
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
  line-height: 1.6;
}

.tool-info ol {
  padding-left: var(--space-6);
}

.tool-info ol li {
  list-style: decimal;
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---------- FAQ ---------- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg);
  text-align: left;
  transition: background var(--transition-fast);
}

.faq-question:hover {
  background: var(--bg-secondary);
}

.faq-question .faq-chevron {
  transition: transform var(--transition-base);
  flex-shrink: 0;
  margin-left: var(--space-4);
}

.faq-item.open .faq-question .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-base);
}

.faq-item.open .faq-answer {
  max-height: 500px;
}

.faq-answer p {
  padding: 0 var(--space-6) var(--space-6);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 0;
}

/* ---------- Loading overlay ---------- */
.tool-loading {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-xl);
}

[data-theme="dark"] .tool-loading {
  background: rgba(15,23,42,0.8);
}

.tool-loading .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---------- Responsive for tool pages ---------- */
@media (max-width: 1024px) {
  .tool-workspace.active {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    max-height: none;
    order: -1;
  }

  .text-tool-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .tool-header h1 {
    font-size: var(--text-2xl);
  }

  .preview-area {
    min-height: 250px;
  }

  .preview-comparison {
    grid-template-columns: 1fr;
  }

  .upload-zone {
    padding: var(--space-8) var(--space-4);
  }

  .tool-actions {
    flex-wrap: wrap;
  }
}
