/* ═══════════════════════════════════════════════════════
   SVG Workspace — Split Layout + 4 Mode System
   Dark theme matching Pratilac UI
   ═══════════════════════════════════════════════════════ */

/* ── Workspace panel: hidden by default ── */
.svg-workspace {
  display: none;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  background: #0f172a;
  border-left: 1px solid #1e293b;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

/* ── Split layout: 3-column when workspace is active ── */
.app.svg-ws-active {
  display: flex;
  min-height: 100vh;
}
.app.svg-ws-active .main {
  flex: 1 1 40%;
  min-width: 320px;
}
.app.svg-ws-active .svg-workspace {
  display: flex;
  flex: 1 1 50%;
  min-width: 400px;
}

/* ── Toolbar ── */
.svg-ws-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.svg-ws-modes {
  display: flex;
  gap: 4px;
}

.svg-ws-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Mode buttons (pill style) ── */
.svg-ws-mode {
  padding: 5px 12px;
  border: 1px solid #334155;
  border-radius: 20px;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.svg-ws-mode:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #e2e8f0;
  border-color: #3b82f6;
}
.svg-ws-mode.active {
  background: #3b82f6;
  color: #ffffff;
  border-color: #3b82f6;
}

/* ── Small icon buttons ── */
.svg-ws-btn {
  padding: 4px 8px;
  border: 1px solid #334155;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.svg-ws-btn:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #e2e8f0;
}

/* Close button red accent */
.svg-ws-close {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}
.svg-ws-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: #ef4444;
}

/* ── Zoom label ── */
.svg-ws-zoom-label {
  font-size: 11px;
  color: #64748b;
  font-family: 'Courier New', monospace;
  min-width: 40px;
  text-align: center;
  padding: 0 4px;
}

/* ── Status bar ── */
.svg-ws-status {
  padding: 3px 10px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  color: #64748b;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Body: canvas + inspector side by side ── */
.svg-ws-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Canvas area ── */
.svg-ws-canvas {
  flex: 1;
  overflow: hidden;
  background: #1a1a2e;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── SVG wrapper (transform target) ── */
.svg-ws-svg-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transition: transform 0.08s ease-out;
  transform-origin: center center;
}
.svg-ws-svg-wrapper svg {
  max-width: 100%;
  max-height: 100%;
}

/* ── Inspector panel ── */
.svg-ws-inspector {
  width: 280px;
  min-width: 240px;
  max-width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-left: 1px solid #1e293b;
  background: #0f172a;
  color: #cbd5e1;
  font-size: 12px;
}

.svg-ws-insp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid #1e293b;
  font-size: 12px;
  color: #e2e8f0;
  flex-shrink: 0;
}

.svg-ws-insp-close {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}
.svg-ws-insp-close:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.svg-ws-insp-body {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.svg-ws-insp-hint {
  color: #475569;
  font-style: italic;
  text-align: center;
  padding: 20px 10px;
  font-size: 12px;
}

/* ── Inspector table ── */
.svg-ws-insp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.svg-ws-insp-table td {
  padding: 3px 6px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.6);
  vertical-align: top;
  word-break: break-all;
}
.svg-ws-insp-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}
.svg-ws-insp-table td:first-child {
  color: #64748b;
  white-space: nowrap;
  width: 85px;
  font-weight: 500;
}
.svg-ws-insp-table td code {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Section header rows */
.svg-ws-insp-section td {
  background: #1e293b !important;
  color: #3b82f6;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 5px 6px 3px;
  border-bottom: 1px solid #334155;
}

/* Color swatch inline */
.svg-ws-color-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  vertical-align: middle;
  margin-right: 4px;
}

/* Warning text */
.svg-ws-warn {
  color: #f87171 !important;
  font-weight: 600;
}

/* ── Edit actions grid ── */
.svg-ws-edit-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 8px 0;
  margin-top: 8px;
  border-top: 1px solid #1e293b;
}
.svg-ws-edit-actions button {
  padding: 5px 8px;
  border: 1px solid #334155;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.svg-ws-edit-actions button:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #e2e8f0;
  border-color: #3b82f6;
}

/* ── SVG element highlights ── */
.svg-ws-hover {
  outline: 1.5px dashed cyan !important;
  outline-offset: 2px;
  cursor: pointer;
}
.svg-ws-selected {
  outline: 2px solid #facc15 !important;
  outline-offset: 2px;
}
.svg-ws-edit-selected {
  outline: 2px solid #f97316 !important;
  outline-offset: 2px;
}

/* ── Open Workspace button (topbar) ── */
.svg-ws-open-btn {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.svg-ws-open-btn:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #bfdbfe;
  border-color: #3b82f6;
}

/* ── Animate bar ── */
.svg-ws-animate-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #1e293b;
  border-top: 1px solid #334155;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.svg-ws-animate-bar select {
  padding: 4px 8px;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════
   PIPE FLOW ANIMATION
   ═══════════════════════════════════════════════════════ */

@keyframes pipeFlow {
  from { stroke-dashoffset: 20; }
  to { stroke-dashoffset: 0; }
}

.svg-ws-pipe-animated {
  stroke-dasharray: 10 5 !important;
  animation: pipeFlow 0.8s linear infinite;
}

/* Blocked flow: red dashed, no animation */
.svg-ws-flow-blocked {
  stroke: #ef4444 !important;
  stroke-dasharray: 6 4 !important;
  animation: none !important;
  opacity: 0.7;
}

