/* ═══════════════════════════════════════════════════════════
   FABBOX · Peças DXF Paramétricas
   Design System: dark mode · Space Mono + DM Sans · accent #ff6b1a
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:         #0e0f0f;
  --surface:    #161818;
  --surface2:   #1d2020;
  --surface3:   #222525;
  --border:     rgba(255,255,255,0.07);
  --border-md:  rgba(255,255,255,0.11);
  --accent:     #ff6b1a;
  --accent2:    #ffaa55;
  --text:       #f0ede8;
  --muted:      #8a8880;
  --dim:        #3a3835;
  --success:    #2dd4a0;
  --blue:       #7ab4ff;
  --danger:     #ff5555;
  --grid-line:  rgba(255,255,255,0.03);
}

/* ── LIGHT THEME ── */
[data-theme="light"] {
  --bg:        #f2f1ee;
  --surface:   #ffffff;
  --surface2:  #ece9e4;
  --surface3:  #e3e0db;
  --border:    rgba(0,0,0,0.09);
  --border-md: rgba(0,0,0,0.14);
  --text:      #1a1410;
  --muted:     #6a6560;
  --dim:       #b5b2ad;
  --grid-line: rgba(0,0,0,0.04);
}
[data-theme="light"] .cat-icon { background: rgba(0,0,0,0.05); }
[data-theme="light"] .glow {
  background: radial-gradient(circle, rgba(255,107,26,0.06) 0%, transparent 70%);
}

/* ── THEME TOGGLE BUTTON ── */
.header-right { display: flex; align-items: center; gap: 10px; }
.theme-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border-md);
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0; padding: 0;
}
.theme-btn:hover { background: var(--surface3); color: var(--accent); border-color: rgba(255,107,26,0.3); }
.theme-btn svg { display: block; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  position: relative;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none; z-index: 0;
}

.glow {
  position: fixed;
  width: 560px; height: 560px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,107,26,0.07) 0%, transparent 70%);
  top: -100px; right: -100px;
  pointer-events: none; z-index: 0;
}

.wrap {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  position: relative; z-index: 1;
}

/* ── HEADER ── */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.75rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-icon {
  width: 32px; height: 32px;
  background: var(--accent); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
}
.logo-icon svg { display: block; }
.logo-wordmark {
  font-family: 'Space Mono', monospace;
  font-size: 1.05rem; font-weight: 700;
  letter-spacing: -0.02em; color: var(--text);
}
.logo-wordmark span { color: var(--accent); }

.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem; color: var(--muted);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.breadcrumb a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--dim); }
.breadcrumb .current { color: var(--accent2); }

/* ── PAGE HEAD ── */
.page-head { margin-bottom: 2rem; }

.page-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 0.6rem;
  display: flex; align-items: center; gap: 8px;
}
.page-label::before {
  content: ''; display: inline-block;
  width: 16px; height: 1px; background: var(--accent);
}
.page-head h1 {
  font-size: 1.9rem; font-weight: 300;
  letter-spacing: -0.03em; line-height: 1.2;
}
.page-head h1 strong { font-weight: 600; color: var(--accent2); }

/* ── MAIN LAYOUT ── */
.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  position: sticky;
  top: 1rem;
  display: flex; flex-direction: column;
}

.sidebar-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.58rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
  padding: 0.9rem 1rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.cat-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 0.68rem 1rem;
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem; font-weight: 400;
  text-align: left;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s, color 0.12s;
  position: relative;
  line-height: 1.3;
}
.cat-btn:last-child { border-bottom: none; }
.cat-btn:hover { background: var(--surface2); color: var(--text); }
.cat-btn.active { background: var(--surface2); color: var(--text); }
.cat-btn.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--accent);
}
.cat-icon {
  width: 26px; height: 26px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: rgba(255,255,255,0.04);
  font-size: 0.75rem;
}
.cat-btn.active .cat-icon { background: rgba(255,107,26,0.14); }

