:root {
  color-scheme: dark;
  --bg: #070b14;
  --panel: #0f1524;
  --panel-2: #151d2f;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f7fb;
  --muted: #8f9bb3;
  --accent: #5c8dff;
  --accent-strong: #78a5ff;
  --danger: #ff7d85;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.24);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: 74px minmax(0, 1fr);
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 12, 22, 0.94);
  backdrop-filter: blur(18px);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  border: 1px solid rgba(122, 166, 255, 0.35);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(91, 140, 255, 0.2), rgba(91, 140, 255, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark svg {
  width: 29px;
  fill: none;
  stroke: #8bb0ff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.button,
.tool-button,
.view-button,
.icon-button {
  border: 0;
  cursor: pointer;
  transition: 0.18s ease;
}

.button {
  height: 40px;
  padding: 0 15px;
  border-radius: 11px;
  font-weight: 700;
  font-size: 13px;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  box-shadow: 0 10px 25px rgba(92, 141, 255, 0.24);
}

.button-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.button-ghost {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.button-ghost:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.workspace {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 0;
}

.sidebar {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: #0c111e;
  scrollbar-width: thin;
  scrollbar-color: #29334a transparent;
}

.panel-section {
  padding: 15px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.038), rgba(255, 255, 255, 0.015));
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #dbe4f4;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-heading small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.icon-button:hover:not(:disabled) {
  background: rgba(255, 125, 133, 0.12);
  color: var(--danger);
}

.file-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 11px;
  background: rgba(92, 141, 255, 0.15);
  color: #9cbbff;
  font-size: 12px;
  font-weight: 900;
}

.file-info {
  min-width: 0;
}

.file-info strong,
.file-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info strong {
  font-size: 13px;
}

.file-info span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.control-grid {
  display: grid;
  gap: 8px;
}

.two-columns {
  grid-template-columns: 1fr 1fr;
}

.tool-button,
.view-button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.tool-button:hover,
.view-button:hover,
.tool-button.active,
.view-button.active {
  border-color: rgba(92, 141, 255, 0.45);
  background: rgba(92, 141, 255, 0.13);
  color: #dce7ff;
}

.field-label {
  display: block;
  margin: 15px 0 7px;
  color: var(--muted);
  font-size: 11px;
}

.color-control {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.color-control input[type="color"] {
  width: 35px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
}

.color-control input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-control input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 7px;
}

.color-control span {
  color: #cfd8e8;
  font-size: 11px;
  font-weight: 700;
}

.view-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  cursor: pointer;
  color: #cbd5e5;
  font-size: 12px;
}

.toggle-row + .toggle-row {
  border-top: 1px solid rgba(255, 255, 255, 0.055);
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-row i {
  position: relative;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: #283249;
  transition: 0.18s ease;
}

.toggle-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #a9b4c8;
  transition: 0.18s ease;
}

.toggle-row input:checked + i {
  background: rgba(92, 141, 255, 0.72);
}

.toggle-row input:checked + i::after {
  left: 18px;
  background: white;
}

.dimension-grid {
  display: grid;
  gap: 8px;
}

.dimension-grid > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
}

.dimension-grid span {
  color: var(--muted);
  font-size: 10px;
}

.dimension-grid strong {
  color: #e7eef9;
  font-size: 11px;
}

.viewer-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, rgba(53, 75, 130, 0.15), transparent 42%),
    #0b1020;
}

.canvas-container {
  position: absolute;
  inset: 0;
}

.canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.drop-overlay,
.loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  transition: 0.22s ease;
}

.drop-overlay {
  z-index: 5;
}

.drop-overlay.dragging {
  background: rgba(92, 141, 255, 0.08);
}

.drop-overlay.dragging .drop-card {
  transform: scale(1.015);
  border-color: rgba(92, 141, 255, 0.65);
  background: rgba(21, 29, 47, 0.92);
}

.drop-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.drop-card {
  width: min(500px, 100%);
  padding: 34px;
  border: 1px dashed rgba(153, 178, 230, 0.28);
  border-radius: 22px;
  background: rgba(15, 21, 36, 0.74);
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(14px);
  transition: 0.22s ease;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 18px;
  background: rgba(92, 141, 255, 0.14);
}