/* Closed valve: red overlay */
.svg-ws-valve-closed {
  fill: rgba(239, 68, 68, 0.3) !important;
  stroke: #ef4444 !important;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE: Stack vertically on narrow screens
   ═══════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════
   TP-SVG-018: Insert Mode
   ═══════════════════════════════════════════════════════ */
.svg-ws-insert-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #1a237e;
    border-bottom: 1px solid #3949ab;
    font-size: 13px;
    color: #e8eaf6;
}
.svg-ws-insert-label {
    flex: 1;
    font-weight: 500;
}
.svg-ws-insert-confirm {
    background: #2e7d32 !important;
    color: #fff !important;
}
.svg-ws-insert-cancel {
    background: #c62828 !important;
    color: #fff !important;
}

/* Draft elements */
.svg-ws-draft-element,
.svg-ws-insert-preview {
    cursor: move;
    opacity: 0.85;
}
.svg-ws-insert-preview {
    animation: draftPulse 1.5s ease-in-out infinite;
}
@keyframes draftPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}
.svg-ws-draft-element circle,
.svg-ws-draft-element rect,
.svg-ws-draft-element polygon {
    stroke-dasharray: 4, 2;
}
.svg-ws-draft-connection {
    opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE: Stack vertically on narrow screens
   ═══════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .app.svg-ws-active {
    flex-direction: column;
  }
  .app.svg-ws-active .main {
    flex: none;
    min-width: unset;
    height: 45vh;
  }
  .app.svg-ws-active .svg-workspace {
    flex: 1;
    min-width: unset;
    width: 100%;
    border-left: none;
    border-top: 1px solid #1e293b;
  }
  .svg-ws-body {
    flex-direction: column;
  }
  .svg-ws-inspector {
    width: 100%;
    max-width: 100%;
    max-height: 200px;
    border-left: none;
    border-top: 1px solid #1e293b;
  }

  .svg-ws-toolbar {
    flex-wrap: wrap;
  }
  .svg-ws-modes {
    flex-wrap: wrap;
  }
}

/* ══════════════════════════════════════════════════════════════════
   TP-SVG-VIEW-CONTRAST (v2, Suadova korekcija): kontrast mijenja SAMO
   POZADINU platna — linije, debljine i boje crteža se NE diraju.
   Režimi: original → bijela pozadina → crna pozadina.
   ══════════════════════════════════════════════════════════════════ */
.svg-white-mode {
  background: #ffffff !important;
}
.svg-black-mode {
  background: #000000 !important;
}

/* ── Resizer: vertikalni stub za promjenu širine prozora ── */
.svg-ws-resizer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: col-resize;
  z-index: 30;
  background: transparent;
  border-left: 1px solid #1e293b;
}
.svg-ws-resizer:hover,
.svg-ws-resizer:active {
  background: rgba(91, 138, 245, 0.35);
  border-left-color: #5b8af5;
}

/* ── Pronađeni simboli ("nađi kuglasti ventil") ── */
.svg-ws-found,
.svg-ws-found * {
  stroke: #e11d2e !important;
}
.svg-ws-found [fill]:not([fill="none"]) {
  fill: #e11d2e !important;
}

/* ══ TP-SVG-EDITOR-TOOLS: paleta alata (lijevi stub, kao Inkscape) ══ */
.svg-ws-body { position: relative; }
.svg-ws-palette {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 4px;
  background: #0b1220;
  border-right: 1px solid #1e293b;
  width: 40px;
  flex: 0 0 40px;
  align-items: center;
  z-index: 25;
}
.svg-ws-tool {
  width: 30px; height: 30px;
  background: #14203a;
  color: #cbd5e1;
  border: 1px solid #1e293b;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.svg-ws-tool:hover { background: #1d2c4f; }
.svg-ws-tool.active { background: #2c4a8a; color: #fff; border-color: #5b8af5; }
.svg-ws-palette input[type="color"] {
  width: 30px; height: 26px; padding: 0; border: 1px solid #1e293b;
  background: transparent; cursor: pointer;
}
.svg-ws-palette input[type="number"] {
  width: 32px; background: #14203a; color: #e2e8f0;
  border: 1px solid #1e293b; border-radius: 4px; font-size: 11px; padding: 2px;
}

/* ══ Panel simbola (kao Inkscape "Simboli") ══ */
.svg-ws-symbol-drawer {
  position: absolute;
  left: 40px; top: 0; bottom: 0;
  width: 240px;
  background: #0f172a;
  border-right: 1px solid #1e293b;
  z-index: 24;
  display: flex;
  flex-direction: column;
}
.svg-ws-drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; color: #e2e8f0; border-bottom: 1px solid #1e293b;
}
.svg-ws-drawer-head button {
  background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 14px;
}
#svgWsSymbolSet {
  margin: 6px 8px; background: #14203a; color: #e2e8f0;
  border: 1px solid #1e293b; border-radius: 4px; padding: 4px; font-size: 12px;
}
.svg-ws-drawer-grid {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  color: #94a3b8;
}
.svg-ws-symbol-item {
  background: #14203a;
  border: 1px solid #1e293b;
  border-radius: 6px;
  cursor: pointer;
  padding: 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: #cbd5e1;
}
.svg-ws-symbol-item svg { width: 52px; height: 40px; }
.svg-ws-symbol-item span {
  font-size: 9px; max-width: 64px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.svg-ws-symbol-item:hover { background: #1d2c4f; }
.svg-ws-symbol-item.active { border-color: #5b8af5; background: #2c4a8a; color: #fff; }
