/* Koodesign — main stylesheet */

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

html, body {
  width: 100%; height: 100%;
  background: #1e1e1f;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── bottom-pill toolbar ──────────────────────────────────────────────────── */
#toolbar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #2c2c2e;
  border: 1px solid #3a3a3c;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 10px;
  z-index: 10;
}

#toolbar .tool-btn {
  background: none; border: none; cursor: pointer;
  color: #ebebf5; border-radius: 6px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-size: 14px;
  transition: background 0.15s;
  flex-shrink: 0;
}
#toolbar .tool-btn:hover  { background: #3a3a3c; }
#toolbar .tool-btn.active { background: #0a84ff; color: #fff; }

/* tool group: main button + chevron */
.tool-group {
  display: flex;
  align-items: center;
  border-radius: 8px;
}
.tool-group .tool-btn {
  border-radius: 6px 0 0 6px;
}
.tool-group .chevron {
  background: none; border: none;
  color: #8e8e93; cursor: pointer;
  width: 14px; height: 32px;
  font-size: 8px; padding: 0;
  border-radius: 0 6px 6px 0;
  display: grid; place-items: center;
  transition: background 0.15s;
}
.tool-group .chevron:hover { background: #3a3a3c; }

#toolbar .sep { width: 1px; height: 24px; background: #3a3a3c; margin: 0 4px; flex-shrink: 0; }

/* ── tool dropdowns ──────────────────────────────────────────────────────── */
.tool-dropdown {
  position: fixed;
  background: #2c2c2e;
  border: 1px solid #3a3a3c;
  border-radius: 10px;
  padding: 4px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
  display: none;
  z-index: 25;
}
.tool-dropdown.open { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #ebebf5;
}
.dropdown-item:hover { background: #3a3a3c; }
.dropdown-item.checked::before { content: "✓"; color: #0a84ff; width: 14px; flex-shrink: 0; }
.dropdown-item:not(.checked)::before { content: ""; width: 14px; display: inline-block; flex-shrink: 0; }
.dropdown-item .d-icon { width: 18px; text-align: center; flex-shrink: 0; }
.dropdown-item .d-label { flex: 1; }
.dropdown-item .d-shortcut { color: #636366; font-size: 11px; }

/* ── left activity bar ───────────────────────────────────────────────────── */
#activity-bar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 44px;
  background: #232325;
  border-right: 1px solid #3a3a3c;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 2px;
  z-index: 12;
}
.ab-btn {
  background: none; border: none;
  color: #8e8e93; cursor: pointer;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.ab-btn:hover  { background: #3a3a3c; color: #ebebf5; }
.ab-link {
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center; font-size: 16px;
  text-decoration: none; flex-shrink: 0; transition: background 0.15s;
}
.ab-link:hover { background: #3a3a3c; }
.ab-btn.active { background: rgba(10,132,255,.18); color: #0a84ff; }
.ab-sep { width: 28px; height: 1px; background: #3a3a3c; margin: 4px 0; }

/* ── left layers panel ───────────────────────────────────────────────────── */
#layers-panel {
  position: fixed;
  top: 0; left: 44px; bottom: 0;
  width: 200px;
  background: #1c1c1e;
  border-right: 1px solid #3a3a3c;
  display: none;
  flex-direction: column;
  z-index: 11;
}
#layers-header {
  padding: 10px 12px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #636366;
  text-transform: uppercase;
  border-bottom: 1px solid #3a3a3c;
  flex-shrink: 0;
}
#layers-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3c transparent;
}
.layer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  color: #c7c7cc;
  -webkit-user-select: none;
  user-select: none;
  border-left: 2px solid transparent;
}
.layer-row:hover { background: #2c2c2e; }
.layer-row.selected { background: rgba(10,132,255,.15); border-left-color: #0a84ff; color: #ebebf5; }
.layer-kind {
  font-size: 10px;
  color: #636366;
  background: #2c2c2e;
  border-radius: 3px;
  padding: 1px 4px;
  flex-shrink: 0;
}
.layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-eye {
  font-size: 11px;
  color: #3a3a3c;
  flex-shrink: 0;
  opacity: 0;
}
.layer-row:hover .layer-eye { opacity: 1; color: #636366; }
.layer-row.hidden-node .layer-eye { opacity: 1; color: #3a3a3c; }
.layer-empty {
  padding: 20px 12px;
  font-size: 12px;
  color: #636366;
  text-align: center;
}

/* ── right properties panel ──────────────────────────────────────────────── */
#props-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 240px;
  background: #1c1c1e;
  border-left: 1px solid #3a3a3c;
  display: none;
  flex-direction: column;
  z-index: 11;
}
#props-header {
  padding: 10px 12px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #636366;
  text-transform: uppercase;
  border-bottom: 1px solid #3a3a3c;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
#props-kind-badge {
  font-size: 10px;
  background: #2c2c2e;
  border-radius: 3px;
  padding: 1px 5px;
  color: #8e8e93;
}
#props-content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3c transparent;
  padding: 8px 0;
}
.props-section {
  padding: 2px 0 6px;
  border-bottom: 1px solid #2c2c2e;
  margin-bottom: 2px;
}
.props-section:last-child { border-bottom: none; }
.props-section-head {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #636366;
  text-transform: uppercase;
  padding: 6px 12px 3px;
}
.prop-row {
  display: flex;
  align-items: center;
  padding: 3px 12px;
  gap: 8px;
  font-size: 12px;
}
.prop-label {
  color: #636366;
  width: 56px;
  flex-shrink: 0;
  font-size: 11px;
}
.prop-value {
  color: #ebebf5;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prop-swatch {
  width: 16px; height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.12);
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
#props-empty {
  padding: 24px 12px;
  font-size: 12px;
  color: #636366;
  text-align: center;
  line-height: 1.6;
}

/* ── right panel mode buttons ────────────────────────────────────────────── */
#panel-modes {
  position: fixed;
  top: 12px; right: 248px;
  display: flex;
  background: #2c2c2e;
  border: 1px solid #3a3a3c;
  border-radius: 8px;
  overflow: hidden;
  z-index: 10;
}
.mode-btn {
  background: none; border: none;
  color: #8e8e93;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  border-right: 1px solid #3a3a3c;
  transition: background 0.15s, color 0.15s;
}
.mode-btn:last-child { border-right: none; }
.mode-btn.active { color: #0a84ff; background: rgba(10,132,255,.15); }
.mode-btn:hover:not(.active) { background: #3a3a3c; }

/* ── canvas fills the viewport (inset by sidebars) ───────────────────────── */
#kd-canvas {
  position: fixed;
  top: 0; bottom: 0;
  left: 244px; /* 44px activity-bar + 200px layers-panel */
  right: 240px;
  display: block;
  width: auto; height: 100%;
  touch-action: none;
}

/* ── loading overlay ─────────────────────────────────────────────────────── */
#loading {
  position: fixed; inset: 0;
  background: #1e1e1f;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  z-index: 100;
  transition: opacity 0.4s;
}
#loading.hidden { opacity: 0; pointer-events: none; }
#loading .logo { font-size: 28px; font-weight: 700; color: #ebebf5; letter-spacing: -0.5px; }
#loading .logo span { color: #0a84ff; }
#loading .status { font-size: 13px; color: #8e8e93; }
#loading .spinner {
  width: 32px; height: 32px;
  border: 3px solid #3a3a3c;
  border-top-color: #0a84ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── error banner ────────────────────────────────────────────────────────── */
#error-banner {
  position: fixed; top: 52px; left: 50%; transform: translateX(-50%);
  background: #ff3b30; color: #fff;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; display: none; z-index: 20;
}

/* ── Resources Panel ─────────────────────────────────────────────────────── */
#resources-panel {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  width: 340px;
  max-height: 500px;
  background: #2c2c2e;
  border: 1px solid #3a3a3c;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,.7);
  display: flex;
  flex-direction: column;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
#resources-panel.open {
  opacity: 1;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

/* search */
#rp-search-wrap {
  padding: 10px 10px 0;
  position: relative;
}
#rp-search {
  width: 100%;
  background: #3a3a3c;
  border: none;
  border-radius: 8px;
  color: #ebebf5;
  font-size: 13px;
  padding: 7px 10px 7px 30px;
  outline: none;
}
#rp-search::placeholder { color: #636366; }
.rp-search-icon {
  position: absolute;
  left: 20px; top: 50%;
  transform: translateY(-50%);
  color: #636366; font-size: 12px;
  pointer-events: none;
}

