/* ==========================================================================
   1. Reset + Base
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: system-ui;
}

/* ==========================================================================
   2. #editor-topbar
   ========================================================================== */

#editor-topbar {
  height: 56px;
  background: #1e293b;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #334155;
}

#editor-topbar .btn-back {
  color: #94a3b8;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
}

#editor-topbar .btn-back:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

#editor-topbar .site-name {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  margin-left: 16px;
}

#editor-topbar .site-status {
  font-size: 12px;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 4px;
}

#editor-topbar .site-status.online {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
}

#editor-topbar .btn-preview {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid #475569;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  margin-right: 8px;
}

#editor-topbar .btn-save {
  background: transparent;
  color: #fff;
  border: 1px solid #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  margin-right: 8px;
}

#editor-topbar .btn-publish {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

#editor-topbar .btn-publish:hover {
  background: #1d4ed8;
}

/* ==========================================================================
   3. #editor-main
   ========================================================================== */

#editor-main {
  display: flex;
  height: calc(100vh - 56px - 56px);
  position: relative;
}

/* ==========================================================================
   4. #page-navigator
   ========================================================================== */

#page-navigator {
  width: 220px;
  height: 100%;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
  flex-shrink: 0;
}

#page-navigator .page-nav-header {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e2e8f0;
}

#page-navigator .page-nav-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

#page-navigator .page-count {
  background: #e2e8f0;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  color: #64748b;
}

#page-navigator .page-search {
  padding: 8px 12px;
  border-bottom: 1px solid #e2e8f0;
}

#page-navigator .page-search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}

#page-navigator .page-search input:focus {
  border-color: #2563eb;
}

#page-navigator .page-group-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  user-select: none;
}

#page-navigator .page-group-header:hover {
  background: #f1f5f9;
}

#page-navigator .page-group-count {
  margin-left: auto;
  font-size: 11px;
  color: #94a3b8;
}

#page-navigator .page-group-arrow {
  margin-left: 6px;
  font-size: 10px;
}

#page-navigator .page-thumb-item {
  padding: 6px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: 0.15s;
}

#page-navigator .page-thumb-item:hover {
  background: #f1f5f9;
}

#page-navigator .page-thumb-item.active {
  background: #eff6ff;
  border-left: 3px solid #2563eb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}
#page-navigator .page-thumb-item.active .page-thumb-preview {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
  border-radius: 6px;
}

#page-navigator .page-thumb-preview {
  width: 100%;
  height: 100px;
  border-radius: 6px;
  overflow: hidden;
  background: #e2e8f0;
  margin-bottom: 4px;
  position: relative;
}
#page-navigator .page-thumb-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  display: none;
  z-index: 2;
}
#page-navigator .page-thumb-item:hover .page-thumb-delete {
  display: block;
}
#page-navigator .page-thumb-copy {
  position: absolute;
  bottom: 4px;
  right: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(37,99,235,0.85);
  color: #fff;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  display: none;
  z-index: 2;
  backdrop-filter: blur(4px);
}
#page-navigator .page-thumb-copy:hover {
  background: rgba(37,99,235,1);
}
#page-navigator .page-thumb-item:hover .page-thumb-copy {
  display: block;
}
#page-navigator .page-thumb-add .thumb-add-btn {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #94a3b8;
  border: 2px dashed #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.15s;
}
#page-navigator .page-thumb-add:hover .thumb-add-btn {
  color: #2563eb;
  border-color: #2563eb;
  background: #eff6ff;
}

#page-navigator .thumb-iframe-wrap {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}
#page-navigator .thumb-iframe-wrap iframe {
  width: 1200px;
  height: 800px;
  transform: scale(0.15);
  transform-origin: top left;
  pointer-events: none;
  border: none;
  position: absolute;
  top: 0;
  left: 0;
}
#page-navigator .thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
  padding: 4px;
}

#page-navigator .page-thumb-img {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: top center;
  display: flex;
  align-items: center;
  justify-content: center;
}

#page-navigator .page-thumb-placeholder {
  font-size: 28px;
  line-height: 72px;
  text-align: center;
  width: 100%;
}

#page-navigator .page-thumb-name {
  font-size: 11px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-bottom: 4px;
}

#page-navigator .page-thumb-item.active .page-thumb-name {
  color: #2563eb;
  font-weight: 700;
}

/* ==========================================================================
   5. #editor-canvas
   ========================================================================== */

#editor-canvas {
  flex: 1;
  overflow: hidden;
}

/* ==========================================================================
   6. #editor-bottombar
   ========================================================================== */

