/* ===== Builder Interface Styles ===== */

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ===== Builder Top Bar ===== */
.builder-topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}
.builder-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1rem;
  margin-right: 8px;
}
.builder-logo-icon {
  width: 30px; height: 30px;
  background: var(--gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.85rem;
}
.topbar-sep { width: 1px; height: 24px; background: var(--border); }
.site-name-input {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  transition: all 0.2s;
  min-width: 150px;
}
.site-name-input:focus {
  border-color: var(--primary);
  background: var(--bg-3);
}
.topbar-actions { display: flex; gap: 6px; align-items: center; }
.tb-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.tb-btn:hover { background: var(--bg-2); color: var(--text); }
.tb-btn.primary { background: var(--gradient); color: white; border-color: transparent; }
.tb-btn.primary:hover { opacity: 0.9; }
.device-btns { display: flex; background: var(--bg-3); border-radius: 8px; padding: 3px; gap: 2px; border: 1px solid var(--border); }
.device-btn {
  width: 32px; height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.device-btn.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.ml-auto { margin-left: auto; }
.undo-redo { display: flex; gap: 2px; }
.history-btn {
  width: 32px; height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.history-btn:hover:not(:disabled) { background: var(--bg-2); color: var(--text); }
.history-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===== Builder Layout ===== */
.builder-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ===== Left Sidebar ===== */
.sidebar-left {
  width: 260px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
}
.s-tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.s-tab span { font-size: 1rem; }
.s-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.sidebar-content { flex: 1; overflow-y: auto; padding: 12px; }
.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sidebar-section { margin-bottom: 16px; }
.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  padding: 8px 4px 6px;
}
.elements-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.element-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  cursor: grab;
  transition: all 0.2s;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  user-select: none;
}
.element-item:hover { background: var(--bg-2); border-color: var(--primary); color: var(--primary); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.15); }
.element-item:active { cursor: grabbing; }
.element-item.dragging { opacity: 0.5; }
.element-icon { font-size: 1.4rem; }
.element-list { display: flex; flex-direction: column; gap: 4px; }
.element-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  cursor: grab;
  transition: all 0.2s;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
}
.element-list-item:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-2); }
.element-list-icon { font-size: 1.1rem; }

/* Mini thumb images for library */
.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.thumb-img {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.thumb-img img { width: 100%; height: 100%; object-fit: cover; }
.thumb-img:hover { border-color: var(--primary); transform: scale(1.03); }

/* ===== Canvas ===== */
.canvas-area {
  flex: 1;
  background: var(--bg-2);
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  position: relative;
}
.canvas-area::-webkit-scrollbar { width: 8px; height: 8px; }
.canvas-area::-webkit-scrollbar-track { background: var(--bg-2); }
.canvas-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.canvas-ruler-top {
  position: sticky;
  top: 0;
  width: 100%;
  height: 20px;
  background: var(--bg-2);
  z-index: 10;
  display: flex;
  align-items: center;
  font-size: 0.65rem;
  color: var(--text-3);
  padding-left: 20px;
  gap: 50px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.canvas-frame {
  background: white;
  box-shadow: 0 0 0 1px #ddd, var(--shadow-lg);
  border-radius: 4px;
  overflow: visible;
  transition: width 0.3s ease;
  position: relative;
  min-height: 600px;
}
.canvas-frame[data-device="desktop"] { width: 100%; max-width: 1200px; }
.canvas-frame[data-device="tablet"] { width: 768px; }
.canvas-frame[data-device="mobile"] { width: 375px; }

/* Drop zone */
.drop-zone {
  min-height: 80px;
  border: 2px dashed transparent;
  border-radius: 8px;
  transition: all 0.2s;
  position: relative;
}
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(99,102,241,0.05);
}
.drop-zone-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-3);
  pointer-events: none;
}