.drop-icon svg {
  width: 37px;
  fill: none;
  stroke: #93b5ff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-card h2 {
  margin: 0;
  font-size: clamp(20px, 3vw, 27px);
  letter-spacing: -0.035em;
}

.drop-card > p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.format-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 18px;
}

.format-list span {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: #bac7dc;
  font-size: 10px;
  font-weight: 850;
}

.drop-card .privacy-note {
  margin-top: 20px;
  color: #6f7c94;
  font-size: 10px;
}

.loading-overlay {
  z-index: 8;
  gap: 12px;
  align-content: center;
  background: rgba(7, 11, 20, 0.72);
  backdrop-filter: blur(8px);
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #83a9ff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.loading-overlay strong {
  font-size: 13px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.viewer-hint,
.status-pill {
  position: absolute;
  z-index: 4;
  border: 1px solid var(--border);
  background: rgba(10, 15, 27, 0.75);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.viewer-hint {
  left: 50%;
  bottom: 15px;
  display: flex;
  gap: 16px;
  padding: 9px 13px;
  transform: translateX(-50%);
  border-radius: 11px;
  color: #8d99ae;
  font-size: 10px;
  white-space: nowrap;
}

.status-pill {
  right: 14px;
  bottom: 14px;
  padding: 8px 11px;
  border-radius: 999px;
  color: #9aa7bd;
  font-size: 10px;
}

.toast {
  position: fixed;
  right: 20px;
  top: 92px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 15px;
  transform: translateY(-10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.95);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  color: #e8edf7;
  font-size: 12px;
  transition: 0.22s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: rgba(255, 125, 133, 0.35);
  color: #ffd1d4;
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100%;
    grid-template-rows: auto auto;
  }

  .topbar {
    align-items: flex-start;
    padding: 14px;
  }

  .brand p,
  .button-ghost {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 70vh);
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .panel-section {
    margin-bottom: 0;
  }

  .viewer-panel {
    min-height: 520px;
  }

  .viewer-hint {
    display: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 10px;
  }

  .brand-mark {
    display: none;
  }

  .brand h1 {
    font-size: 15px;
  }

  .button {
    padding: 0 11px;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }
}

/* Pré-visualização local de arquivos SolidWorks */
.solidworks-preview {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 15%, rgba(82, 115, 183, 0.16), transparent 44%),
    #0b1020;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.solidworks-preview.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.solidworks-preview-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.025) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.025) 75%),
    #11182a;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.18);
}

.solidworks-preview-stage img {
  display: block;
  max-width: calc(100% - 28px);
  max-height: calc(100% - 28px);
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.12s ease;
  user-select: none;
  -webkit-user-drag: none;
  border-radius: 5px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
}

.solidworks-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(17, 24, 42, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.sheet-navigation,
.preview-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-navigation span {
  min-width: 110px;
  color: #d9e4f6;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.preview-button {
  min-width: 34px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #e7eef9;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.15s ease;
}

.preview-button:hover:not(:disabled) {
  border-color: rgba(111, 157, 255, 0.55);
  background: rgba(92, 141, 255, 0.13);
}

.preview-button.preview-reset {
  min-width: 66px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.solidworks-preview-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 189, 84, 0.2);
  border-radius: 11px;
  background: rgba(91, 63, 20, 0.18);
}

.solidworks-preview-note strong {
  flex: 0 0 auto;
  color: #ffe0a6;
  font-size: 11px;
}

.solidworks-preview-note span {
  color: #c8d1df;
  font-size: 10px;
  line-height: 1.45;
  text-align: right;
}

@media (max-width: 620px) {
  .solidworks-preview {
    padding: 10px;
  }

  .solidworks-preview-toolbar,
  .solidworks-preview-note {
    align-items: stretch;
    flex-direction: column;
  }

  .solidworks-preview-toolbar {
    gap: 8px;
  }

  .sheet-navigation,
  .preview-zoom-controls {
    justify-content: center;
  }

  .solidworks-preview-note {
    gap: 4px;
  }

  .solidworks-preview-note span {
    text-align: left;
  }
}

.viewer-hint.hidden {
  display: none;
}