#editor-bottombar {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  position: relative;
  z-index: 50;
}

#editor-bottombar .bottombar-tabs {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
}

#editor-bottombar .bottom-tab {
  padding: 10px 24px;
  border: none;
  background: transparent;
  font-size: 14px;
  color: #64748b;
  cursor: pointer;
  border-radius: 8px;
  transition: 0.15s;
}

#editor-bottombar .bottom-tab:hover {
  background: #f1f5f9;
  color: #1e293b;
}

#editor-bottombar .bottom-tab.active {
  background: #eff6ff;
  color: #2563eb;
  font-weight: 600;
}

#editor-bottombar .bottom-panel {
  position: absolute;
  bottom: 56px;
  left: 0;
  right: 0;
  height: 320px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  overflow-y: auto;
  animation: slideUp 0.2s ease;
  z-index: 60;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

#editor-bottombar .panel-header {
  padding: 16px 24px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

#editor-bottombar .panel-header h3 {
  font-size: 16px;
  color: #1e293b;
  margin: 0;
  white-space: nowrap;
}

#editor-bottombar .panel-header p {
  font-size: 13px;
  color: #94a3b8;
  margin: 0;
}

#editor-bottombar .panel-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: none;
  background: #f1f5f9;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  color: #64748b;
}

/* ==========================================================================
   7. Brand form
   ========================================================================== */

.panel-body {
  padding: 20px 24px;
}

.brand-form {
  max-width: 800px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}

.form-group label .required {
  color: #ef4444;
}

.form-group input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 15px;
  color: #1e293b;
  outline: none;
  box-sizing: border-box;
}

.form-group input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder {
  color: #cbd5e1;
}

.logo-upload {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-preview {
  width: 120px;
  height: 48px;
  border: 2px dashed #e2e8f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  color: #94a3b8;
}

.logo-preview:hover {
  border-color: #2563eb;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
}

.btn-apply {
  height: 48px;
  padding: 0 32px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-apply:hover {
  background: #1d4ed8;
}

.apply-hint {
  font-size: 12px;
  color: #94a3b8;
}

/* ==========================================================================
   8. Media library
   ========================================================================== */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.media-grid img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  cursor: grab;
  border: 2px solid transparent;
}

.media-grid img:hover {
  border-color: #2563eb;
}

.media-upload-area {
  border: 2px dashed #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

.btn-upload {
  color: #2563eb;
  background: none;
  border: none;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

/* ==========================================================================
   9. AI assistant buttons
   ========================================================================== */

.ai-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ai-btn {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: 0.15s;
}

.ai-btn:hover {
  border-color: #2563eb;
  background: #f8faff;
}

.ai-btn-icon {
  font-size: 20px;
  margin-bottom: 8px;
}

.ai-btn-text {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.ai-btn-desc {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
  line-height: 1.4;
}

/* ==========================================================================
   10. Text toolbar (floating)
   ========================================================================== */

#text-toolbar {
  position: absolute;
  z-index: 100;
  background: #1e293b;
  border-radius: 8px;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#text-toolbar button {
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
}

#text-toolbar button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 4px;
}

/* ==========================================================================
   11. Image replace button
   ========================================================================== */

#image-replace-btn {
  position: absolute;
  z-index: 100;
  background: #2563eb;
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

#image-replace-btn:hover {
  background: #1d4ed8;
}

/* ==========================================================================
   12. Welcome overlay
   ========================================================================== */

#welcome-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.welcome-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 480px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.welcome-card h2 {
  font-size: 22px;
  color: #1e293b;
  margin-bottom: 8px;
}

.welcome-subtitle {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 20px;
}

.welcome-steps {
  text-align: left;
  margin-bottom: 24px;
}

.welcome-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 15px;
  color: #334155;
}

.step-num {
  width: 28px;
  height: 28px;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.welcome-start {
  width: 100%;
  height: 52px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.welcome-start:hover {
  background: #1d4ed8;
}

/* ==========================================================================
   13. GrapeJS overrides - hide ALL default GrapeJS chrome
   ========================================================================== */

.gjs-pn-panels,
.gjs-pn-views-container,
.gjs-pn-views,
.gjs-pn-commands,
.gjs-cv-dashed,
.gjs-badge,
.gjs-placeholder,
.gjs-toolbar,
.gjs-resizer-h,
.gjs-ghost,
.gjs-highlighter {
  display: none !important;
}

.gjs-frame {
  border: none !important;
}

.gjs-cv-canvas {
  top: 0 !important;
  width: 100% !important;
}
