/* zdoc/styles.css — Professional SaaS editor UI
 *
 * Layout:
 *   ┌──────────────────────────────────────────────────┐
 *   │ TOOLBAR (top)                                    │
 *   ├────────────────────────────┬─────────────────────┤
 *   │                            │                     │
 *   │   VIEWPORT (canvas)        │  RIGHT PANEL         │
 *   │   - page(s) render here    │   - Properties      │
 *   │   - objects are positioned  │   - Layers          │
 *   │   - selection overlay       │                     │
 *   │                            │                     │
 *   ├────────────────────────────┴─────────────────────┤
 *   │ PAGES BAR (bottom — page thumbnails)             │
 *   └──────────────────────────────────────────────────┘
 */

/* ── Container ─────────────────────────────────────────────────────────── */
.zdoc-editor {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  min-height: 500px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  position: relative;
}

/* ── Top toolbar ──────────────────────────────────────────────────────── */
.zdoc-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.zdoc-tb-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
  border-right: 1px solid var(--border);
}
.zdoc-tb-group:last-of-type { border-right: none; }

.zdoc-tool {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}
.zdoc-tool:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.zdoc-tool:active { transform: scale(0.96); }
.zdoc-tool.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.zdoc-zoom-select {
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 0 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.zdoc-save-status {
  font-size: 11px;
  color: var(--text3);
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--surface2);
  min-width: 80px;
  text-align: center;
}
.zdoc-save-status.zdoc-save-saving { color: var(--blue); background: rgba(10,132,255,0.1); }
.zdoc-save-status.zdoc-save-saved { color: var(--green); background: rgba(48,209,88,0.1); }
.zdoc-save-status.zdoc-save-failed { color: var(--red); background: rgba(255,69,58,0.1); }
.zdoc-save-status.zdoc-save-retrying { color: var(--orange); background: rgba(255,159,10,0.1); }

/* ── Workspace (viewport + right panel) ──────────────────────────────── */
.zdoc-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Viewport (canvas area) ──────────────────────────────────────────── */
.zdoc-viewport {
  flex: 1;
  overflow: auto;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.02) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.02) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.02) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.02) 75%),
    var(--bg);
  background-size: 24px 24px, 24px 24px, 24px 24px, 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  position: relative;
  cursor: default;
}
.zdoc-viewport:active { cursor: default; }

