* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── HEADER ─────────────────────────────────────────── */
header {
  background: #16213e;
  padding: 12px 24px;
  border-bottom: 2px solid #0f3460;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

header h1 { font-size: 1.2rem; color: #e94560; font-weight: 600; letter-spacing: 1px; }
header .breadcrumb { font-size: 0.78rem; color: #556; display: flex; align-items: center; gap: 6px; }
header .breadcrumb .sep { color: #334; }
header .breadcrumb .proj-name { color: #aac; }

.header-spacer { flex: 1; }

/* ── SHARED BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 16px; border: none; border-radius: 4px;
  cursor: pointer; font-size: 0.82rem; font-weight: 600;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: #e94560; color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.85; }
.btn-secondary { background: #0f3460; color: #e0e0e0; }
.btn-secondary:hover { background: #1a4a8a; }
.btn-danger { background: #3d1a1a; color: #e94560; border: 1px solid #5a2020; }
.btn-danger:hover { background: #5a2020; }
.btn-sm { padding: 4px 10px; font-size: 0.72rem; }
.btn-back { background: transparent; color: #889; border: 1px solid #334; font-size: 0.78rem; padding: 5px 12px; }
.btn-back:hover { color: #e0e0e0; border-color: #556; }

/* ── LANDING PAGE ───────────────────────────────────── */
#landing {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.landing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.landing-toolbar h2 { font-size: 1rem; color: #aac; font-weight: 400; }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.project-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-card:hover { border-color: #e94560; transform: translateY(-2px); }

.project-card .card-name {
  font-size: 1rem;
  font-weight: 600;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card .card-meta {
  font-size: 0.72rem;
  color: #557;
}

.project-card .card-panels {
  font-size: 0.78rem;
  color: #889;
  margin-top: 4px;
}

.project-card .card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.empty-projects {
  grid-column: 1 / -1;
  text-align: center;
  color: #334;
  padding: 60px 0;
  font-size: 0.9rem;
}

.empty-projects span { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ── MODAL ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}

.modal {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 10px;
  padding: 28px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal h3 { font-size: 1rem; color: #e94560; }

.modal input {
  background: #0d1b36;
  border: 1px solid #0f3460;
  color: #e0e0e0;
  padding: 9px 12px;
  border-radius: 4px;
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.2s;
}

.modal input:focus { outline: none; border-color: #e94560; }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── 3D BUILDER ─────────────────────────────────────── */
#builder {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.panel-left {
  flex: 1;
  position: relative;
  background: #0d0d1a;
  border-right: 2px solid #0f3460;
}

.panel-left canvas { display: block; width: 100% !important; height: 100% !important; }

.canvas-overlay {
  position: absolute; top: 12px; left: 12px;
  background: rgba(0,0,0,0.5);
  padding: 6px 12px; border-radius: 4px;
  font-size: 0.72rem; color: #aaa; pointer-events: none;
}

.panel-right {
  width: 340px;
  background: #16213e;
  overflow-y: auto;
  /* min-height: 0 overrides the flex default of min-height: auto,
     allowing this flex item to be capped at the container height
     so overflow-y: auto actually triggers a scrollbar */
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #0f3460 #16213e;
}

.panel-right::-webkit-scrollbar { width: 6px; }
.panel-right::-webkit-scrollbar-track { background: #16213e; }
.panel-right::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 3px; }
.panel-right::-webkit-scrollbar-thumb:hover { background: #1a4a8a; }

.panel-section {
  border-bottom: 1px solid #0f3460;
}

.panel-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}

.panel-section-header:hover { background: rgba(255,255,255,0.03); }

.panel-section-header h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #e94560;
  margin: 0;
}

.panel-section-toggle {
  font-size: 0.7rem;
  color: #556;
  transition: transform 0.2s;
}

.panel-section-toggle.open { transform: rotate(180deg); }

.panel-section-body {
  padding: 0 16px 16px;
}

.form-row { display: flex; gap: 8px; margin-bottom: 8px; }

.form-group { flex: 1; display: flex; flex-direction: column; }
.form-group label { font-size: 0.68rem; color: #888; margin-bottom: 3px; text-transform: uppercase; }
.form-group input {
  background: #0d1b36; border: 1px solid #0f3460;
  color: #e0e0e0; padding: 5px 8px; border-radius: 4px;
  font-size: 0.82rem; width: 100%; transition: border-color 0.2s;
}
.form-group input:focus { outline: none; border-color: #e94560; }
.form-group input::-webkit-inner-spin-button { opacity: 0.4; }

.section-label {
  font-size: 0.7rem; color: #557;
  text-transform: uppercase; letter-spacing: 1px;
  margin: 8px 0 4px;
}

.btn-edit-sm { background: #0f3460; color: #e0e0e0; }
.btn-edit-sm:hover { background: #1a4a8a; }

.parts-tree { padding: 12px; }

.parts-tree-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.parts-tree-header h2 {
  font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 1.5px; color: #e94560; margin: 0;
}

.group-info-bar {
  display: flex; align-items: center; gap: 6px;
  background: #0f3460; border-radius: 4px;
  padding: 6px 10px; margin-bottom: 8px;
}
.group-info-name {
  flex: 1; font-size: 0.8rem; font-weight: 600; color: #aac;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.group-select {
  width: 100%; background: #0d1b36; border: 1px solid #0f3460;
  color: #e0e0e0; padding: 5px 8px; border-radius: 4px;
  font-size: 0.82rem; cursor: pointer; transition: border-color 0.2s;
}
.group-select:focus { outline: none; border-color: #e94560; }
.group-select option { background: #0d1b36; }

.jstree-group-label { font-weight: 600; color: #aac; }

.empty-state { color: #445; font-size: 0.78rem; text-align: center; padding: 24px 0; }

/* ── MATERIAL SELECTOR ──────────────────────────────── */
.mat-tabs {
  display: flex; gap: 4px; margin-bottom: 10px;
}
.mat-tab {
  flex: 1; padding: 5px 4px; border: 1px solid #0f3460;
  background: #0d1b36; color: #778; border-radius: 4px;
  font-size: 0.72rem; font-weight: 600; cursor: pointer;
  text-align: center; transition: all 0.15s; text-transform: uppercase; letter-spacing: 0.5px;
}
.mat-tab.active { background: #e94560; border-color: #e94560; color: #fff; }
.mat-tab:hover:not(.active) { border-color: #557; color: #aac; }

.color-row {
  display: flex; align-items: center; gap: 10px;
}
.color-row input[type=color] {
  width: 44px; height: 34px; padding: 2px; border: 1px solid #0f3460;
  border-radius: 4px; background: #0d1b36; cursor: pointer;
}
.color-hex {
  background: #0d1b36; border: 1px solid #0f3460; color: #e0e0e0;
  padding: 5px 8px; border-radius: 4px; font-size: 0.82rem;
  width: 90px; font-family: monospace;
}
.color-hex:focus { outline: none; border-color: #e94560; }

.img-upload-area {
  border: 1px dashed #0f3460; border-radius: 4px; padding: 12px;
  text-align: center; cursor: pointer; transition: border-color 0.15s;
}
.img-upload-area:hover { border-color: #557; }
.img-upload-area input { display: none; }
.img-upload-area .hint { font-size: 0.72rem; color: #557; margin-bottom: 6px; }
.img-preview {
  width: 100%; height: 80px; object-fit: cover;
  border-radius: 3px; margin-top: 6px; display: block;
}

footer {
  background: #0f1929; padding: 4px 16px;
  font-size: 0.7rem; color: #445;
  border-top: 1px solid #0f3460; flex-shrink: 0;
}

/* ── LANGUAGE SWITCHER ──────────────────────────────── */
.lang-switcher {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.lang-btn {
  background: transparent;
  border: 1px solid #334;
  color: #667;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s;
}

.lang-btn:hover { border-color: #556; color: #aac; }
.lang-btn.active { background: #0f3460; border-color: #0f3460; color: #e0e0e0; }
