/**
 * PicDriver Image Filter Tool - Studio Stylesheet
 * 100% Fluid & Mobile-First Responsive
 */

/* Top Action & Demo Bar */
.demo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.filter-pills-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Category Filter Tabs */
.filter-category-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.category-tab {
  padding: 6px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
}

.category-tab:hover {
  color: #fff;
  border-color: var(--brand-primary);
}

.category-tab.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.35);
}

/* Preset Cards Grid (Fluid & No Nested Scroll Trap) */
.filter-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  position: relative;
  user-select: none;
}

.preset-card:hover {
  border-color: var(--brand-primary);
  background: rgba(99, 102, 241, 0.12);
  transform: translateY(-1px);
}

.preset-card.active {
  border-color: var(--brand-primary);
  background: rgba(99, 102, 241, 0.22);
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.35);
}

.preset-swatch {
  width: 100%;
  height: 26px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Stage Preview */
.filter-stage-container {
  position: relative;
  min-height: 420px;
  max-height: 560px;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.98) 100%);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 20px;
  user-select: none;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

#filterCanvas {
  display: block;
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  touch-action: none;
}

/* Split Slider Divider */
.split-slider-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.split-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ffffff;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.9);
  pointer-events: auto;
  cursor: ew-resize;
  transform: translateX(-50%);
  touch-action: none;
}

.split-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  background: var(--brand-primary);
  border: 2px solid #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
  user-select: none;
}

.split-label-before, .split-label-after {
  position: absolute;
  bottom: 12px;
  padding: 4px 10px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  pointer-events: none;
}

.split-label-before { left: 16px; }
.split-label-after { right: 16px; }

/* Control Sections */
.control-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.control-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.control-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.control-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stage-actions-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Switch Toggle */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: .2s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: .2s;
  border-radius: 50%;
}

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

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

/* Mobile Responsiveness */
@media (max-width: 1080px) {
  .filter-stage-container {
    min-height: 340px;
    max-height: 460px;
  }
}

@media (max-width: 768px) {
  .demo-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-stage-container {
    min-height: 260px;
    max-height: 350px;
    padding: 10px;
  }
  #filterCanvas {
    max-height: 330px;
  }
  .control-grid-2col {
    grid-template-columns: 1fr;
  }
  .stage-actions-bar {
    flex-direction: column;
  }
  .stage-actions-bar .btn {
    width: 100%;
  }
}
