:root {
  --c-red: #e2001a;
  --c-red-dark: #b50015;
  --c-dark: #1c1c1c;
  --c-gray: #6b6b6b;
  --c-light: #f0f0f2;
  --c-border: #e0e0e4;
  --c-white: #fff;
  --toolbar-w: 220px;
  --props-w: 280px;
  --header-h: 60px;
  --font: 'Poppins', Arial, sans-serif;
}

* { box-sizing: border-box; }

.designer-body {
  margin: 0;
  font-family: var(--font);
  background: #2a2a2e;
  color: var(--c-dark);
  overflow: hidden;
  height: 100vh;
}

.designer-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.designer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  height: auto;
  padding: 8px 20px;
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
  gap: 16px;
}

.designer-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 200px;
}

.designer-back {
  font-size: 13px;
  color: var(--c-gray);
  white-space: nowrap;
}

.designer-back:hover { color: var(--c-red); }

.designer-header-left strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
}

.designer-header-left span {
  font-size: 11px;
  color: var(--c-gray);
}

.designer-header-center {
  display: flex;
  gap: 4px;
  background: var(--c-light);
  border-radius: 8px;
  padding: 4px;
}

.side-tab {
  border: none;
  background: transparent;
  padding: 8px 24px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--c-gray);
  transition: 0.15s;
}

.side-tab.active {
  background: var(--c-white);
  color: var(--c-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

.designer-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
  justify-content: flex-end;
}

.header-zoom,
.header-align {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-align {
  padding-left: 10px;
  border-left: 1px solid var(--c-border);
}

.header-align-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--c-gray);
  margin-right: 4px;
}

.header-align-sep {
  width: 1px;
  height: 18px;
  background: var(--c-border);
  margin: 0 4px;
}

.header-align .btn-icon {
  width: 30px;
  height: 30px;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--c-dark);
}

.header-align .btn-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.header-align .btn-icon:hover {
  border-color: var(--c-red);
  color: var(--c-red);
}

#zoomLabel {
  font-size: 12px;
  color: var(--c-gray);
  min-width: 40px;
  text-align: center;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: 1px solid var(--c-border);
  background: var(--c-white);
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { border-color: var(--c-red); color: var(--c-red); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--c-red);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 22px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
}

.btn:hover { background: var(--c-red-dark); }

.btn-outline {
  background: transparent;
  color: var(--c-dark);
  border: 1px solid var(--c-border);
}

.btn-outline:hover {
  border-color: var(--c-red);
  color: var(--c-red);
  background: transparent;
}

.designer-alert {
  background: #fff3cd;
  color: #856404;
  padding: 10px 20px;
  font-size: 13px;
  border-bottom: 1px solid #ffc107;
}

/* Main layout */
.designer-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.designer-toolbar,
.designer-props {
  background: var(--c-white);
  overflow-y: auto;
  flex-shrink: 0;
}

.designer-toolbar {
  width: var(--toolbar-w);
  border-right: 1px solid var(--c-border);
  padding: 16px 14px;
}

.designer-props {
  width: var(--props-w);
  border-left: 1px solid var(--c-border);
  padding: 16px 14px;
}

.designer-toolbar h4,
.designer-props h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--c-gray);
  margin: 0 0 10px;
  font-weight: 600;
}

.designer-toolbar hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 12px 0;
}

.designer-toolbar .toolbar-sub {
  margin-top: 16px;
}

.tool-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  background: var(--c-white);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: 0.15s;
}

.tool-btn:hover,
.tool-btn.active {
  border-color: var(--c-red);
  color: var(--c-red);
  background: #fff5f6;
}

.tool-btn.danger:hover {
  border-color: #c0392b;
  color: #c0392b;
  background: #fdf0ef;
}

.admin-template-hint {
  background: #fff8e6;
  border: 1px solid #ffe08a;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #6b5a2a;
}

.admin-template-hint h4 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.admin-template-hint ol {
  margin: 0 0 8px;
  padding-left: 16px;
}

.admin-template-hint p {
  margin: 0;
  font-size: 11px;
  opacity: 0.85;
}

.template-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.template-item {
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: 0.15s;
}

.template-item:hover,
.template-item.active {
  border-color: var(--c-red);
  background: #fff5f6;
}

/* Color option swatches (MOO-style) */
.designer-color-options {
  margin-bottom: 4px;
}

.designer-props-divider {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 0 0 16px;
}

.designer-color-group {
  margin-bottom: 18px;
}

.designer-color-group h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-dark);
}

.designer-swatch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.designer-swatch-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 10px;
  border: 2px solid var(--c-border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: 0.15s;
  min-height: 72px;
}

.designer-swatch-btn:hover {
  border-color: #ccc;
}

.designer-swatch-btn.active {
  border-color: var(--c-red);
  box-shadow: 0 0 0 2px rgba(226, 0, 26, 0.12);
}

.designer-swatch-chip {
  display: block;
  width: 100%;
  height: 6px;
  border-radius: 999px;
}

.designer-swatch-label {
  font-size: 11px;
  line-height: 1.3;
  color: var(--c-gray);
  font-weight: 500;
}

.props-hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--c-gray);
  line-height: 1.4;
}