.sidebar-bottom {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.lib-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 0.58rem;
  background: var(--surface2);
  border: 1px solid var(--border-md);
  border-radius: 7px;
  color: var(--muted); cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 0.78rem;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.lib-btn:hover {
  background: var(--surface3); color: var(--accent);
  border-color: rgba(255,107,26,0.3);
}

/* ── MAIN AREA ── */
.main-area { position: relative; min-width: 0; }

/* ── LIBRARY PANEL ── */
.library-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.library-panel.open {
  display: block;
  animation: fadeUp 0.2s ease both;
}

.library-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.library-header > span:first-child { font-size: 0.85rem; font-weight: 600; }
.lib-hint { font-size: 0.72rem; color: var(--muted); }

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1px;
  background: var(--border);
}

.library-card {
  background: var(--surface);
  padding: 1rem;
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; gap: 0.55rem;
  transition: background 0.12s;
}
.library-card:hover { background: var(--surface2); }
.library-card.active { background: rgba(255,107,26,0.05); }

.library-thumb { width: 100%; height: 88px; }
.library-thumb .shape-line {
  stroke: var(--muted); stroke-width: 1.2px; fill: none;
}

.library-name {
  font-size: 0.7rem; color: var(--muted);
  text-align: center; line-height: 1.35;
}
.library-card.active .library-name { color: var(--accent2); }

/* ── PANEL ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.panel-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-title {
  font-size: 0.98rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.panel-title .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.panel-subtitle { font-size: 0.74rem; color: var(--muted); margin-top: 3px; }

.clear-btn {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--dim); background: none; border: none;
  cursor: pointer; transition: color 0.12s; padding: 4px 8px;
}
.clear-btn:hover { color: var(--accent); }

/* ── CONTENT SPLIT ── */
.content-split {
  display: grid;
  grid-template-columns: 330px 1fr;
}

/* ── PARAMS PANE ── */
.params-pane {
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 500px;
}

.params-scroll {
  flex: 1;
  padding: 1.1rem 1rem 0.5rem;
  overflow-y: auto;
}