/* tabs */
#rp-tabs {
  display: flex;
  padding: 6px 10px 0;
  border-bottom: 1px solid #3a3a3c;
}
.rp-tab {
  background: none; border: none;
  color: #8e8e93; font-size: 13px;
  padding: 4px 10px 8px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.1s;
}
.rp-tab.active { color: #ebebf5; border-bottom-color: #ebebf5; font-weight: 600; }
.rp-tab:hover:not(.active) { color: #c7c7cc; }

/* content */
#rp-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3c transparent;
}

/* section headings */
.rp-section-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #636366;
  text-transform: uppercase;
  padding: 8px 12px 4px;
}

/* suggestion / recent rows */
.rp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #ebebf5;
}
.rp-row:hover { background: #3a3a3c; }
.rp-row .rp-icon { width: 18px; text-align: center; color: #8e8e93; flex-shrink: 0; font-size: 12px; }
.rp-row .rp-label { flex: 1; }
.rp-row .rp-shortcut { color: #636366; font-size: 11px; }

/* settings rows */
.rp-setting {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  font-size: 13px;
  color: #ebebf5;
  cursor: pointer;
}
.rp-setting:hover { background: #3a3a3c; }
.rp-setting input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: #0a84ff;
  flex-shrink: 0;
  cursor: pointer;
}
.rp-setting .rp-label { flex: 1; }
.rp-setting .rp-shortcut { color: #636366; font-size: 11px; }

/* asset grid */
#rp-asset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 10px;
}
.rp-asset-card {
  background: #3a3a3c;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.1s;
}
.rp-asset-card.selected { border-color: #0a84ff; }
.rp-asset-card:hover:not(.selected) { border-color: #636366; }
.rp-asset-preview {
  width: 100%; aspect-ratio: 1;
  background: #fff;
  display: grid; place-items: center;
  font-size: 28px;
  color: #2c2c2e;
}
.rp-asset-name { font-size: 11px; color: #ebebf5; padding: 4px 6px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-asset-lib  { font-size: 10px; color: #636366; padding: 0 6px 4px;   white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* footer */
#rp-footer {
  padding: 10px 12px;
  border-top: 1px solid #3a3a3c;
  display: none;
  align-items: center;
  gap: 8px;
}
#rp-footer.visible { display: flex; }
.rp-community-link { font-size: 12px; color: #636366; flex: 1; cursor: pointer; }
.rp-community-link:hover { color: #8e8e93; }
#rp-insert-btn {
  background: #0a84ff; color: #fff;
  border: none; border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
#rp-insert-btn:disabled { opacity: 0.4; cursor: default; }
#rp-insert-btn:not(:disabled):hover { background: #0070d6; }

/* plugin rows */
.rp-plugin-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.rp-plugin-row:hover { background: #3a3a3c; }
.rp-plugin-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: #636366;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.rp-plugin-body { flex: 1; min-width: 0; }
.rp-plugin-name { font-size: 13px; color: #ebebf5; font-weight: 500; }
.rp-plugin-desc { font-size: 11px; color: #8e8e93; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-plugin-meta { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; align-items: center; }
.rp-badge { font-size: 10px; color: #8e8e93; background: #3a3a3c; border-radius: 4px; padding: 1px 5px; }
.rp-badge.iap { color: #ff9500; }
.rp-plugin-more { background: none; border: none; color: #636366; cursor: pointer; font-size: 16px; padding: 0 4px; align-self: center; }
.rp-plugin-more:hover { color: #ebebf5; }

/* plugin filter bar */
#rp-plugin-filter-bar {
  display: flex; justify-content: flex-end;
  padding: 4px 12px 2px;
}
#rp-plugin-filter {
  background: #3a3a3c; border: none; border-radius: 6px;
  color: #ebebf5; font-size: 12px; padding: 3px 8px;
  cursor: pointer;
}

/* ── export panel (Figma-style presets + handoff) ─────────────────────────── */
#export-panel { border-top: 1px solid #3a3a3c; padding: 10px 12px 14px; font-size: 12px; color: #ebebf5; max-height: 52%; overflow-y: auto; }
#export-panel .ex-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #8e8e93; }
#export-panel .ex-add { background: none; border: 0; color: #ebebf5; font-size: 16px; cursor: pointer; width: 22px; height: 22px; border-radius: 5px; }
#export-panel .ex-add:hover, #export-panel .ex-del:hover { background: #3a3a3c; }
#export-panel .ex-row { display: grid; grid-template-columns: 1fr 1fr 1.1fr 22px; gap: 4px; margin-bottom: 4px; }
#export-panel select, #export-panel input { min-width: 0; background: #2c2c2e; color: #ebebf5; border: 1px solid #3a3a3c; border-radius: 5px; padding: 4px 5px; font: inherit; }
#export-panel .ex-del { background: none; border: 0; color: #8e8e93; cursor: pointer; border-radius: 5px; }
#export-panel .ex-btn { display: block; width: 100%; margin-top: 6px; padding: 7px; border-radius: 6px; border: 1px solid #3a3a3c; background: #2c2c2e; color: #ebebf5; cursor: pointer; font: inherit; }
#export-panel .ex-btn:hover { background: #3a3a3c; }
#export-panel .ex-btn.primary { background: #0a84ff; border-color: #0a84ff; color: #fff; }
#export-panel .ex-btn:disabled { opacity: .5; cursor: default; }
#export-panel .ex-sec { margin-top: 12px; }
#export-panel .ex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
#export-panel .ex-grid .ex-btn { margin-top: 0; }
#export-panel .ex-opt { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: #aeaeb2; }
#export-panel .ex-note { color: #8e8e93; margin-top: 6px; line-height: 1.4; }