.zdoc-pages {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ── Page (the document canvas) ───────────────────────────────────────── */
.zdoc-page {
  position: relative;
  background: #ffffff;
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
  flex-shrink: 0;
  overflow: hidden;
  transform-origin: top left;
}

/* ── Object (base) ────────────────────────────────────────────────────── */
.zdoc-obj {
  position: absolute;
  cursor: move;
  user-select: none;
  box-sizing: border-box;
}
.zdoc-obj.zdoc-selected {
  outline: 1px solid var(--blue);
}
.zdoc-obj.zdoc-locked { cursor: default; opacity: 0.7; }
.zdoc-obj:hover:not(.zdoc-selected):not(.zdoc-locked) {
  outline: 1px dashed rgba(10,132,255,0.5);
}

/* ── Selection box + handles ──────────────────────────────────────────── */
.zdoc-selection-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}
.zdoc-sel-box {
  position: absolute;
  border: 1.5px solid var(--blue);
  pointer-events: auto;
  box-shadow: 0 0 0 1px rgba(10,132,255,0.2);
}
.zdoc-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1.5px solid var(--blue);
  border-radius: 50%;
  z-index: 10000;
  pointer-events: auto;
}
.zdoc-handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.zdoc-handle-n  { top: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.zdoc-handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.zdoc-handle-e  { top: 50%; right: -5px; transform: translateY(-50%); cursor: ew-resize; }
.zdoc-handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.zdoc-handle-s  { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.zdoc-handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.zdoc-handle-w  { top: 50%; left: -5px; transform: translateY(-50%); cursor: ew-resize; }
.zdoc-handle-rotate {
  top: -32px; left: 50%; transform: translateX(-50%);
  width: 18px; height: 18px;
  background: var(--blue);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: grab;
}
.zdoc-handle-rotate:active { cursor: grabbing; }
.zdoc-handle-rotate::before {
  content: '';
  position: absolute;
  top: 18px; left: 50%;
  width: 1.5px; height: 14px;
  background: var(--blue);
  transform: translateX(-50%);
}

/* ── Right panel (properties + layers) ────────────────────────────────── */
.zdoc-right-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.zdoc-panel-section {
  border-bottom: 1px solid var(--border);
  padding: 12px;
}
.zdoc-panel-section h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.zdoc-panel-section h4 i { color: var(--blue); }
.zdoc-layer-count {
  background: var(--surface2);
  color: var(--text3);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  margin-left: auto;
}

.zdoc-panel-body { font-size: 12px; }
.zdoc-prop-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.zdoc-prop-row label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.zdoc-prop-row input, .zdoc-prop-row select, .zdoc-prop-row textarea {
  width: 100%;
  padding: 4px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}
.zdoc-prop-row input[type="color"] {
  height: 28px;
  padding: 2px;
  cursor: pointer;
}
.zdoc-prop-row input[type="range"] {
  padding: 0;
  height: 24px;
}
.zdoc-prop-row textarea { resize: vertical; min-height: 50px; }

.zdoc-empty {
  color: var(--text3);
  font-size: 12px;
  text-align: center;
  padding: 20px 8px;
  font-style: italic;
}

/* ── Layer list ───────────────────────────────────────────────────────── */
.zdoc-layer-list {
  max-height: 350px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.zdoc-layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.12s;
}
.zdoc-layer-row:hover { background: rgba(255,255,255,0.06); }
.zdoc-layer-row.active {
  border-color: var(--blue);
  background: rgba(10,132,255,0.12);
}
.zdoc-layer-icon {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  color: var(--text3);
  flex-shrink: 0;
}
.zdoc-layer-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text2);
}
.zdoc-layer-actions {
  display: flex;
  gap: 2px;
}
.zdoc-layer-actions button {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
}
.zdoc-layer-actions button:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.zdoc-layer-actions .del:hover { color: var(--red); }

/* ── Pages bar (bottom) ──────────────────────────────────────────────── */
.zdoc-pages-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  overflow-x: auto;
  flex-shrink: 0;
}
.zdoc-pages-bar-inner {
  display: flex;
  gap: 8px;
  align-items: center;
}
.zdoc-page-thumb {
  width: 50px;
  height: 70px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.zdoc-page-thumb:hover { border-color: var(--blue); }
.zdoc-page-thumb.active { border-color: var(--blue); background: rgba(10,132,255,0.05); }
.zdoc-page-thumb-num {
  font-size: 14px;
  font-weight: 700;
  color: var(--text3);
}
.zdoc-page-thumb.active .zdoc-page-thumb-num { color: var(--blue); }
.zdoc-page-del {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 9px;
  display: none;
  align-items: center;
  justify-content: center;
}
.zdoc-page-thumb:hover .zdoc-page-del { display: flex; }
.zdoc-page-del:disabled { background: var(--surface2); cursor: not-allowed; opacity: 0.4; }
.zdoc-page-add {
  width: 50px;
  height: 70px;
  background: var(--surface2);
  border: 2px dashed var(--border);
  border-radius: 6px;
  color: var(--text3);
  cursor: pointer;
  font-size: 18px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.zdoc-page-add:hover { border-color: var(--blue); color: var(--blue); }

/* ── Table object ─────────────────────────────────────────────────────── */
.zdoc-table { border-collapse: collapse; }
.zdoc-table td {
  border: 1px solid #ccc;
  padding: 2px 4px;
  font-size: 12px;
  vertical-align: top;
}

/* ── Mobile responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .zdoc-right-panel { width: 240px; }
  .zdoc-tool { width: 32px; height: 32px; font-size: 12px; }
  .zdoc-toolbar { padding: 6px 8px; gap: 4px; }
  .zdoc-tb-group { gap: 2px; padding-right: 4px; }
}
@media (max-width: 600px) {
  .zdoc-right-panel { display: none; }
  .zdoc-toolbar { overflow-x: auto; flex-wrap: nowrap; }
  .zdoc-pages { padding: 10px; }
}
