/* ===== Site Editor — J:FRESH (Warm Light Theme) ===== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700;900&family=Noto+Serif+KR:wght@400;700;900&display=swap');

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

:root {
  --bg: #FAF6F1; --bg-panel: #F3EDE4; --bg-card: #FFFFFF;
  --border: rgba(120,90,60,0.1); --border-active: rgba(200,85,61,0.4);
  --text: #2C2418; --text-secondary: #6B5D4F; --text-muted: #9B8E7E;
  --accent: #C8553D; --accent-light: #E8DDD3; --accent-hover: #A8432F;
  --caramel: #C4956A; --olive: #7A8B5C;
  --green: #3D8B37; --amber: #C4850A;
  --left-width: 260px; --right-width: 340px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font-serif: 'Noto Serif KR', Georgia, serif;
  --font-sans: 'Noto Sans KR', -apple-system, sans-serif;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-sans);
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }

/* ===== TOP BAR ===== */
.topbar {
  height: 52px; background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 100; position: relative;
  box-shadow: 0 1px 3px rgba(120,90,60,0.04);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo { height: 24px; filter: brightness(0.2); }
.topbar-title { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); }
.topbar-center {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
}
.save-status {
  font-size: 0.75rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
}
.save-status.saving { color: var(--amber); }
.save-status.saved { color: var(--green); }
.save-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Buttons */
.btn {
  padding: 7px 16px; border-radius: 8px; font-size: 0.8rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  cursor: pointer; transition: all 0.2s;
}
.btn:hover { background: var(--accent-light); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; display: flex;
  align-items: center; justify-content: center; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-secondary); cursor: pointer; font-size: 1rem;
  transition: all 0.2s;
}
.btn-icon:hover { background: var(--accent-light); color: var(--text); }

/* ===== LAYOUT ===== */
.editor-layout {
  display: flex; height: calc(100vh - 52px);
}

/* ===== LEFT SIDEBAR ===== */
.sidebar-left {
  width: var(--left-width); min-width: var(--left-width);
  background: var(--bg-card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-header h3 { font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); letter-spacing: 0.02em; text-transform: uppercase; }

.section-list {
  flex: 1; overflow-y: auto; padding: 8px;
}
.sidebar-divider {
  height: 1px; background: var(--border); margin: 8px 12px;
}
.manage-item .section-info-type { color: var(--accent); }
.section-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 10px;
  cursor: pointer; transition: background 0.15s;
  margin-bottom: 2px; user-select: none;
}
.section-item:hover { background: var(--accent-light); }
.section-item.active { background: rgba(200,85,61,0.08); border: 1px solid var(--border-active); }
.section-item.dragging { opacity: 0.5; }
.section-drag-handle {
  cursor: grab; color: var(--text-muted); font-size: 0.85rem;
  flex-shrink: 0;
}
.section-info { flex: 1; min-width: 0; }
.section-info-name { font-size: 0.82rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-info-type { font-size: 0.7rem; color: var(--text-muted); }
.section-visibility {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border: none; background: none; color: var(--text-muted);
  cursor: pointer; border-radius: 6px; font-size: 0.85rem; flex-shrink: 0;
  transition: color 0.2s;
}
.section-visibility:hover { color: var(--text); background: var(--accent-light); }
.section-visibility.hidden { color: var(--text-muted); opacity: 0.4; }

/* ===== CENTER PREVIEW ===== */
.preview-panel {
  flex: 1; overflow-y: auto; background: var(--bg);
  position: relative;
}
.preview-frame {
  max-width: 1400px; margin: 0 auto;
  min-height: 100%;
}
.preview-section-wrapper {
  position: relative; transition: outline 0.2s;
  outline: 2px solid transparent; outline-offset: -2px;
}
.preview-section-wrapper.selected {
  outline-color: var(--accent);
}
.preview-section-wrapper:hover:not(.selected) {
  outline-color: rgba(200,85,61,0.2);
}
.preview-section-label {
  position: absolute; top: 8px; left: 8px; z-index: 10;
  background: var(--accent); color: #fff;
  font-size: 0.65rem; font-weight: 700; padding: 2px 8px;
  border-radius: 4px; opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
}
.preview-section-wrapper:hover .preview-section-label,
.preview-section-wrapper.selected .preview-section-label { opacity: 1; }

/* ===== RIGHT SIDEBAR ===== */
.sidebar-right {
  width: var(--right-width); min-width: var(--right-width);
  background: var(--bg-card); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}

/* Right tabs */
.right-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.right-tab {
  flex: 1; padding: 10px 0; text-align: center; font-size: 0.78rem;
  font-weight: 600; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.2s;
  background: none; border-top: none; border-left: none; border-right: none;
}
.right-tab:hover { color: var(--text-secondary); }
.right-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Properties panel */
.props-panel {
  flex: 1; overflow-y: auto; padding: 16px;
  display: none;
}
.props-panel.active { display: block; }

.prop-group { margin-bottom: 20px; }
.prop-label {
  font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px;
}
.prop-input {
  width: 100%; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 0.85rem; font-family: inherit;
  transition: border-color 0.2s;
}
.prop-input:focus { outline: none; border-color: var(--accent); }
.prop-textarea {
  min-height: 80px; resize: vertical;
}
.prop-input-row { display: flex; gap: 8px; }

/* Image upload area */
.image-upload-area {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 24px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative; overflow: hidden;
  background: var(--bg);
}
.image-upload-area:hover { border-color: var(--accent); background: rgba(200,85,61,0.03); }
.image-upload-area.has-image { padding: 0; border-style: solid; }
.image-upload-area img {
  width: 100%; height: 160px; object-fit: cover; border-radius: 10px;
}
.image-upload-area .upload-text { color: var(--text-muted); font-size: 0.8rem; }
.image-upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

/* Item list (menu items, value items) */
.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
}
.item-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.item-card-title { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.item-card-actions { display: flex; gap: 4px; }
.item-delete {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border: none; background: none; color: var(--text-muted);
  cursor: pointer; border-radius: 4px; font-size: 0.8rem;
}
.item-delete:hover { color: var(--accent); background: rgba(200,85,61,0.08); }

.no-selection {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); font-size: 0.85rem; gap: 8px;
}
.no-selection-icon { font-size: 2rem; opacity: 0.3; }