/* Canvas elements */
.canvas-section {
  position: relative;
  min-height: 80px;
}
.canvas-section:hover > .section-controls { opacity: 1; }
.section-controls {
  position: absolute;
  top: 0; right: 0;
  display: flex;
  gap: 4px;
  padding: 6px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
}
.section-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,0.95);
  cursor: pointer;
  font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: all 0.2s;
}
.section-btn:hover { transform: scale(1.1); }
.section-btn.delete:hover { background: #fef2f2; color: #ef4444; }
.section-btn.move { cursor: grab; }
.section-btn.move:active { cursor: grabbing; }

/* Section drag-and-drop feedback */
.canvas-section.is-dragging { opacity: 0.35; }
.canvas-section.drop-above { box-shadow: 0 -3px 0 0 #6366f1; }
.canvas-section.drop-below { box-shadow: 0 3px 0 0 #6366f1; }

.section-controls .sc-label {
  font-size: 0.7rem;
  background: rgba(99,102,241,0.9);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  pointer-events: none;
}
.section-controls .sc-btns {
  display: flex;
  gap: 4px;
}

/* Canvas built elements */
.canvas-hero-preview {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  padding: 60px 40px;
  text-align: center;
  color: white;
}
.canvas-hero-preview h1 { font-size: 2.5rem; font-weight: 900; margin-bottom: 12px; }
.canvas-hero-preview p { font-size: 1.1rem; opacity: 0.9; margin-bottom: 24px; }
.canvas-hero-preview .c-btn {
  display: inline-block; padding: 14px 32px;
  background: white; color: #6366f1;
  border-radius: 12px; font-weight: 700;
}

.canvas-text-preview { padding: 40px; background: white; }
.canvas-text-preview h2 { font-size: 1.8rem; font-weight: 800; color: #0f172a; margin-bottom: 12px; }
.canvas-text-preview p { color: #475569; line-height: 1.7; }

.canvas-image-preview { background: #f1f5f9; display: flex; justify-content: center; padding: 20px; }
.canvas-image-preview img { max-height: 250px; border-radius: 12px; object-fit: cover; }

.canvas-cta-preview { background: #0f172a; padding: 60px 40px; text-align: center; }
.canvas-cta-preview h2 { color: white; font-size: 2rem; font-weight: 800; margin-bottom: 12px; }
.canvas-cta-preview p { color: #94a3b8; margin-bottom: 24px; }
.canvas-cta-preview .c-btn { display: inline-block; padding: 14px 32px; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: white; border-radius: 12px; font-weight: 700; }

.canvas-features-preview { padding: 60px 40px; background: white; }
.canvas-features-preview h2 { text-align: center; font-size: 1.8rem; font-weight: 800; color: #0f172a; margin-bottom: 32px; }
.canvas-features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.canvas-feature-item { background: #f8fafc; border-radius: 12px; padding: 20px; }
.canvas-feature-item .icon { font-size: 1.8rem; margin-bottom: 10px; }
.canvas-feature-item h3 { font-weight: 700; color: #0f172a; margin-bottom: 6px; font-size: 0.95rem; }
.canvas-feature-item p { color: #64748b; font-size: 0.83rem; line-height: 1.5; }

.canvas-nav-preview { background: white; padding: 16px 40px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e2e8f0; }
.canvas-nav-preview .c-logo { font-weight: 900; color: #6366f1; font-size: 1.2rem; }
.canvas-nav-preview .c-links { display: flex; gap: 20px; font-size: 0.85rem; color: #475569; }
.canvas-nav-preview .c-btn-nav { padding: 8px 18px; background: #6366f1; color: white; border-radius: 8px; font-size: 0.82rem; font-weight: 700; }

.canvas-footer-preview { background: #0f172a; padding: 40px; color: white; }
.canvas-footer-preview .f-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }
.canvas-footer-preview .f-title { font-weight: 700; margin-bottom: 12px; font-size: 0.9rem; }
.canvas-footer-preview .f-link { color: #94a3b8; font-size: 0.82rem; margin-bottom: 6px; }
.canvas-footer-preview .f-copy { border-top: 1px solid #1e293b; margin-top: 28px; padding-top: 20px; color: #64748b; font-size: 0.78rem; text-align: center; }

.canvas-products-preview { padding: 60px 40px; background: white; }
.canvas-products-preview h2 { text-align: center; font-size: 1.8rem; font-weight: 800; color: #0f172a; margin-bottom: 32px; }
.products-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* Editable product card */
.product-item { background: #f8fafc; border-radius: 12px; overflow: hidden; position: relative; transition: box-shadow 0.2s; }
.product-item .p-img { height: 140px; background: linear-gradient(135deg, #e2e8f0, #cbd5e1); display: flex; align-items: center; justify-content: center; font-size: 2rem; overflow: hidden; }
.product-item .p-info { padding: 12px 12px 10px; }
.product-item .p-name { font-weight: 700; font-size: 0.88rem; color: #0f172a; margin-bottom: 4px; }
.product-item .p-price { color: #6366f1; font-weight: 800; font-size: 0.95rem; }
.product-item .p-desc { font-size: 0.75rem; color: #64748b; margin-top: 5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-item .p-variants-display { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.p-variant-tag { font-size: 0.68rem; padding: 2px 8px; background: #ede9fe; border-radius: 50px; color: #6366f1; font-weight: 600; }

/* Variant groups on product cards */
.p-variant-group { margin-top: 8px; }
.p-variant-group-name { font-size: 0.7rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.p-variant-options { display: flex; flex-wrap: wrap; gap: 5px; }
.p-variant-btn {
  font-size: 0.72rem; padding: 3px 10px; border-radius: 6px;
  border: 1.5px solid #e2e8f0; background: white; color: #374151;
  cursor: pointer; font-weight: 600; transition: all 0.15s;
}
.p-variant-btn:hover { border-color: #6366f1; color: #6366f1; }
.p-variant-btn.selected { border-color: #6366f1; background: #ede9fe; color: #6366f1; }
.p-variant-color {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid transparent; cursor: pointer;
  display: inline-block; transition: transform 0.15s, box-shadow 0.15s;
}
.p-variant-color:hover { transform: scale(1.15); }
.p-variant-color.selected { border-color: #0f172a; box-shadow: 0 0 0 2px rgba(15,23,42,0.25); }

/* Variant group blocks in editor */
.variant-group-block {
  background: var(--bg-3); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 12px; transition: border-color 0.2s;
}
.variant-group-block:hover { border-color: #6366f1; }

/* Edit button — visible on hover */
.product-editable { cursor: default; }
.product-editable:hover { box-shadow: 0 0 0 2px #6366f1; }
.p-edit-btn {
  position: absolute; top: 8px; right: 8px;
  padding: 5px 10px; border-radius: 7px;
  background: rgba(99,102,241,0.9); backdrop-filter: blur(4px);
  border: none; color: white; font-size: 0.72rem; font-weight: 700;
  cursor: pointer; opacity: 0; transition: opacity 0.2s;
  font-family: inherit; white-space: nowrap;
}
.product-editable:hover .p-edit-btn { opacity: 1; }

/* Add product card */
.p-add-card {
  background: rgba(99,102,241,0.04);
  border: 2px dashed rgba(99,102,241,0.35);
  border-radius: 12px; min-height: 160px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
}
.p-add-card:hover { background: rgba(99,102,241,0.08); border-color: #6366f1; }

/* Variant rows in product editor */
.variant-row { display: flex; gap: 6px; align-items: center; }
.variant-input {
  flex: 1; padding: 8px 11px;
  background: var(--bg-3); border: 1.5px solid var(--border);
  border-radius: 7px; color: var(--text); font-size: 0.83rem;
  font-family: inherit; outline: none; transition: border-color 0.2s;
}
.variant-input:focus { border-color: #6366f1; }
.variant-remove-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid #fca5a5; background: #fef2f2;
  color: #ef4444; cursor: pointer; font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.canvas-contact-preview { padding: 60px 40px; background: #f8fafc; }
.canvas-contact-preview h2 { text-align: center; font-size: 1.8rem; font-weight: 800; color: #0f172a; margin-bottom: 32px; }
.contact-form-preview { max-width: 400px; margin: 0 auto; }
.c-field { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px 14px; font-size: 0.85rem; color: #94a3b8; margin-bottom: 10px; }
.c-submit { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: white; padding: 12px; border-radius: 8px; text-align: center; font-weight: 700; font-size: 0.88rem; }

/* Selected element */
.canvas-section.selected {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Empty canvas */
.empty-canvas {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 16px;
  color: #94a3b8;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  margin: 40px;
  text-align: center;
  padding: 40px;
  transition: all 0.3s;
}
.empty-canvas.drag-over {
  border-color: #6366f1;
  background: rgba(99,102,241,0.03);
  color: #6366f1;
}
.empty-canvas-icon { font-size: 3rem; opacity: 0.5; }
.empty-canvas h3 { font-size: 1.2rem; font-weight: 700; color: #64748b; }
.empty-canvas p { font-size: 0.88rem; }

/* ===== Right Sidebar ===== */
.sidebar-right {
  width: 260px;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.props-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.props-content { flex: 1; overflow-y: auto; padding: 12px; }
.props-content::-webkit-scrollbar { width: 4px; }
.props-content::-webkit-scrollbar-thumb { background: var(--border); }
.props-section { margin-bottom: 20px; }
.props-section-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin-bottom: 10px; }
.prop-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.prop-label { font-size: 0.8rem; color: var(--text-2); font-weight: 500; }
.prop-input {
  width: 120px;
  padding: 5px 8px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
  font-family: inherit;
}
.prop-input:focus { border-color: var(--primary); }
.prop-color-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-palette { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.prop-toggle-row { display: flex; gap: 4px; margin-bottom: 10px; }
.prop-toggle-btn {
  flex: 1;
  padding: 5px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text-3);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.prop-toggle-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.no-selection {
  text-align: center;
  color: var(--text-3);
  font-size: 0.85rem;
  padding: 40px 16px;
  line-height: 1.6;
}
.no-selection .ns-icon { font-size: 2rem; margin-bottom: 12px; opacity: 0.5; }

/* Layers panel */
.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.82rem;
  color: var(--text-2);
}
.layer-item:hover { background: var(--bg-3); }
.layer-item.active { background: rgba(99,102,241,0.1); color: var(--primary); }
.layer-icon { font-size: 0.9rem; }
.layer-drag { margin-left: auto; color: var(--text-3); cursor: grab; }

/* ===== Preview Mode ===== */
.preview-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 50px;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1000;
  display: none;
}
.preview-bar.active { display: flex; }
.preview-bar span { color: #94a3b8; font-size: 0.85rem; }
.preview-close {
  padding: 8px 20px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ===== Product Card Enhancements ===== */
.p-price-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.p-old-price {
  font-size: 0.8rem;
  color: #94a3b8;
  text-decoration: line-through;
}
.p-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  z-index: 2;
}
.p-cart-btn {
  width: 100%;
  margin-top: 10px;
  padding: 9px 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.15s;
}
.p-cart-btn:hover { opacity: 0.88; transform: translateY(-1px); }

/* ===== Image Category Filter ===== */
.img-cat-btn {
  padding: 4px 10px;
  border: 1.5px solid var(--border);
  background: var(--bg-3);
  color: var(--text-2);
  border-radius: 20px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.img-cat-btn:hover { border-color: #6366f1; color: #6366f1; }
.img-cat-btn.active {
  background: #6366f1;
  border-color: #6366f1;
  color: white;
}