/* Canvas area */
.designer-canvas-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 24px;
  background: #2a2a2e;
  background-image:
    linear-gradient(45deg, #333 25%, transparent 25%),
    linear-gradient(-45deg, #333 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #333 75%),
    linear-gradient(-45deg, transparent 75%, #333 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.canvas-stage {
  position: relative;
  transform-origin: center center;
  transition: transform 0.15s ease;
  padding: 56px 18px 54px;
}

.canvas-stage .canvas-container {
  border-radius: 2px;
  position: relative;
  z-index: 1;
  box-shadow: 0 8px 40px rgba(0,0,0,.45);
}

.canvas-stage .canvas-container canvas {
  image-rendering: auto;
}

.guide-callouts {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.guide-callout {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.guide-callout__bubble {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #161618;
  border: 1px solid #3a3a40;
  color: #f2f2f2;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}

.guide-callout__bubble::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.guide-callout__arrow {
  position: relative;
  width: 0;
  margin-left: 13px;
}

.guide-callout__arrow::after {
  content: '';
  position: absolute;
  left: -3.5px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.guide-callout--bleed {
  top: 6px;
  left: 18px;
}

.guide-callout--bleed .guide-callout__bubble {
  border-color: rgba(226, 0, 26, 0.55);
}

.guide-callout--bleed .guide-callout__bubble::before {
  background: #e2001a;
}

.guide-callout--bleed .guide-callout__arrow {
  height: 22px;
  border-left: 1.5px dashed #e2001a;
}

.guide-callout--bleed .guide-callout__arrow::after {
  bottom: -5px;
  border-top: 5px solid #e2001a;
}

.guide-callout--trim {
  top: 6px;
  right: 18px;
  left: auto;
  align-items: flex-end;
}

.guide-callout--trim .guide-callout__bubble {
  border-color: rgba(0, 102, 204, 0.55);
}

.guide-callout--trim .guide-callout__bubble::before {
  background: #0066cc;
}

.guide-callout--trim .guide-callout__arrow {
  height: calc(22px + var(--bleed, 12px));
  margin-left: 0;
  margin-right: 14px;
  border-left: 1.5px solid #0066cc;
  align-self: flex-end;
}

.guide-callout--trim .guide-callout__arrow::after {
  bottom: -5px;
  border-top: 5px solid #0066cc;
}

.guide-callout--safe {
  right: 18px;
  bottom: 6px;
  align-items: flex-end;
}

.guide-callout--safe .guide-callout__bubble {
  border-color: rgba(0, 170, 68, 0.55);
}

.guide-callout--safe .guide-callout__bubble::before {
  background: #00aa44;
}

.guide-callout--safe .guide-callout__arrow {
  height: calc(20px + var(--bleed, 12px) + var(--safe, 10px));
  margin-left: 0;
  margin-right: 14px;
  border-left: 1.5px dashed #00aa44;
  align-self: flex-end;
}

.guide-callout--safe .guide-callout__arrow::after {
  top: -5px;
  border-bottom: 5px solid #00aa44;
}

.canvas-hint {
  margin-top: 16px;
  font-size: 12px;
  color: #aaa;
  text-align: center;
  max-width: 480px;
}

/* Properties panel */
.props-empty {
  font-size: 13px;
  color: var(--c-gray);
  padding: 12px 0;
}

.props-panel .form-group {
  margin-bottom: 12px;
}

.props-panel label {
  display: block;
  font-size: 12px;
  color: var(--c-gray);
  margin-bottom: 4px;
}

.props-panel input[type="text"],
.props-panel input[type="number"],
.props-panel select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
}

.props-panel input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-group { flex: 1; }

.radius-all {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.radius-all span:first-child {
  font-size: 11px;
  color: var(--c-gray);
  white-space: nowrap;
}

.radius-all input[type="range"] {
  flex: 1;
  min-width: 0;
}

.radius-all #radiusAllVal {
  min-width: 22px;
  font-size: 12px;
  color: var(--c-dark);
  text-align: right;
}

.radius-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.radius-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--c-gray);
  margin: 0;
}

.radius-grid input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
}

.align-btns {
  display: flex;
  gap: 4px;
}

.align-btns button {
  flex: 1;
  padding: 6px;
  border: 1px solid var(--c-border);
  background: var(--c-white);
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font);
}

.align-btns button:hover,
.align-btns button.active {
  border-color: var(--c-red);
  color: var(--c-red);
}

.layers-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}

.layers-empty {
  margin: 0;
  font-size: 12px;
  color: var(--c-gray);
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 6px;
  border: 1px solid var(--c-border);
  border-radius: 7px;
  background: var(--c-white);
  cursor: pointer;
}

.layer-item:hover {
  border-color: #ccc;
}

.layer-item.active {
  border-color: var(--c-red);
  background: #fff5f6;
}

.layer-item.is-hidden .layer-name {
  color: var(--c-gray);
  text-decoration: line-through;
}

.layer-eye,
.layer-move {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  color: var(--c-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.layer-eye svg,
.layer-move svg {
  width: 14px;
  height: 14px;
  display: block;
}

.layer-eye:hover,
.layer-move:hover {
  background: var(--c-light);
  color: var(--c-red);
}

.layer-item.is-hidden .layer-eye {
  opacity: 0.4;
}

.layer-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-move:disabled {
  opacity: 0.3;
  cursor: default;
}

.props-help {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
}

.props-help ul {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: var(--c-gray);
  line-height: 1.8;
}

/* Saving state */
.designer-saving .btn { opacity: 0.7; pointer-events: none; }

.mockup-modal {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.mockup-modal[hidden] { display: none; }
.mockup-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.78);
}
.mockup-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  background: #111;
  border: 1px solid #333;
  color: #e4e4e4;
}
.mockup-modal__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #333;
  font-family: Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
}
.mockup-modal__close {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.mockup-modal__body {
  padding: 16px;
  text-align: center;
}
.mockup-modal__body img {
  width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
  display: block;
  background: #0a0a0a;
}
.mockup-modal__body p {
  margin: 12px 0 0;
  font-size: 12px;
  color: #999;
}

@media (max-width: 900px) {
  .designer-toolbar,
  .designer-props { display: none; }
  .designer-header-left span { display: none; }
}
