/* ─────────────────────────────────────────────
   Watturette — Configurator Modal
   ───────────────────────────────────────────── */

/* ══════════════════════════════════════
   MODAL OVERLAY
══════════════════════════════════════ */
.cfg-modal {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
}
.cfg-modal.open { opacity: 1; visibility: visible; }

.cfg-backdrop {
  position: absolute; inset: 0;
  background: rgba(17, 20, 24, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ══════════════════════════════════════
   DIALOG
══════════════════════════════════════ */
.cfg-dialog {
  position: relative; z-index: 1;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,.22), 0 4px 16px rgba(0,0,0,.1);
  width: min(1040px, 96vw);
  max-height: 92vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(.98);
  transition: transform .25s ease;
}
.cfg-modal.open .cfg-dialog { transform: translateY(0) scale(1); }

/* ── Header ── */
.cfg-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  gap: 16px;
}
.cfg-header-left { display: flex; align-items: center; gap: 14px; }
.cfg-header-icon {
  width: 40px; height: 40px; border-radius: var(--radius);
  background: var(--cyan-light); color: var(--cyan-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.cfg-header-title { font-size: 1rem; font-weight: 700; line-height: 1.2; }
.cfg-header-sub { font-size: .78rem; color: var(--gray-400); margin-top: 2px; }

.cfg-close {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200); background: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600); font-size: 1.1rem;
  cursor: pointer; transition: all .15s; flex-shrink: 0;
}
.cfg-close:hover { background: var(--gray-100); color: var(--black); border-color: var(--gray-400); }

/* ── Body ── */
.cfg-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Canvas area ── */
.cfg-canvas-area {
  background: var(--gray-50);
  border-right: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
  position: relative;
  overflow: hidden;
}

.cfg-canvas-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--gray-50); z-index: 10;
  gap: 12px;
  font-size: .85rem; color: var(--gray-400); font-weight: 500;
}
.cfg-canvas-loading i {
  font-size: 1.5rem; color: var(--cyan);
  animation: cfg-spin .9s linear infinite;
}
@keyframes cfg-spin { to { transform: rotate(360deg); } }

#konva-container { line-height: 0; border-radius: var(--radius); overflow: hidden; }

/* ── Controls panel ── */
.cfg-controls {
  overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 0;
  min-height: 0;
}
.cfg-controls::-webkit-scrollbar { width: 4px; }
.cfg-controls::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }

/* ── Section ── */
.cfg-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--gray-200);
}
.cfg-section:first-child { padding-top: 4px; }
.cfg-section:last-child { border-bottom: none; padding-bottom: 4px; }

.cfg-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 8px;
}
.cfg-section-header-left { display: flex; align-items: center; gap: 8px; }
.cfg-section-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; flex-shrink: 0;
}
.cfg-section-icon.cyan   { background: var(--cyan-light);  color: var(--cyan-dark); }
.cfg-section-icon.green  { background: var(--green-light); color: var(--green-dark); }
.cfg-section-icon.gray   { background: var(--gray-100);    color: var(--gray-600); }
.cfg-section-icon.orange { background: #fff3e0;            color: #e67e22; }

.cfg-section-name { font-size: .9rem; font-weight: 700; }
.cfg-section-sub {
  font-size: .75rem; color: var(--gray-400); margin-top: 2px;
  display: block; padding-left: 36px;
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ── Toggle switch ── */
.cfg-toggle {
  width: 40px; height: 22px; border-radius: 100px;
  background: var(--gray-200); border: none; padding: 0;
  position: relative; cursor: pointer;
  transition: background .2s; flex-shrink: 0;
}
.cfg-toggle::after {
  content: ''; position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: transform .2s;
}
.cfg-toggle.on { background: var(--cyan); }
.cfg-toggle.on::after { transform: translateX(18px); }

/* ── Swatch grid ── */
.cfg-swatches {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 12px;
}

.cfg-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; border: 2.5px solid transparent;
  transition: transform .15s, box-shadow .15s;
  flex-shrink: 0; position: relative;
  outline: none;
}
.cfg-swatch:hover { transform: scale(1.14); }
.cfg-swatch.active {
  box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--black);
}

/* "None" swatch (crossed out) */
.cfg-swatch-none {
  background: var(--white) !important;
  border-color: var(--gray-300, #c8d0da) !important;
  overflow: hidden;
}
.cfg-swatch-none::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(
    -45deg,
    transparent 42%,
    #e53e3e 42%,
    #e53e3e 58%,
    transparent 58%
  );
}
.cfg-swatch-none.active {
  box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--gray-400);
}

/* Light swatches get a border to be visible on white bg */
.cfg-swatch-light {
  border-color: var(--gray-200) !important;
}

/* ── Custom color row ── */
.cfg-custom-row {
  display: flex; align-items: center; gap: 10px;
}
.cfg-custom-label { font-size: .8rem; color: var(--gray-600); font-weight: 500; }
.cfg-custom-input {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  padding: 2px; cursor: pointer;
  background: none; overflow: hidden;
}
.cfg-custom-input::-webkit-color-swatch-wrapper { padding: 0; }
.cfg-custom-input::-webkit-color-swatch { border: none; border-radius: 4px; }

/* Disabled state (for bandes controls when toggled off) */
.cfg-layer-options {
  transition: opacity .2s;
}
.cfg-layer-options.disabled {
  opacity: .35;
  pointer-events: none;
}

/* ── Selected color preview ── */
.cfg-color-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-size: .8rem; color: var(--gray-600);
  transition: all .2s;
}
.cfg-color-preview.hidden { display: none; }
.cfg-color-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.1);
  flex-shrink: 0;
}
.cfg-color-name { font-weight: 600; color: var(--black); }

/* ── Footer ── */
.cfg-footer {
  padding: 14px 28px;
  border-top: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; gap: 12px; flex-wrap: wrap;
  background: var(--gray-50);
}
.cfg-summary-text {
  font-size: .82rem; color: var(--gray-600);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.cfg-summary-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 100px; padding: 2px 8px 2px 4px;
  font-size: .75rem; font-weight: 600; color: var(--black);
}
.cfg-summary-chip-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.1);
}
.cfg-footer-actions { display: flex; gap: 10px; }

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 760px) {
  .cfg-dialog {
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }
  .cfg-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
  }
  .cfg-canvas-area {
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    padding: 20px;
  }
  .cfg-controls {
    overflow-y: visible;
    padding: 16px;
  }
  .cfg-header { padding: 14px 16px; }
  .cfg-footer { padding: 12px 16px; }
}
