/*
 * CSS Filter & Blend Generator
 * Prefix: cfbg-
 * Common components use dtc-* classes from tools-common.css
 */

:root {
  --dtc-primary: #3b82f6;
  --dtc-primary-light: #eff6ff;
  --dtc-primary-dark: #2563eb;
  --dtc-bg: #f8fafc;
  --dtc-bg-card: #ffffff;
  --dtc-border: #e2e8f0;
  --dtc-text: #1e293b;
  --dtc-text-muted: #64748b;
  --dtc-radius: 12px;
  --dtc-radius-sm: 6px;
  --dtc-transition: .2s ease;
}

/* Base */
.cfbg-container > p,
.cfbg-container > br {
  display: none !important;
}
.cfbg-app * {
  margin-top: 0 !important;
  box-sizing: border-box;
}

/* App Wrapper */
.cfbg-app {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Presets */
.cfbg-presets-wrap {
  width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 12px 16px;
}
.cfbg-presets {
  display: flex;
  gap: 10px;
}
.cfbg-preset-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}
.cfbg-preset-btn:hover {
  background: #f1f5f9;
}
.cfbg-preset-btn.active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

/* Preview Section */
.cfbg-preview-section {
  padding: 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.cfbg-preview-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.cfbg-preview-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.cfbg-btn-small {
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
}
.cfbg-btn-small:hover {
  background: #f1f5f9;
}

/* Canvas Settings Bar */
.cfbg-canvas-bar {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.8rem;
}
.cfbg-canvas-bar label {
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}
.cfbg-canvas-bar select,
.cfbg-canvas-bar input[type="number"] {
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.8rem;
  background: #fff;
}
.cfbg-canvas-bar input[type="number"] {
  width: 55px;
}
.cfbg-canvas-bar .cfbg-canvas-sep {
  color: #94a3b8;
  font-weight: 600;
}
.cfbg-canvas-bar .cfbg-btn-fit-image {
  padding: 4px 10px;
  background: #e0f2fe;
  border: 1px solid #7dd3fc;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #0369a1;
  cursor: pointer;
  white-space: nowrap;
}
.cfbg-canvas-bar .cfbg-btn-fit-image:hover {
  background: #bae6fd;
}
.cfbg-canvas-bar input[type="range"] {
  width: 80px;
}
.cfbg-canvas-bar .cfbg-range-val {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  width: 30px;
  text-align: right;
}
.cfbg-save-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.cfbg-preview-area {
  width: 100%;
  max-width: 600px;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background-color: #e2e8f0;
  transition: background-color 0.3s;
}
/* Background types */
.cfbg-bg-light { background-color: #f8fafc; }
.cfbg-bg-dark { background-color: #0f172a; }
.cfbg-bg-checker {
  background-color: #f1f5f9;
  background-image: 
    linear-gradient(45deg, #cbd5e1 25%, transparent 25%, transparent 75%, #cbd5e1 75%, #cbd5e1),
    linear-gradient(45deg, #cbd5e1 25%, transparent 25%, transparent 75%, #cbd5e1 75%, #cbd5e1);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  background-repeat: repeat !important;
}
.cfbg-bg-image {
  background-image: url('https://images.unsplash.com/photo-1557683316-973673baf926?auto=format&fit=crop&q=80&w=800');
  background-size: cover;
  background-position: center;
}

.cfbg-target-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  transition: all 0.3s;
}

.cfbg-backdrop-overlay {
  position: absolute;
  top: 15%;
  left: 15%;
  width: 70%;
  height: 70%;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: bold;
  font-size: 1.5rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  pointer-events: none;
  overflow: hidden;
  word-break: break-word;
  text-align: center;
  padding: 10px;
}

/* Settings Tabs */
.cfbg-tabs {
  display: flex;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.cfbg-tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-size: 0.95rem;
}
.cfbg-tab-btn:hover {
  color: #3b82f6;
}
.cfbg-tab-btn.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
  background: #fff;
}
.cfbg-tab-pane {
  display: none;
  padding: 20px;
}
.cfbg-tab-pane.active {
  display: block;
}

/* Draggable List */
.cfbg-filter-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.cfbg-filter-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: grab;
  user-select: none;
}
.cfbg-filter-item:active {
  cursor: grabbing;
}
.cfbg-filter-item.dragging {
  opacity: 0.5;
  background: #f1f5f9;
}
.cfbg-drag-handle {
  color: #94a3b8;
  font-size: 1.2rem;
}
.cfbg-filter-info {
  width: 100px;
  font-weight: 600;
  font-size: 0.85rem;
  color: #334155;
  text-transform: capitalize;
}
.cfbg-filter-control {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cfbg-filter-control input[type="range"] {
  flex: 1;
}
.cfbg-filter-val {
  font-size: 0.85rem;
  font-weight: 600;
  width: 45px;
  text-align: right;
  color: #475569;
}
.cfbg-btn-remove {
  padding: 4px 8px;
  background: #fee2e2;
  color: #ef4444;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}
.cfbg-btn-remove:hover {
  background: #fecaca;
}

/* Add Filter Control */
.cfbg-add-filter {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #f8fafc;
  padding: 12px;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
}
.cfbg-select {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  flex: 1;
}
.cfbg-btn-primary {
  padding: 8px 16px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.cfbg-btn-primary:hover {
  background: #2563eb;
}

/* Blend & Backdrop Layout */
.cfbg-input-group {
  margin-bottom: 20px;
}
.cfbg-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 8px;
}

/* Settings Group */
.cfbg-settings-group {
  padding: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 16px;
}
.cfbg-settings-group-title {
  font-weight: 600;
  font-size: 0.8rem;
  color: #64748b;
  margin-bottom: 12px !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cfbg-settings-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.cfbg-settings-row:last-child {
  margin-bottom: 0;
}
.cfbg-settings-row label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  width: 80px;
  flex-shrink: 0;
}
.cfbg-settings-row select,
.cfbg-settings-row input[type="text"],
.cfbg-settings-row input[type="number"],
.cfbg-settings-row input[type="color"],
.cfbg-settings-row input[type="range"] {
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.8rem;
  background: #fff;
}
.cfbg-settings-row input[type="color"] {
  width: 36px;
  height: 30px;
  padding: 2px;
  cursor: pointer;
}
.cfbg-settings-row input[type="range"] {
  flex: 1;
  min-width: 100px;
}
.cfbg-settings-row input[type="number"] {
  width: 60px;
}
.cfbg-settings-row input[type="text"] {
  flex: 1;
  min-width: 120px;
}
.cfbg-range-val {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  width: 36px;
  text-align: right;
}

/* Result Area */
.cfbg-result-block {
  background: #1e293b;
  border-radius: 8px;
  padding: 16px;
  position: relative;
  margin-top: 10px;
}
.cfbg-code {
  margin: 0 !important;
  color: #e2e8f0;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.cfbg-copy-wrap {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}
.cfbg-btn-copy,
.cfbg-btn-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 30px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.cfbg-btn-copy:hover,
.cfbg-btn-save:hover {
  background: #2563eb;
}
.cfbg-btn-save {
  background: #10b981;
}
.cfbg-btn-save:hover {
  background: #059669;
}