/* ===== AI CHAT PANEL ===== */
.ai-panel {
  flex: 1; display: none; flex-direction: column;
}
.ai-panel.active { display: flex; }

.ai-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.ai-msg {
  max-width: 90%; padding: 10px 14px; border-radius: 14px;
  font-size: 0.84rem; line-height: 1.6; word-break: break-word;
}
.ai-msg.user {
  align-self: flex-end;
  background: rgba(200,85,61,0.1); color: var(--text);
  border-bottom-right-radius: 4px;
}
.ai-msg.assistant {
  align-self: flex-start;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.ai-msg .apply-btn {
  display: inline-block; margin-top: 8px;
  padding: 4px 12px; border-radius: 6px;
  background: var(--accent); color: #fff;
  font-size: 0.75rem; font-weight: 700;
  cursor: pointer; border: none; transition: opacity 0.2s;
}
.ai-msg .apply-btn:hover { opacity: 0.8; }
.ai-streaming::after {
  content: ''; display: inline-block;
  width: 6px; height: 14px; background: var(--accent);
  margin-left: 4px; animation: blink 0.8s infinite;
  vertical-align: middle;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.ai-input-row {
  padding: 12px; border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}
.ai-input {
  flex: 1; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 0.84rem; font-family: inherit;
}
.ai-input:focus { outline: none; border-color: var(--accent); }
.ai-send {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); border: none; color: #fff;
  cursor: pointer; font-size: 1rem; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  transition: opacity 0.2s;
}
.ai-send:hover { opacity: 0.8; }

/* ===== LOGIN OVERLAY ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-box {
  text-align: center; max-width: 320px; width: 100%; padding: 40px;
}
.login-box h2 { font-size: 1.2rem; margin-bottom: 8px; color: var(--text); }
.login-box p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 24px; }
.login-link {
  display: inline-block; padding: 12px 32px;
  background: var(--accent); color: #fff; border-radius: 10px;
  font-weight: 700; font-size: 0.9rem; transition: opacity 0.2s;
}
.login-link:hover { opacity: 0.9; }

/* ===== VIEWPORT TOGGLE ===== */
.viewport-toggle {
  display: flex; gap: 2px; background: var(--bg); border-radius: 8px;
  padding: 2px; border: 1px solid var(--border);
}
.viewport-btn {
  width: 32px; height: 28px; display: flex; align-items: center; justify-content: center;
  border: none; background: none; border-radius: 6px;
  font-size: 0.85rem; cursor: pointer; color: var(--text-muted);
  transition: all 0.15s;
}
.viewport-btn:hover { color: var(--text); background: var(--accent-light); }
.viewport-btn.active { color: var(--accent); background: var(--bg-card); box-shadow: 0 1px 3px rgba(120,90,60,0.1); }

.preview-panel.viewport-tablet .preview-frame {
  max-width: 768px; margin: 0 auto;
  box-shadow: 0 0 0 1px var(--border);
  background: #fff; min-height: 100%;
}
.preview-panel.viewport-mobile .preview-frame {
  max-width: 375px; margin: 0 auto;
  box-shadow: 0 0 0 1px var(--border);
  background: #fff; min-height: 100%;
}

/* ===== SEO MODAL ===== */
.seo-modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(44,36,24,0.4); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.seo-modal-overlay.show { display: flex; }
.seo-modal {
  background: var(--bg-card); border-radius: 16px; max-width: 520px; width: 100%;
  box-shadow: 0 20px 60px rgba(44,36,24,0.15);
}
.seo-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.seo-modal-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.seo-modal-close {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border: none; background: var(--bg); color: var(--text-muted); border-radius: 6px;
  cursor: pointer; font-size: 1rem; transition: all 0.15s;
}
.seo-modal-close:hover { background: var(--accent); color: #fff; }
.seo-modal-body { padding: 20px 24px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120,90,60,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,90,60,0.22); }