.params-actions {
  padding: 1rem 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── FIELD ROW ── */
.field {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 0 0.65rem;
  padding: 0.5rem 0.6rem;
  border-radius: 7px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.field:hover { background: var(--surface2); }
.field.active-field {
  background: rgba(255,107,26,0.05);
  border-color: rgba(255,107,26,0.22);
}

.field-hl {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(45,212,160,0.1);
  border: 1px solid rgba(45,212,160,0.2);
  color: var(--success);
  font-size: 0.65rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; padding: 0;
  transition: background 0.12s, border-color 0.12s;
}
.field-hl:hover { background: rgba(45,212,160,0.2); }
.field.active-field .field-hl {
  background: rgba(255,107,26,0.18);
  border-color: rgba(255,107,26,0.4);
  color: var(--accent);
}

.field-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.field.active-field .field-label { color: var(--text); }

.field-spin {
  display: flex; align-items: center; gap: 3px;
}

.spin-btn {
  width: 24px; height: 24px;
  background: var(--surface3);
  border: 1px solid var(--border-md);
  border-radius: 5px;
  color: var(--muted); font-size: 1rem; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; padding: 0;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.spin-btn:hover {
  background: var(--surface2); color: var(--accent);
  border-color: rgba(255,107,26,0.3);
}

.field-input {
  width: 68px;
  background: var(--surface2);
  border: 1px solid var(--border-md);
  border-radius: 5px;
  padding: 0.28rem 0.45rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem; font-weight: 700;
  color: var(--text); text-align: right;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}
.field-input::-webkit-outer-spin-button,
.field-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.field-input:focus { border-color: var(--accent); }
.field.active-field .field-input { border-color: rgba(255,107,26,0.35); }

/* ── DOWNLOAD BUTTON ── */
.btn-download {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 0.7rem 1rem;
  background: var(--accent); border: none; border-radius: 8px;
  color: #fff;
  font-family: 'DM Sans', sans-serif; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; margin-bottom: 0.75rem;
  transition: background 0.15s, transform 0.1s;
}
.btn-download:hover { background: #e55e10; }
.btn-download:active { transform: scale(0.98); }

/* ── ERROR ── */
.error {
  font-size: 0.72rem; color: var(--danger);
  font-family: 'Space Mono', monospace;
  min-height: 0; line-height: 1.5;
}
.error:not(:empty) {
  background: rgba(255,85,85,0.07);
  border: 1px solid rgba(255,85,85,0.2);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

/* ── INFO TIP ── */
.info-tip {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 0.71rem; color: var(--muted); line-height: 1.55;
}
.info-icon {
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(122,180,255,0.1);
  border: 1px solid rgba(122,180,255,0.2);
  color: var(--blue);
  font-family: 'Space Mono', monospace; font-size: 0.6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}

/* ── PREVIEW PANE ── */
.preview-pane {
  display: flex; flex-direction: column;
  background: var(--surface);
}

.preview-toolbar {
  padding: 0.72rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.preview-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.preview-info {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem; color: var(--dim); letter-spacing: 0.04em;
}

.svg-area {
  flex: 1;
  padding: 2rem 1.5rem;
  display: flex; align-items: center; justify-content: center;
  min-height: 440px;
}

#preview { width: 100%; height: 100%; max-height: 520px; }

/* ── SVG DRAW CLASSES ── */
.shape-line {
  stroke: var(--text); stroke-width: 1.5px; fill: none;
  vector-effect: non-scaling-stroke;
}
.highlight-line {
  stroke: var(--accent); stroke-width: 2.5px; fill: none;
  vector-effect: non-scaling-stroke;
}
.center-line {
  stroke: var(--dim); stroke-width: 1px;
  stroke-dasharray: 6 4; fill: none;
  vector-effect: non-scaling-stroke;
}
.dim-text {
  font-family: 'Space Mono', monospace;
  font-size: 11px; fill: var(--muted);
}

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-head { animation: fadeUp 0.4s ease both; }
.sidebar   { animation: fadeUp 0.4s 0.08s ease both; }
.panel     { animation: fadeUp 0.4s 0.14s ease both; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .content-split { grid-template-columns: 290px 1fr; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  #sidebarList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .cat-btn {
    border: 1px solid var(--border); border-radius: 6px;
    margin: 3px; width: auto;
  }
  .cat-btn.active::before { display: none; }
  .sidebar-bottom { padding: 0.5rem 0.75rem; }
  .content-split { grid-template-columns: 1fr; }
  .params-pane { border-right: none; border-bottom: 1px solid var(--border); min-height: auto; }
}

@media (max-width: 520px) {
  .wrap { padding: 0 1rem 3rem; }
  .page-head h1 { font-size: 1.5rem; }
  #sidebarList { grid-template-columns: 1fr 1fr; }
}

/* ── LANGUAGE SWITCHER ── */
.lang-switcher { position: relative; }
.lang-btn {
  height: 34px; padding: 0 10px;
  background: var(--surface2); border: 1px solid var(--border-md);
  border-radius: 8px; color: var(--muted); cursor: pointer;
  font-family: 'Space Mono', monospace; font-size: 0.65rem; letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 5px;
  transition: background 0.15s, color 0.15s, border-color 0.15s; white-space: nowrap;
}
.lang-btn:hover { color: var(--text); border-color: rgba(255,107,26,0.3); }
.lang-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface2); border: 1px solid var(--border-md);
  border-radius: 9px; overflow: hidden; z-index: 500;
  min-width: 158px; box-shadow: 0 8px 28px rgba(0,0,0,0.3);
}
.lang-menu.open { display: block; }
.lang-menu-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 0.55rem 0.9rem;
  background: none; border: none; border-bottom: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 0.82rem; text-align: left;
  transition: background 0.1s, color 0.1s;
}
.lang-menu-btn:last-child { border-bottom: none; }
.lang-menu-btn:hover { background: var(--surface3); color: var(--text); }
.lang-menu-btn.active { color: var(--accent); }
