/* ═══════════════════════════════════════════════════════════════════════════ */
/*  ACM Unfolder — Unified Stylesheet */
/* ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #1a1a1a;
  --surface:   #242424;
  --panel:     #2e2e2e;
  --panel2:    #363636;
  --border:    #404040;
  --border2:   #4a4a4a;
  --text:      #e8e8e8;
  --text2:     #b0b0b0;
  --muted:     #808080;
  --accent:    #4facf7;
  --accent2:   #1a6fb5;
  --red:       #f04848;
  --red2:      #c73232;
  --blue:      #3b82f6;
  --blue2:     #1d4ed8;
  --green:     #22c55e;
  --orange:    #f59e0b;
  --fold-blue: #2563eb;
  --cut-red:   #dc2626;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  display: flex;
  flex-direction: column;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/*  Common Components */
/* ─────────────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border2);
  background: var(--panel);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--panel2);
  border-color: var(--border);
}

.btn:active {
  transform: scale(0.98);
}

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

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn.primary:hover {
  background: var(--accent2);
  border-color: var(--accent2);
}

.btn.danger {
  background: var(--red2);
  color: #fff;
  border-color: var(--red2);
}

.btn.danger:hover {
  background: var(--red);
  border-color: var(--red);
}

.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/*  Header */
/* ─────────────────────────────────────────────────────────────────────────── */

.header {
  height: 52px;
  min-height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

.logo {
  font-family: 'Rajdhani', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.logo em {
  color: var(--text2);
  font-style: normal;
  font-weight: 400;
}

.h-sep {
  width: 1px;
  height: 26px;
  background: var(--border);
  flex-shrink: 0;
}

.file-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.fname {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.fname.ok {
  color: var(--green);
}

.hdr-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text2);
}

.unfolds-remaining {
  font-weight: 600;
  color: var(--green);
}

/* ─────────────────────────────────────────────────────────────────────────── */
/*  Main Container */
/* ─────────────────────────────────────────────────────────────────────────── */

.main-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/*  Model Library Dropdown (Navbar) */
/* ─────────────────────────────────────────────────────────────────────────── */

.model-library-dropdown {
  position: relative;
}

.model-library-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-width: 320px;
  max-width: 400px;
  margin-top: 4px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.model-library-dropdown:hover .model-library-panel {
  display: block;
}

.library-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
}

.library-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.library-item:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.model-thumbnail {
  width: 100px;
  height: 100px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 40px;
  color: var(--muted);
}

.model-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.model-item-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-item-unit {
  font-size: 9px;
  color: var(--text2);
}


.split-panes {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.pane-3d {
  flex: 2.5;
  min-width: 300px;
}

.pane-2d {
  flex: 1.8;
  min-width: 250px;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.pane-library {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.divider {
  width: 8px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s;
}

.divider:hover {
  background: var(--panel);
}

.library-slot {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.library-slot:hover {
  background: var(--panel2);
  border-color: var(--text1);
}

.library-slot.empty {
  opacity: 0.6;
  color: var(--muted);
}

.library-slot-thumbnail {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--muted);
  overflow: hidden;
  position: relative;
}

.library-slot-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-slot-icon {
  position: absolute;
  font-size: 32px;
  color: var(--muted);
}
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 32px;
  overflow: hidden;
}

.library-slot-name {
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text1);
}

.library-slot-info {
  font-size: 9px;
  color: var(--muted);
}

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

.svg-viewer {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: #fff;
  position: relative;
}

.svg-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.svg-controls .btn {
  height: 28px;
  padding: 0 8px;
  font-size: 11px;
}

#svgLayer {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/*  Controls Bar */
/* ─────────────────────────────────────────────────────────────────────────── */

.controls-bar {
  padding: 16px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  flex-shrink: 0;
  min-height: auto;
  max-height: 140px;
  overflow-y: auto;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.control-input {
  width: 70px;
  height: 28px;
  padding: 0 8px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  border-radius: 3px;
  transition: all 0.2s;
}

.control-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}

.main-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn.btn-lg {
  height: 36px;
  padding: 0 20px;
  font-size: 13px;
  font-weight: 600;
}

.control-slider {
  width: 120px;
  height: 4px;
  cursor: pointer;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/*  Status Bar */
/* ─────────────────────────────────────────────────────────────────────────── */

.status-bar {
  padding: 8px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 20px;
  align-items: center;
  flex-shrink: 0;
  font-size: 11px;
  flex-wrap: wrap;
  max-height: 60px;
  overflow-y: auto;
}

.stat-item {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--text2);
}

.stat-item span:first-child {
  font-weight: 500;
}

.stat-v {
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}

.status-msg {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/*  Modals & Toast */
/* ─────────────────────────────────────────────────────────────────────────── */

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-bg.show {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}

.modal-title {
  font-weight: 600;
  font-size: 14px;
}

.modal-body {
  padding: 16px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text2);
}

.modal-body h3 {
  color: var(--text);
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 13px;
}

.modal-body p {
  margin-bottom: 8px;
}

.modal-body code {
  background: var(--panel2);
  color: var(--green);
  padding: 2px 4px;
  border-radius: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.modal-body pre {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  line-height: 1.4;
}

.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  display: none;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast.show {
  display: block;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ─────────────────────────────────────────────────────────────────────────── */
/*  Responsive */
/* ─────────────────────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .split-panes {
    flex-direction: column;
  }

  .pane-2d {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .divider {
    width: 100%;
    height: 8px;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    cursor: row-resize;
  }
}

@media (max-width: 768px) {
  .controls-bar {
    gap: 8px;
    padding: 8px;
  }

  .control-group {
    gap: 4px;
  }

  .btn {
    height: 28px;
    padding: 0 10px;
    font-size: 11px;
  }
}
