/* ==========================================================================
   NSKOREAN 可视化编辑器界面样式
   仅作用于编辑器外壳，不会写入被编辑页面
   ========================================================================== */

:root {
  --navy: #142b45;
  --navy-2: #1d3a5c;
  --gold: #b89a63;
  --gold-2: #a3854f;
  --slate: #64748b;
  --line: #dbe3ec;
  --bg: #eef2f7;
  --white: #ffffff;
  --danger: #c0392b;
  --success: #1f8a5b;
  --topbar-h: 58px;
  --status-h: 30px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Pretendard Variable", Pretendard, "Noto Sans KR", "Microsoft YaHei",
    "PingFang SC", sans-serif;
  color: var(--navy);
  background: var(--bg);
  overflow: hidden;
}

button,
input {
  font-family: inherit;
}

/* --------------------------------------------------------------------------
   顶部工具栏
   -------------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--navy);
  color: var(--white);
  box-shadow: 0 2px 10px rgba(15, 32, 52, 0.18);
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand__text {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.brand__text small {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.62);
}

.page-loader {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.page-loader label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.page-loader input {
  width: 230px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  font-size: 12px;
  outline: none;
}

.page-loader input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.page-loader input:focus {
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.12);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.toolbar__divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.16);
  margin: 0 4px;
}

.btn {
  height: 32px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}

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

.btn--ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.9);
}

.btn--ghost:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.btn--primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--navy);
}

.btn--primary:hover:not(:disabled) {
  background: var(--gold-2);
  border-color: var(--gold-2);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  background: transparent;
  color: var(--white);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.device-group {
  display: flex;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

.device-btn {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  cursor: pointer;
}

.device-btn.is-active {
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   三栏工作区
   -------------------------------------------------------------------------- */
.workspace {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 300px;
  height: calc(100vh - var(--topbar-h) - var(--status-h));
}

.sidebar {
  background: var(--white);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar--left {
  border-right: 1px solid var(--line);
}

.sidebar--right {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.sidebar__title {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 14px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--slate);
}

.canvas-wrap {
  position: relative;
  min-width: 0;
  background: var(--bg);
}

#gjs {
  height: 100%;
  width: 100%;
}

/* --------------------------------------------------------------------------
   右侧标签页
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
}

.tab {
  flex: 1;
  height: 38px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--slate);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab.is-active {
  color: var(--navy);
  border-bottom-color: var(--gold);
}

.tab-panel {
  display: none;
  flex: 1 1 auto;
  overflow-y: auto;
}

.tab-panel.is-active {
  display: block;
}

/* --------------------------------------------------------------------------
   GrapesJS 外观微调（保留其功能结构）
   -------------------------------------------------------------------------- */
.gjs-editor,
.gjs-editor-cont {
  height: 100%;
  background: var(--bg);
}

.gjs-cv-canvas {
  top: 0;
  width: 100%;
  height: 100%;
  background: #dfe6ef;
}

.gjs-cv-canvas__frames {
  padding: 18px 0;
}

.gjs-frame-wrapper {
  box-shadow: 0 4px 24px rgba(20, 43, 69, 0.16);
}

.gjs-pn-panel {
  display: none;
}

/* 左侧组件块 */
.gjs-blocks-c {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}

.gjs-block {
  width: calc(50% - 4px);
  min-height: 64px;
  margin: 0;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
  color: var(--navy);
  font-size: 11px;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.gjs-block:hover {
  border-color: var(--gold);
  background: #fffaf0;
}

.gjs-block svg {
  fill: var(--slate);
}

/* 右侧样式管理器 */
.gjs-sm-sectors,
.gjs-clm-tags,
.gjs-am-assets {
  background: var(--white);
}

.gjs-sm-sector-title,
.gjs-clm-header {
  font-size: 12px;
  font-weight: 600;
}

.gjs-field {
  font-size: 12px;
}

/* 选中元素高亮使用品牌金色 */
.gjs-selected {
  outline: 2px solid var(--gold) !important;
  outline-offset: -2px;
}

.gjs-hovered {
  outline: 1px dashed var(--gold) !important;
}

/* 预览模式：隐藏侧栏与状态栏，保留顶部按钮以便退出预览 */
body.is-preview .sidebar,
body.is-preview .statusbar {
  display: none;
}

body.is-preview .workspace {
  height: calc(100vh - var(--topbar-h));
  grid-template-columns: 1fr;
}

/* --------------------------------------------------------------------------
   状态栏与提示
   -------------------------------------------------------------------------- */
.statusbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--status-h);
  padding: 0 14px;
  background: var(--white);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--slate);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b6c2d1;
  flex: 0 0 auto;
}

.status-dot.is-loading {
  background: var(--gold);
  animation: pulse 1s ease-in-out infinite;
}

.status-dot.is-ok {
  background: var(--success);
}

.status-dot.is-error {
  background: var(--danger);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.commit-link {
  margin-left: auto;
  color: var(--navy);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--gold);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 46px;
  z-index: 100;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 6px;
  background: var(--navy);
  color: var(--white);
  font-size: 12px;
  line-height: 1.6;
  box-shadow: 0 10px 30px rgba(15, 32, 52, 0.28);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  background: var(--danger);
}

.toast.is-success {
  background: var(--success);
}

/* --------------------------------------------------------------------------
   窄屏适配（编辑器主要面向桌面使用）
   -------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 196px minmax(0, 1fr) 260px;
  }

  .brand__text small {
    display: none;
  }

  .page-loader input {
    width: 170px;
  }
}
