@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #1e2530;
  --surface3:  #262d3a;
  --border:    #30394a;
  --text:      #e6edf3;
  --text-muted:#8b949e;
  --accent:    #004367;
  --accent-h:  #005a8a;
  --red:       #D82E31;
  --orange:    #F48719;
  --radius:    14px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --transition:0.22s cubic-bezier(0.4,0,0.2,1);
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ─── Layout ───────────────────────────────────────────────── */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 40px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-logo {
  width: 36px;
  height: 36px;
}

header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text);
}

header h1 span {
  color: var(--text-muted);
  font-weight: 400;
}

.header-spacer { flex: 1; }

/* ─── Breadcrumb / Steps indicator ────────────────────────── */
.steps-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 16px 40px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.step-item.active { color: var(--text); }
.step-item.done   { color: var(--accent-h); }

.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  transition: all var(--transition);
}

.step-item.active .step-num {
  background: var(--accent);
  border-color: var(--accent-h);
  color: #fff;
}
.step-item.done .step-num {
  background: #1a4a6e;
  border-color: var(--accent);
  color: #fff;
}

.step-sep {
  color: var(--border);
  font-size: 12px;
  margin: 0 2px;
}

/* ─── Main content area ────────────────────────────────────── */
.content {
  flex: 1;
  padding: 40px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; }

/* ─── Step 1: BU Cards ─────────────────────────────────────── */
.view-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.view-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.bu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.bu-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all var(--transition);
  position: relative;
}

.bu-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 36px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,67,103,0.3);
}

/* Colored banner at top */
.bu-card-banner {
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Subtle diagonal shine overlay */
.bu-card-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.07) 0%, transparent 60%);
  pointer-events: none;
}

.bu-card-logo-wrap {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: brightness(0) invert(1);  /* Force white logo on any color bg */
  opacity: 0.92;
}

.bu-card-logo-wrap svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Text body below */
.bu-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bu-card-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
}

.bu-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Editorial step header */
.view-step-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent-h);
  margin-bottom: 6px;
}


/* ─── Step 2: Variant Grid ─────────────────────────────────── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--red);
  border: 1.5px solid var(--red);
  border-radius: 22px;
  cursor: pointer;
  padding: 10px 20px;
  margin-bottom: 24px;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: 0.2px;
}

.back-btn:hover {
  color: #fff;
  background: #b82528;
  border-color: #b82528;
  box-shadow: 0 4px 16px rgba(216,46,49,0.35);
  transform: translateX(-3px);
}

.back-btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.variant-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transition: all var(--transition);
}

.variant-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,67,103,0.2);
}

.variant-preview {
  width: 100%;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: #ffffff;
  padding: 16px;
  border: 1px solid #e0e4e8;
}

.variant-preview svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.variant-label {
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  color: var(--text);
}

/* ─── Step 3: Customizer ───────────────────────────────────── */
.customizer-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.canvas-panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.canvas-toolbar-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.bg-swatches {
  display: flex;
  gap: 6px;
  align-items: center;
}

.bg-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.bg-swatch:hover, .bg-swatch.active {
  border-color: var(--accent-h);
  transform: scale(1.15);
}

.bg-swatch[data-bg="white"]       { background: #fff; }
.bg-swatch[data-bg="gray-light"]  { background: #d4d4d4; }
.bg-swatch[data-bg="gray-dark"]   { background: #666666; }
.bg-swatch[data-bg="black"]       { background: #000; }
.bg-swatch[data-bg="transparent"] {
  background: repeating-conic-gradient(#aaa 0% 25%, #fff 0% 50%) 0 0 / 10px 10px;
}

.bg-custom {
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bg-custom input[type=color] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border: none;
  padding: 0;
}

.canvas-area {
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  background: #ffffff;
  transition: background var(--transition);
}

.canvas-area svg {
  max-width: 100%;
  max-height: 260px;
  filter: drop-shadow(0 2px 12px rgba(0,0,0,0.3));
}

/* ─── Color Panel ──────────────────────────────────────────── */
.color-panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 120px;
}

.color-panel-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.color-group-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-group-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}

.color-group-row:hover {
  border-color: var(--accent);
  background: var(--surface3);
}

.color-group-row.active {
  border-color: var(--accent-h);
  box-shadow: 0 0 0 2px rgba(0,90,138,0.25);
}

.color-chip {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.color-chip input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  opacity: 0;
  cursor: pointer;
}

.color-group-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}

/* ─── Brand palette ────────────────────────────────────────── */
.palette-section {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

.palette-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  font-weight: 600;
  padding: 0 2px;
}

.palette-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 2px;
}

.palette-swatch {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.palette-swatch:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 2px var(--accent-h);
}

/* ─── Export Bar ───────────────────────────────────────────── */
.export-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 40px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 50;
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: all var(--transition);
}

.export-bar.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.export-bar-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.select-styled {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 12px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

.select-styled:hover, .select-styled:focus {
  border-color: var(--accent);
}

.export-spacer { flex: 1; }

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.3px;
}

.btn-export:hover {
  background: var(--accent-h);
  box-shadow: 0 4px 16px rgba(0,67,103,0.4);
  transform: translateY(-1px);
}

.btn-export:active {
  transform: translateY(0);
}

.btn-export svg { width: 16px; height: 16px; }

/* ─── Animations ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view.active { animation: fadeIn 0.3s ease; }

.bu-card, .variant-card {
  animation: fadeIn 0.25s ease both;
}

/* ─── SVG highlight on hover ───────────────────────────────── */
#svg-canvas svg g[id]:not([id="fixed"]) {
  cursor: pointer;
  transition: filter 0.15s;
}

#svg-canvas svg g[id]:not([id="fixed"]):hover {
  filter: brightness(1.25) drop-shadow(0 0 4px rgba(255,255,255,0.3));
}

#svg-canvas svg g[id].selected {
  filter: brightness(1.1) drop-shadow(0 0 6px rgba(0, 160, 255, 0.6));
}

/* ─── Themes ────────────────────────────────────────────────── */
.themes-section {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

.themes-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  font-weight: 600;
  padding: 0 2px;
}

.theme-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 2px;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.3px;
}

.theme-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface3);
}

.theme-btn.active {
  border-color: var(--accent-h);
  color: var(--text);
  background: rgba(0,67,103,0.2);
}

.theme-btn .theme-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}

/* ─── Pastilla ─────────────────────────────────────────────── */
.pastilla-section {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

.pastilla-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pastilla-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  padding: 0 2px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--surface3);
  transition: .2s;
  border-radius: 20px;
  border: 1.5px solid var(--border);
}

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

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

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

.pastilla-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
  animation: fadeIn 0.2s ease;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text);
}

.control-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  background: transparent;
  width: 100px;
}
.control-row input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.control-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background: var(--text);
  margin-top: -5px;
  cursor: pointer;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  header, .steps-bar, .content, .export-bar { padding-left: 20px; padding-right: 20px; }
  .customizer-layout { grid-template-columns: 1fr; }
  .color-panel { position: static; }
}
