* { box-sizing: border-box; }
body { margin: 0; padding: 0; font-family: Arial, sans-serif; background: #f5f5f5; overflow: hidden; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #888; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ==================== HEADER ==================== */
#header {
  background: #fff;
  border-bottom: 3px solid #f59e0b;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.header-logo { display: flex; align-items: center; gap: 10px; }
.back-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #e5e7eb;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #6b7280;
}
.back-btn:hover { background: #f3f4f6; }
.header-title { font-size: 18px; font-weight: 700; color: #111; }
.header-divider { width: 2px; height: 30px; background: #f59e0b; margin: 0 12px; }
.header-product { font-size: 12px; color: #6b7280; }
.header-product strong { color: #111; display: block; font-size: 13px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.btn-save, .btn-continue {
  background: #f97316; color: #fff; border: none;
  padding: 8px 18px; border-radius: 6px;
  font-weight: 700; cursor: pointer; font-size: 13px;
}
.btn-save:hover, .btn-continue:hover { background: #ea580c; }
.btn-help {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid #d1d5db;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #6b7280; background: #fff;
  font-weight: 700; font-size: 14px;
}

/* ==================== LAYOUT ==================== */
#main-layout { display: flex; height: calc(100vh - 52px); }

/* ==================== LEFT SIDEBAR ==================== */
#icon-sidebar {
  width: 56px; background: #1a1a2e;
  display: flex; flex-direction: column;
  align-items: center; padding: 8px 0;
  gap: 2px; z-index: 50;
  flex-shrink: 0;
}
.icon-btn {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  width: 48px; height: 52px; border-radius: 8px;
  cursor: pointer; color: #9ca3af;
  transition: all 0.2s; gap: 2px;
  border: none; background: transparent;
}
.icon-btn:hover, .icon-btn.active {
  background: rgba(255,255,255,0.15); color: #fff;
}
.icon-btn i { font-size: 16px; }
.icon-btn span { font-size: 9px; text-align: center; line-height: 1.1; }

/* ==================== PANEL ==================== */
#panel-container {
  width: 0; overflow: hidden;
  transition: width 0.3s ease;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  z-index: 40; height: 100%;
  flex-shrink: 0;
}
#panel-container.open { width: 300px; overflow-y: auto; }
.panel { padding: 16px; display: none; }
.panel.active { display: block; }
.panel-header {
  display: flex; align-items: center;
  margin-bottom: 12px;
}
.panel-title { font-size: 16px; font-weight: 700; color: #111; flex: 1; }
.panel-close {
  width: 28px; height: 28px; border: none;
  background: none; cursor: pointer;
  color: #6b7280; font-size: 18px; margin-left: auto;
}
.panel-close:hover { color: #111; }
.panel-desc { font-size: 12px; color: #6b7280; margin-bottom: 12px; }

/* ==================== FORM ELEMENTS ==================== */
.form-group { margin-bottom: 12px; }
.form-row { display: flex; gap: 8px; margin-bottom: 8px; }
.form-label { font-size: 11px; color: #6b7280; font-weight: 600; display: block; margin-bottom: 4px; }
.font-select {
  width: 100%; border: 1px solid #d1d5db;
  border-radius: 6px; padding: 6px 10px;
  margin-bottom: 0; font-size: 13px;
  background: #fff;
}
.color-input {
  width: 36px; height: 36px; border: none;
  cursor: pointer; border-radius: 4px;
  border: 1px solid #d1d5db;
}
.hex-input {
  border: 1px solid #d1d5db; border-radius: 4px;
  padding: 4px 8px; font-size: 12px; flex: 1;
}
.text-color-row { display: flex; align-items: center; gap: 8px; }
.align-row { display: flex; gap: 4px; }

/* ==================== CONTEXT TOOLBAR ==================== */
#context-toolbar {
  background: #1a1a2e; padding: 6px 12px;
  display: none; flex-wrap: wrap;
  gap: 4px; align-items: center; min-height: 54px;
  overflow-x: auto;
}
#context-toolbar.show { display: flex; }
.toolbar-btn {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4px 8px; border-radius: 4px;
  cursor: pointer; color: #d1d5db;
  border: none; background: transparent;
  gap: 2px; min-width: 44px; flex-shrink: 0;
}
.toolbar-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.toolbar-btn i { font-size: 14px; }
.toolbar-btn span { font-size: 9px; }
.toolbar-btn.danger { color: #ef4444 !important; }
.toolbar-btn.danger:hover { background: rgba(239,68,68,0.15); }
.toolbar-select {
  background: #2d2d4e; color: #fff;
  border: 1px solid #4b5563; border-radius: 4px;
  padding: 3px 6px; font-size: 12px; cursor: pointer;
}
.toolbar-divider {
  width: 1px; height: 32px;
  background: rgba(255,255,255,0.2); margin: 0 4px;
  flex-shrink: 0;
}

/* ==================== CANVAS AREA ==================== */
#canvas-area {
  flex: 1; display: flex;
  flex-direction: column;
  align-items: center; justify-content: center;
  background: #e8e8e8; position: relative;
  overflow: hidden; min-width: 0;
}
#canvas-wrapper {
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.canvas-border {
  border: 2px dashed #93c5fd;
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}
.canvas-border-inner {
  border: 1px dashed rgba(0,150,255,0.4);
  position: absolute; top: 14px; left: 14px; right: 14px; bottom: 14px;
  pointer-events: none;
}

/* Zoom Controls */
#zoom-controls {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 24px;
  padding: 6px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 10;
}
.zoom-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: none; cursor: pointer;
  color: #6b7280;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.zoom-btn:hover { color: #111; background: #f3f4f6; }
#zoom-level { font-size: 13px; color: #374151; font-weight: 500; min-width: 44px; text-align: center; }
.zoom-divider { width: 1px; height: 16px; background: #d1d5db; flex-shrink: 0; }
.zoom-expand, .zoom-info { color: #6b7280; cursor: pointer; font-size: 14px; }
.zoom-expand:hover, .zoom-info:hover { color: #111; }

/* Exit Pattern Button */
#exit-pattern-btn {
  position: absolute; top: 12px; right: 12px;
  background: #fff; border: 1px solid #d1d5db;
  color: #374151; cursor: pointer;
  font-size: 13px; font-weight: 600;
  display: none; align-items: center; gap: 4px;
  z-index: 20; padding: 6px 12px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
#exit-pattern-btn.show { display: flex; }
#exit-pattern-btn:hover { background: #f3f4f6; }

/* ==================== 3D VIEW ==================== */
#view3d-panel {
  width: 360px; background: #c8cdd2;
  position: relative; display: flex;
  flex-direction: column; flex-shrink: 0;
  transition: width 0.3s ease;
  overflow: hidden;
}
#view3d-panel.hidden { width: 0; }
#three-canvas { width: 100%; height: 100%; display: block; }
#btn-hide3d {
  position: absolute; top: 12px; right: 12px;
  background: #0d9488; color: #fff; border: none;
  padding: 6px 14px; border-radius: 6px;
  cursor: pointer; font-size: 12px; font-weight: 600; z-index: 10;
}
#btn-hide3d:hover { background: #0f766e; }
#btn-show3d {
  position: fixed; right: 12px; top: 70px;
  background: #0d9488; color: #fff; border: none;
  padding: 6px 14px; border-radius: 6px;
  cursor: pointer; font-size: 12px; font-weight: 600;
  z-index: 50; display: none;
}
#btn-show3d.show { display: block; }
#btn-show3d:hover { background: #0f766e; }
.view3d-label {
  position: absolute; bottom: 12px; left: 50%;
  transform: translateX(-50%);
  font-size: 11px; color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.3);
  padding: 3px 10px; border-radius: 10px;
  pointer-events: none; white-space: nowrap;
}

/* ==================== CHAT BUTTON ==================== */
#chat-btn {
  position: fixed; bottom: 16px; right: 16px;
  background: #06b6d4; color: #fff; border: none;
  padding: 10px 16px; border-radius: 24px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  z-index: 200; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 12px rgba(6,182,212,0.4);
}
#chat-btn:hover { background: #0891b2; }

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000; display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 12px;
  padding: 32px; max-width: 480px; width: 90%;
  position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 20px; font-weight: 700; color: #111; margin-bottom: 8px; }
.modal-desc { font-size: 13px; color: #6b7280; margin-bottom: 24px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 28px; height: 28px; border: none;
  background: none; cursor: pointer;
  color: #6b7280; font-size: 20px;
}
.modal-close:hover { color: #111; }

/* Product Modal */
.product-option {
  border: 2px solid #e5e7eb; border-radius: 8px;
  padding: 16px; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.product-option:hover, .product-option.selected {
  border-color: #0d9488; background: #f0fdfa;
}
.product-option .check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #d1d5db;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.product-option.selected .check {
  border-color: #0d9488; background: #0d9488; color: #fff;
}
.size-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin-bottom: 16px;
}
.size-btn {
  border: 2px solid #e5e7eb; border-radius: 8px;
  padding: 10px 6px; text-align: center;
  cursor: pointer; transition: all 0.2s;
  font-size: 13px; font-weight: 600; color: #374151;
}
.size-btn:hover, .size-btn.selected {
  border-color: #0d9488; background: #f0fdfa; color: #0d9488;
}
.btn-primary {
  background: #0d9488; color: #fff; border: none;
  padding: 12px 32px; border-radius: 8px;
  font-size: 15px; font-weight: 700;
  cursor: pointer; width: 100%;
}
.btn-primary:hover { background: #0f766e; }

/* ==================== BACKGROUNDS PANEL ==================== */
.palette-header {
  font-size: 12px; color: #374151; font-weight: 600;
  margin-bottom: 8px; display: flex;
  justify-content: space-between; align-items: center;
}
.palette-header a { color: #0d9488; text-decoration: none; font-weight: 600; }
.color-swatch-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch {
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}
.color-swatch:hover { transform: scale(1.2); border-color: #6b7280; }
.color-swatch.selected { border-color: #111 !important; transform: scale(1.2); box-shadow: 0 0 0 2px #fff, 0 0 0 4px #111; }
.color-swatch.no-color {
  background: linear-gradient(135deg, #fff 45%, #ef4444 45%, #ef4444 55%, #fff 55%);
  border: 2px solid #d1d5db;
}
.color-hex-input {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid #d1d5db; border-radius: 6px;
  padding: 6px 10px; margin-bottom: 12px;
}
.color-hex-input input[type=color] {
  width: 28px; height: 28px; border: none;
  outline: none; cursor: pointer;
  border-radius: 4px; padding: 0;
}
.color-hex-input input[type=text] {
  border: none; outline: none;
  font-size: 13px; flex: 1;
}
.big-color-picker {
  width: 80px; height: 80px;
  border: none; cursor: pointer; border-radius: 8px;
}

/* ==================== SHAPES PANEL ==================== */
.shapes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shape-item {
  border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 10px 8px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
  background: #fafafa; min-height: 70px;
}
.shape-item:hover { border-color: #0d9488; background: #f0fdfa; transform: scale(1.03); }
.shape-item svg { width: 36px; height: 36px; }
.shape-item span { font-size: 9px; color: #6b7280; margin-top: 4px; text-align: center; }

/* ==================== PATTERNS PANEL ==================== */
.pattern-cat-filter select {
  width: 100%; border: 1px solid #d1d5db;
  border-radius: 6px; padding: 7px 10px;
  font-size: 13px; background: #fff;
  margin-bottom: 12px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7280' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  cursor: pointer;
}
.patterns-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pattern-item {
  border: 2px solid #e5e7eb; border-radius: 8px;
  overflow: hidden; cursor: pointer;
  aspect-ratio: 1; transition: all 0.2s;
  position: relative;
}
.pattern-item:hover { border-color: #0d9488; box-shadow: 0 0 0 2px #0d9488; }
.pattern-item.selected { border-color: #0d9488; box-shadow: 0 0 0 2px #0d9488; }
.pattern-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slider-wrap {
  background: #2d2d4e; border-radius: 6px;
  padding: 6px 10px; min-width: 120px;
}
.slider-label { font-size: 11px; color: #9ca3af; margin-bottom: 2px; }
input[type=range] { width: 100%; accent-color: #0d9488; margin: 4px 0; cursor: pointer; }

/* ==================== TEXT PANEL ==================== */
.text-format-row { display: flex; gap: 4px; }
.fmt-btn {
  padding: 6px 10px; border: 1px solid #d1d5db;
  border-radius: 4px; cursor: pointer;
  font-size: 13px; background: #fff;
  color: #374151; font-weight: 600;
  transition: all 0.15s;
}
.fmt-btn:hover, .fmt-btn.active {
  background: #0d9488; color: #fff; border-color: #0d9488;
}
.align-btn {
  flex: 1; padding: 8px; border: 1px solid #d1d5db;
  border-radius: 4px; cursor: pointer;
  text-align: center; background: #fff; color: #374151;
  transition: all 0.15s;
}
.align-btn:hover, .align-btn.active {
  background: #0d9488; color: #fff; border-color: #0d9488;
}
.btn-add-text {
  width: 100%; background: #0d9488; color: #fff;
  border: none; padding: 10px; border-radius: 6px;
  font-weight: 700; cursor: pointer;
  margin-top: 8px; font-size: 14px;
}
.btn-add-text:hover { background: #0f766e; }

/* ==================== IMAGES PANEL ==================== */
.upload-area {
  border: 2px dashed #d1d5db; border-radius: 8px;
  padding: 32px 16px; text-align: center;
  cursor: pointer; transition: all 0.2s;
  margin-bottom: 12px;
}
.upload-area:hover { border-color: #0d9488; background: #f0fdfa; }
.upload-area i { font-size: 32px; color: #9ca3af; display: block; margin-bottom: 8px; }
.upload-area p { font-size: 12px; color: #6b7280; margin: 0; }
.btn-upload {
  width: 100%; background: #0d9488; color: #fff;
  border: none; padding: 10px; border-radius: 6px;
  font-weight: 700; cursor: pointer; font-size: 14px;
}
.btn-upload:hover { background: #0f766e; }
.uploaded-images-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; margin-top: 12px;
}
.uploaded-img-thumb {
  border: 1px solid #e5e7eb; border-radius: 6px;
  overflow: hidden; aspect-ratio: 1;
  cursor: pointer; position: relative;
}
.uploaded-img-thumb:hover .img-overlay { opacity: 1; }
.img-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5); opacity: 0;
  transition: opacity 0.2s;
  display: flex; align-items: center;
  justify-content: center; gap: 6px;
}
.img-overlay button {
  background: none; border: 1px solid #fff;
  color: #fff; border-radius: 4px;
  padding: 2px 6px; font-size: 10px; cursor: pointer;
}
.img-overlay button:hover { background: rgba(255,255,255,0.2); }

/* ==================== GRAPHICS PANEL ==================== */
.section-title {
  font-size: 13px; font-weight: 700; color: #374151;
  margin: 12px 0 8px; display: flex; align-items: center; gap: 6px;
}
.graphics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.graphic-item {
  border: 1px solid #e5e7eb; border-radius: 8px;
  overflow: hidden; aspect-ratio: 1;
  cursor: pointer; background: #fafafa;
  display: flex; align-items: center;
  justify-content: center; transition: all 0.2s;
  flex-direction: column; gap: 4px; padding: 8px;
}
.graphic-item:hover { border-color: #0d9488; background: #f0fdfa; }
.graphic-item span { font-size: 9px; color: #6b7280; }

/* ==================== SAVE MODAL ==================== */
.save-option {
  border: 2px solid #e5e7eb; border-radius: 10px;
  padding: 20px; cursor: pointer;
  transition: all 0.2s; text-align: center;
}
.save-option:hover { border-color: #0d9488; background: #f0fdfa; }
.save-option i { font-size: 32px; color: #0d9488; display: block; margin-bottom: 8px; }
.save-option h3 { font-size: 16px; font-weight: 700; color: #111; margin: 0 0 4px; }
.save-option p { font-size: 12px; color: #6b7280; margin: 0; }

/* ==================== WHATSAPP BOX ==================== */
.whatsapp-box {
  background: #25d366; color: #fff;
  border-radius: 12px; padding: 20px;
  text-align: center; margin-top: 16px;
}
.whatsapp-box i { font-size: 36px; display: block; margin-bottom: 8px; }
.whatsapp-box p { margin: 0 0 12px; font-size: 14px; }
.whatsapp-box a {
  background: #fff; color: #25d366;
  padding: 10px 24px; border-radius: 8px;
  text-decoration: none; font-weight: 700;
  font-size: 14px; display: inline-block;
}
.whatsapp-box a:hover { background: #f0fdf4; }

/* ==================== CANVAS INFO ==================== */
.canvas-info-list { font-size: 13px; color: #374151; line-height: 2.2; }

/* ==================== THEMES DROPDOWN ==================== */
#themes-dropdown {
  position: absolute;
  top: 60px;
  left: 120px;
  background: #2d2d2d;
  border-radius: 10px;
  padding: 14px;
  z-index: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  display: none;
  min-width: 320px;
}
#themes-dropdown.show { display: block; }
#themes-dropdown .td-title {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#themes-dropdown .td-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
}
#themes-dropdown .td-close:hover { color: #fff; }
.theme-row {
  display: flex;
  gap: 3px;
  margin-bottom: 4px;
  align-items: center;
}
.theme-swatch-group {
  display: flex;
  gap: 2px;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px;
  transition: background 0.15s;
}
.theme-swatch-group:hover { background: rgba(255,255,255,0.15); }
.theme-swatch-group.active { background: rgba(255,255,255,0.25); outline: 2px solid #0d9488; }
.theme-swatch {
  width: 18px;
  height: 18px;
  border-radius: 2px;
  flex-shrink: 0;
}
.td-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 10px 0;
}
.td-custom-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.td-custom-label {
  color: #9ca3af;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.td-color-pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.td-color-picker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.td-color-picker-item label {
  color: #9ca3af;
  font-size: 9px;
  text-align: center;
}
.td-color-picker-item input[type=color] {
  width: 32px;
  height: 32px;
  border: 2px solid #4b5563;
  border-radius: 6px;
  cursor: pointer;
  padding: 1px;
  background: none;
}
.td-color-picker-item input[type=color]:hover {
  border-color: #0d9488;
}
.td-apply-btn {
  background: #0d9488;
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  width: 100%;
}
.td-apply-btn:hover { background: #0f766e; }
