/* ========== Global Style ========== */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f8f9fa;
  color: #212529;
  margin: 0;
}

/* ========== Hero Section ========== */
.hero-section {
  background: linear-gradient(145deg, #ffffff 0%, #f2f4f8 100%);
  border-radius: 1rem;
  padding: 4rem 2rem;
  margin-bottom: 2rem;
}

.hero-section h1 {
  color: #1a1e24;
}

.hero-section .lead {
  color: #4a5568;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

/* ========== Features / Steps ========== */
.features-section .card,
.how-it-works .step {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.features-section .card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.1) !important;
}

.step-number {
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1;
}

/* ========== Tool Cards ========== */
.card {
  border-radius: 0.75rem;
  border: none;
  background: #ffffff;
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  font-weight: 600;
  padding: 1rem 1.25rem;
}

/* Upload buttons */
.card:has(#upload) .btn-group {
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.card:has(#upload) .btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 0.5rem;
  min-width: 180px;
}

.card:has(#upload) .btn i {
  margin-right: 0.5rem;
}

[dir="rtl"] .card:has(#upload) .btn i {
  margin-right: 0;
  margin-left: 0.5rem;
}

/* Canvas container */
#canvasContainer {
  position: relative;
  display: block;
  width: 100%;
  overflow: auto;
  margin-bottom: 20px;
  min-height: 200px;
  max-height: 70vh;
}

#canvas {
  display: block;
  background: #fff;
  border-radius: 0.5rem;
  border: 1px solid #dee2e6;
  margin: 1rem auto;
  transition: transform 0.3s ease;
  transform-origin: center center;
  cursor: grab;
  max-width: none !important;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

#canvas.zooming {
  cursor: grabbing;
}

/* ========== Zoom Controls ========== */
.zoom-controls {
  top: 10px;
  right: 10px;
  z-index: 1000;
  opacity: 0.9;
  pointer-events: auto;
}

.zoom-controls-inner {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 0.5rem;
  padding: 0.5rem;
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.zoom-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  border: 1px solid rgba(0, 0, 0, 0.125);
}

.zoom-indicator {
  top: 10px;
  left: 10px;
  z-index: 1000;
  font-size: 12px;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  opacity: 0.9;
}

[dir="rtl"] .zoom-controls {
  right: auto;
  left: 10px;
}

[dir="rtl"] .zoom-indicator {
  left: auto;
  right: 10px;
}

/* ========== Before/After Slider ========== */
.before-after-slider-container {
  position: relative;
  max-width: 100%;
  margin: 0.25rem auto 1rem auto;
  background: #fff;
  border-radius: 0.5rem;
  border: 1px solid #dee2e6;
  overflow: visible;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  display: block;
}

.before-after-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 0.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.before-after-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
  border-radius: 0.75rem;
  width: 100%;
  height: 100%;
}

.before-after-image canvas {
  display: block;
  border-radius: 0.75rem;
  width: 100%;
  height: auto;
}

.before-image { z-index: 2; }
.after-image  { z-index: 1; }

.before-after-slider-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid #fff;
  border-radius: 2px;
  z-index: 3;
  cursor: ew-resize;
  transform: translateX(-50%);
  transition: background-color 0.2s ease;
  pointer-events: auto;
}

.slider-line {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
  pointer-events: none;
}

.slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  background: #fff;
  border: 3px solid #0d6efd;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  z-index: 4;
}

.slider-handle i {
  font-size: 16px;
  color: #0d6efd;
  transform: rotate(90deg);
}

.before-after-controls {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 5;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.5rem;
  border-radius: 0.5rem;
  backdrop-filter: blur(4px);
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

[dir="rtl"] .before-after-slider-handle {
  cursor: ew-resize;
}
[dir="rtl"] .slider-handle i {
  transform: rotate(-90deg);
}
[dir="rtl"] .before-after-controls {
  right: auto;
  left: 1rem;
}

/* ========== Footer ========== */
.footer {
  background-color: #343a40;
  color: #f8f9fa;
}
.footer a {
  color: #f8f9fa;
  transition: color 0.2s ease;
}
.footer a:hover {
  color: #0d6efd;
}
.footer p {
  color: #f8f9fa;
}
.footer span {
  color: #f8f9fa;
}
.filter-lightgray {
  filter: brightness(0) invert(1) grayscale(1) brightness(2);
}

/* ========== Responsive Tweaks ========== */
@media (max-width: 768px) {
  .hero-section {
    padding: 2rem 1rem;
  }
  .hero-section h1 {
    font-size: 2rem;
  }
  .zoom-controls {
    top: 5px;
    right: 5px;
  }
  .zoom-btn {
    width: 32px;
    height: 32px;
  }
  .slider-handle {
    width: 36px;
    height: 36px;
  }
  .before-after-controls {
    bottom: 0.75rem;
    right: 0.75rem;
  }
}

@media (max-width: 480px) {
  .card:has(#upload) .btn {
    min-width: 140px;
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
  }
  .slider-handle {
    width: 32px;
    height: 32px;
  }
}