/* ===================================================
   Configurador Revu — Styles
   =================================================== */

:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --surface-hover: #ebebed;
  --border: #e0e0e5;
  --text: #1a1a1e;
  --text-muted: #6b6b76;
  --accent: #000000;
  --accent-hover: #2a2a2a;
  --green: #25d366;
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 32px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.1);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.15);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --panel-width: 380px;
  --header-h: 64px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
button { font-family: var(--font); }
input, textarea { font-family: var(--font); }

/* ── Header ── */
.cfg-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.cfg-header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.5px;
}

.cfg-header-logo img {
  height: 28px;
  width: auto;
}

.cfg-header-badge {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  letter-spacing: 0.02em;
}

/* ── Layout ── */
.cfg-layout {
  display: flex;
  height: 100dvh;
  padding-top: var(--header-h);
}

/* Right: 3D Preview */
.cfg-preview {
  flex: 1;
  position: sticky;
  top: var(--header-h);
  height: calc(100dvh - var(--header-h));
  background: linear-gradient(145deg, #f0f0f3 0%, #e8e8ec 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.cfg-preview canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.cfg-preview-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 99px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.5s ease;
  white-space: nowrap;
}

.cfg-preview-hint.hidden {
  opacity: 0;
}

.cfg-download-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, transform 0.15s;
  box-shadow: var(--shadow-sm);
}

.cfg-download-btn:hover {
  background: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.cfg-download-btn svg {
  width: 14px;
  height: 14px;
}

/* Left: Options Panel */
.cfg-panel {
  width: var(--panel-width);
  flex-shrink: 0;
  height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  order: -1;
}

.cfg-panel::-webkit-scrollbar { width: 4px; }
.cfg-panel::-webkit-scrollbar-track { background: transparent; }
.cfg-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.cfg-panel-inner {
  padding: 28px 24px 120px;
  flex: 1;
}

.cfg-panel-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 4px;
  color: var(--text);
}

.cfg-panel-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── Section ── */
.cfg-section {
  margin-bottom: 28px;
}

.cfg-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Segmented Control ── */
.cfg-segment {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.cfg-segment input[type="radio"] { display: none; }

.cfg-segment label {
  flex: 1;
  text-align: center;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cfg-segment input[type="radio"]:checked + label {
  background: white;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* ── Color Swatches ── */
.cfg-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cfg-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
  flex-shrink: 0;
}

.cfg-swatch:hover {
  transform: scale(1.12);
}

.cfg-swatch.selected {
  border-color: var(--text);
  transform: scale(1.12);
}

.cfg-swatch.selected::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--text);
}

.cfg-swatch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cfg-color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cfg-color-input {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 2px;
  background: none;
  flex-shrink: 0;
}

.cfg-color-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Paint Toggle ── */
.cfg-paint-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cfg-paint-color {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  transition: all 0.3s ease;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
}

.cfg-paint-color.visible {
  max-height: 100px;
  opacity: 1;
  padding: 12px 14px;
}

/* ── Logo Section ── */
.cfg-logo-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cfg-radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: background 0.2s;
  border: 2px solid transparent;
}

.cfg-radio-option:hover { background: var(--surface-hover); }

.cfg-radio-option input[type="radio"] { display: none; }

.cfg-radio-option.selected {
  background: white;
  border-color: var(--text);
}

.cfg-radio-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cfg-radio-option.selected .cfg-radio-dot {
  border-color: var(--text);
  background: var(--text);
}

.cfg-radio-option.selected .cfg-radio-dot::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
}

.cfg-radio-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.cfg-radio-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Upload Zone ── */
.cfg-upload-zone {
  margin-top: 10px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--surface);
  display: none;
}

.cfg-upload-zone.visible { display: block; }

.cfg-upload-zone:hover, .cfg-upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.cfg-upload-zone input { display: none; }

.cfg-upload-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.cfg-upload-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.cfg-upload-text strong { color: var(--text); }

.cfg-upload-preview {
  margin-top: 10px;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

.cfg-upload-preview.visible { display: flex; }

.cfg-upload-preview img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
  background: white;
  border: 1px solid var(--border);
}

.cfg-upload-preview-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cfg-upload-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.cfg-upload-remove:hover { color: #e00; background: #fee; }
.cfg-upload-remove svg { width: 14px; height: 14px; }

/* ── Text Input ── */
.cfg-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.cfg-input::placeholder { color: var(--text-muted); font-weight: 400; }

.cfg-input:focus {
  border-color: var(--text);
  background: white;
}

.cfg-input-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ── Divider ── */
.cfg-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0 28px;
}

/* ── CTA ── */
.cfg-cta-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  width: var(--panel-width);
  padding: 16px 24px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 50;
}

.cfg-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 99px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  letter-spacing: -0.01em;
}

.cfg-cta-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.3);
}

.cfg-cta-btn:active { transform: scale(0.98); }

.cfg-cta-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  flex-shrink: 0;
}

.cfg-cta-note {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Loading overlay ── */
.cfg-loading {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, #f0f0f3 0%, #e8e8ec 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
  transition: opacity 0.4s ease;
}

.cfg-loading.done { opacity: 0; pointer-events: none; }

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

.cfg-loading-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Mobile Layout ── */
@media (max-width: 768px) {
  :root { --panel-width: 100%; }

  .cfg-layout {
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }

  .cfg-preview {
    position: sticky;
    top: var(--header-h);
    height: 48vw;
    min-height: 260px;
    max-height: 380px;
    z-index: 10;
    order: -1;
    flex-shrink: 0;
  }

  .cfg-panel {
    width: 100%;
    height: auto;
    overflow-y: visible;
    border-right: none;
    border-top: 1px solid var(--border);
    order: 1;
  }

  .cfg-panel-inner {
    padding: 24px 20px 140px;
  }

  .cfg-cta-wrap {
    width: 100%;
    left: 0;
  }

  .cfg-header {
    padding: 0 16px;
  }

  .cfg-download-btn {
    font-size: 0.72rem;
    padding: 6px 10px;
  }
}

@media (max-width: 480px) {
  .cfg-preview {
    height: 55vw;
    min-height: 240px;
  }

  .cfg-panel-title { font-size: 1.2rem; }
}

/* ── Animations ── */
.cfg-section {
  animation: fadeUp 0.4s ease both;
}

.cfg-section:nth-child(1) { animation-delay: 0.05s; }
.cfg-section:nth-child(2) { animation-delay: 0.1s; }
.cfg-section:nth-child(3) { animation-delay: 0.15s; }
.cfg-section:nth-child(4) { animation-delay: 0.2s; }
.cfg-section:nth-child(5) { animation-delay: 0.25s; }
.cfg-section:nth-child(6) { animation-delay: 0.3s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
