/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #0c0c0c;
  --bg-panel: #161616;
  --bg-hover: #1e1e1e;
  --bg-active: #252525;
  --border: #2a2a2a;
  --border-light: #333;
  --text: #ffffff;
  --text-dim: #aaaaaa;
  --text-muted: #666666;
  --accent: #6366f1;
  --accent-hover: #818cf8;
}

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

/* ===== HEADER ===== */
.header {
  height: 56px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.divider-v {
  width: 1px;
  height: 24px;
  background: var(--border-light);
}

.page-name-input {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  width: 140px;
  outline: none;
  font-family: inherit;
}

.page-name-input:focus {
  border-color: var(--accent);
}

.device-toggle {
  display: flex;
  background: var(--bg-hover);
  border-radius: 8px;
  padding: 4px;
}

.device-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.device-btn:hover {
  color: var(--text-dim);
}

.device-btn.active {
  background: var(--accent);
  color: var(--text);
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-hover);
  border-radius: 6px;
  padding: 4px;
}

.zoom-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.zoom-btn:hover {
  background: var(--bg-active);
  color: var(--text);
}

.zoom-value {
  color: var(--text-dim);
  font-size: 12px;
  min-width: 44px;
  text-align: center;
}

.header-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s;
}

.header-btn:hover:not(:disabled) {
  background: var(--bg-active);
  color: var(--text);
}

.header-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.publish-btn {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border: none;
  color: var(--text);
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s;
}

.publish-btn:hover {
  filter: brightness(1.1);
}

/* ===== MAIN LAYOUT ===== */
.main {
  display: flex;
  height: calc(100vh - 56px);
}

/* ===== LEFT PANEL ===== */
.left-panel {
  width: 280px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.left-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.left-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 14px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: inherit;
  transition: all 0.15s;
}

.left-tab:hover {
  color: var(--text-dim);
  background: var(--bg-hover);
}

.left-tab.active {
  color: var(--text);
  background: var(--bg-hover);
}

.left-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Accordion */
.accordion {
  margin-bottom: 8px;
}

.accordion-header {
  width: 100%;
  background: var(--bg-hover);
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.accordion-header:hover {
  background: var(--bg-active);
}

.accordion-header .chevron {
  transition: transform 0.2s;
}

.accordion:not(.open) .chevron {
  transform: rotate(-90deg);
}

.accordion-body {
  padding: 12px 0;
  display: none;
}

.accordion.open .accordion-body {
  display: block;
}

/* Section Grid */
.section-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.section-item {
  background: var(--bg-hover);
  border-radius: 8px;
  padding: 16px 8px;
  text-align: center;
  cursor: grab;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.section-item:hover {
  border-color: var(--border-light);
  background: var(--bg-active);
}

.section-item.dragging {
  opacity: 0.5;
  border-color: var(--accent);
}

.section-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  color: var(--text-dim);
}

.section-thumb svg {
  width: 24px;
  height: 24px;
}

.section-label {
  color: var(--text-dim);
  font-size: 11px;
}

/* Element List */
.element-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-hover);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: grab;
  color: var(--text-dim);
  font-size: 13px;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.element-item:hover {
  border-color: var(--border-light);
  background: var(--bg-active);
  color: var(--text);
}

.element-item.dragging {
  opacity: 0.5;
  border-color: var(--accent);
}

.element-icon {
  color: var(--text-muted);
  display: flex;
}

.drag-handle {
  margin-left: auto;
  color: var(--border-light);
}

/* Pages */
.pages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-hover);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.page-item:hover, .page-item.active {
  background: var(--bg-active);
  color: var(--text);
}

.add-page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: none;
  border: 1px dashed var(--border-light);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
}

.add-page-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Theme */
.theme-section {
  margin-bottom: 24px;
}

.theme-title {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.color-swatch {
  aspect-ratio: 1;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.theme-select {
  width: 100%;
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.theme-select:focus {
  border-color: var(--accent);
}

/* ===== CANVAS AREA ===== */
.canvas-wrapper {
  flex: 1;
  background: var(--bg-dark);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  padding: 24px;
}

.canvas-container {
  position: relative;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 30px 100px rgba(0,0,0,0.5);
  width: 100%;
  max-width: 1200px;
  height: calc(100vh - 104px);
  transition: max-width 0.3s;
}

.canvas-container.tablet {
  max-width: 768px;
}

.canvas-container.mobile {
  max-width: 375px;
}

.overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#editorFrame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #fff;
}

/* Drop Overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(99, 102, 241, 0.1);
  border: 2px dashed var(--accent);
  border-radius: 8px;
  z-index: 50;
  pointer-events: none;
  display: none;
  align-items: center;
  justify-content: center;
}

.drop-overlay.visible {
  display: flex;
}

.drop-overlay-text {
  background: var(--accent);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
}

/* ===== STYLE PANEL ===== */
.style-panel {
  width: 320px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
}

.empty-icon {
  margin-bottom: 16px;
  color: var(--text-muted);
}

.empty-icon svg {
  opacity: 0.5;
}

.empty-title {
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-dim);
}

.empty-text {
  font-size: 12px;
  color: var(--text-muted);
}

.panel-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.element-tag {
  background: var(--accent);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s;
}

.close-btn:hover {
  color: var(--text);
}

.element-path {
  padding: 0 16px 12px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.style-groups {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.style-group {
  margin-bottom: 8px;
}

.style-group-header {
  padding: 12px 16px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.style-group-header:hover {
  color: var(--text-dim);
}

.style-group-body {
  display: none;
}

.style-group.open .style-group-body {
  display: block;
}

.style-row {
  display: flex;
  align-items: center;
  padding: 6px 16px;
  gap: 12px;
}

.style-label {
  flex: 0 0 90px;
  font-size: 12px;
  color: var(--text-dim);
}

.style-control {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.style-input {
  flex: 1;
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
}

.style-input:focus {
  border-color: var(--accent);
}

.style-select {
  flex: 1;
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.style-select:focus {
  border-color: var(--accent);
}

.color-picker {
  width: 32px;
  height: 32px;
  padding: 2px;
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
}

.color-hex {
  flex: 1;
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 12px;
  font-family: 'Menlo', 'Monaco', monospace;
  outline: none;
}

.color-hex:focus {
  border-color: var(--accent);
}

.unit-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 20px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Page item icons */
.page-item svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

/* Element icon size */
.element-icon svg {
  width: 18px;
  height: 18px;
}

/* Hint text for double-click */
.style-panel .panel-header::after {
  content: 'Double-click text to edit';
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 400;
}

/* Canvas drag over state */
.canvas-container.drag-over {
  box-shadow: 0 0 0 2px var(--accent), 0 30px 100px rgba(0,0,0,0.5);
}

/* Improve input focus states */
.style-input:focus,
.style-select:focus,
.color-hex:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Number input styling */
input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Smooth transitions */
.style-group-body {
  transition: max-height 0.2s ease-out;
}

.accordion-body {
  transition: max-height 0.2s ease-out;
}
