/* =============================================================
   DXF 3D Viewer — Stylesheet
   Dark UI, minimal, two-column layout (panel + 3D viewport)
   ============================================================= */

/* ── Reset & Variables ──────────────────────────────────────── */

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

:root {
  --bg-app:     #0f1117;
  --bg-panel:   #161920;
  --bg-section: #1d2029;
  --border:     #272c38;
  --accent:     #4f8ef7;
  --accent-h:   #3a7be0;
  --text-1:     #e4e7f0;
  --text-2:     #8b91a4;
  --success:    #4ec882;
  --error:      #e05555;
  --info:       #4f8ef7;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  background: var(--bg-app);
  color: var(--text-1);
}

/* ── App Shell ──────────────────────────────────────────────── */

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ── Side Panel ─────────────────────────────────────────────── */

#panel {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

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

.panel-header {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.app-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text-1);
}

.app-subtitle {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.5;
}

/* ── Generic Section Block ──────────────────────────────────── */

.section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-2);
}

/* ── Upload ─────────────────────────────────────────────────── */

#dxf-upload { display: none; }

.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.upload-btn:hover { background: var(--accent-h); }

.file-name {
  font-size: 11px;
  color: var(--text-2);
  word-break: break-all;
  min-height: 16px;
}

.file-type {
  font-size: 10px;
  color: var(--text-2);
  margin-top: 2px;
}

/* ── Sample Browser ─────────────────────────────────────────── */

.sample-browser {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sample-category {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-section);
  overflow: hidden;
}

.sample-category-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: transparent;
  border: 0;
  color: var(--text-1);
  cursor: pointer;
  text-align: left;
}

.sample-category-header:hover {
  background: #1e2234;
}

.category-chevron {
  width: 12px;
  color: var(--text-2);
  transition: transform 0.2s;
}

.sample-category.open .category-chevron {
  transform: rotate(90deg);
}

.category-title {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
}

.status-badge,
.extension-badge {
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.status-badge.supported {
  color: var(--success);
  background: rgba(78, 200, 130, 0.12);
}

.status-badge.soon {
  color: var(--text-2);
  background: rgba(139, 145, 164, 0.14);
}

.sample-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.22s ease;
}

.sample-category.open .sample-list {
  max-height: 480px;
}

.sample-empty {
  padding: 9px 10px 11px 30px;
  font-size: 11px;
  color: var(--text-2);
}

.sample-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-section);
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-1);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}

.sample-btn:hover {
  background: #1e2234;
}

.sample-btn.active {
  background: rgba(79, 142, 247, 0.15);
  border-left: 3px solid var(--accent);
  padding-left: 7px;
}

.extension-badge {
  min-width: 38px;
  text-align: center;
  color: #cbd8ff;
  background: rgba(79, 142, 247, 0.18);
  flex-shrink: 0;
}

.sample-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sample-info strong {
  font-size: 12px;
  font-weight: 600;
}

.sample-info small {
  font-size: 10px;
  color: var(--text-2);
  line-height: 1.35;
}

/* ── Status Box ─────────────────────────────────────────────── */

.status-box {
  margin: 0 16px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid transparent;
}

.status-box.success {
  background: rgba(78, 200, 130, 0.1);
  border-color: rgba(78, 200, 130, 0.35);
  color: var(--success);
}

.status-box.error {
  background: rgba(224, 85, 85, 0.1);
  border-color: rgba(224, 85, 85, 0.35);
  color: var(--error);
}

.status-box.info {
  background: rgba(79, 142, 247, 0.1);
  border-color: rgba(79, 142, 247, 0.35);
  color: var(--info);
}

/* ── Camera Controls List ───────────────────────────────────── */

.controls-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.controls-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}

.ctrl-key {
  display: inline-block;
  padding: 1px 6px;
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 10px;
  font-family: monospace;
  color: var(--text-1);
  min-width: 50px;
  text-align: center;
}

/* ── Stats Section ──────────────────────────────────────────── */

.stats-section {
  background: transparent;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-2);
}

.stat-row strong {
  color: var(--text-1);
  font-weight: 600;
}

/* ── Viewport ───────────────────────────────────────────────── */

#viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0f1117;
}

#three-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* ── Loading Overlay ────────────────────────────────────────── */

#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 23, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-1);
  z-index: 10;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* ── Empty State ────────────────────────────────────────────── */

#empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.empty-icon {
  font-size: 56px;
  opacity: 0.25;
}

#empty-state p {
  font-size: 13px;
  color: var(--text-2);
  opacity: 0.6;
  text-align: center;
  max-width: 240px;
  line-height: 1.6;
}

/* ── Utility ─────────────────────────────────────────────────── */

.hidden { display: none !important; }

/* ── Custom Scrollbar ────────────────────────────────────────── */

#panel::-webkit-scrollbar {
  width: 6px;
}

#panel::-webkit-scrollbar-track {
  background: var(--bg-panel);
}

#panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

#panel::-webkit-scrollbar-thumb:hover {
  background: #3a4150;
}

/* ── Project Explorer (IDE-like) ─────────────────────────────── */
#project-explorer .tree-root { font-size: 13px; }
#project-explorer .tree-node { margin-left: 6px; }
#project-explorer .tree-row { display:flex; align-items:center; gap:8px; padding:4px 6px; border-radius:6px; background:transparent; color:inherit; border:none; text-align:left; width:100%; cursor:pointer; }
#project-explorer .tree-row:hover { background:#1e2234; }
#project-explorer .folder-row { font-weight:600; }
#project-explorer .file-row.unsupported { opacity:0.6; }
#project-explorer .file-row.active { background: rgba(79, 142, 247, 0.15); }
#project-explorer .chevron { width:16px; display:inline-block; color: var(--text-2); }
#project-explorer .icon { width:18px; text-align:center; }
#project-explorer .pill { margin-left:auto; font-size:11px; background:#3a2a2a; color:#f2b9b9; padding:2px 6px; border-radius:999px; }
#project-explorer .tree-children { margin-left: 18px; border-left:1px solid var(--border); padding-left:8px; }

.explorer-actions { display:flex; flex-direction:column; gap:8px; margin-bottom:8px; }

/* Floor-wise Plans priority visuals */
#floor-plans-section .section-label { font-weight: 800; }
#floor-plans-section { border-color: var(--accent); }

/* Collapsible Project Files */
#project-files-section.collapsed #project-explorer { display: none; }
#project-files-section .section-label { opacity: 0.85; }

/* ── Modal Overlay ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: #1a1e2e;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 340px;
  max-width: 92vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: slideUp 0.18s ease;
}

@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.modal-icon {
  font-size: 24px;
  line-height: 1;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 3px;
}

.modal-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-field-label {
  font-size: 12px;
  color: var(--text-1);
  flex: 1;
}

.modal-field-label small {
  color: var(--text-2);
  font-size: 10px;
}

.modal-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-section);
  color: var(--text-1);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}

.stepper-btn:hover { background: #2a3050; }

.stepper-value {
  min-width: 28px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.modal-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.floor-preview-pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(79, 142, 247, 0.15);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(79, 142, 247, 0.3);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

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

.modal-btn.primary:hover { background: var(--accent-h); border-color: var(--accent-h); }

.modal-btn.secondary {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}

.modal-btn.secondary:hover { background: var(--bg-section); color: var(--text-1); }

/* ── Floor File Picker ──────────────────────────────────────── */
.floor-file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.floor-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--text-1);
  transition: background 0.12s, border-color 0.12s;
}

.floor-file-item:hover {
  background: #1e2540;
  border-color: var(--accent);
}

.floor-file-icon { font-size: 16px; }

.floor-file-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.floor-file-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.floor-file-path {
  font-size: 10px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Floor Plans Section ────────────────────────────────────── */
.floor-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.floor-reconfig-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--text-2);
  transition: background 0.12s;
}

.floor-reconfig-btn:hover { background: var(--bg-section); }

.floor-btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-section);
  margin-bottom: 4px;
  transition: border-color 0.15s, background 0.15s;
}

.floor-btn-row.mapped { border-color: rgba(79, 142, 247, 0.3); }
.floor-btn-row.active { background: rgba(79, 142, 247, 0.12); border-color: var(--accent); }
.floor-btn-row:hover { background: #1e2234; }

.floor-btn-body {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.floor-btn-body.clickable { cursor: pointer; }
.floor-btn-body.clickable:hover .floor-key-sub { color: var(--accent); }

.floor-key-badge {
  min-width: 34px;
  text-align: center;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(79, 142, 247, 0.18);
  color: var(--accent);
  flex-shrink: 0;
}

.floor-key-sub {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.12s;
}

.floor-btn-row.mapped .floor-key-sub { color: var(--text-1); font-weight: 500; }

.floor-action-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  padding: 3px 7px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

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

/* ── Import Choice Popover ──────────────────────────────────── */
.import-choice-popover {
  position: absolute;
  z-index: 999;
  background: #1a1e2e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: slideUp 0.12s ease;
}

.import-choice-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-1);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
}

.import-choice-btn:hover { background: var(--bg-section); }

/* Global slim dark scrollbars (consistent across app) */
* {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: rgba(79, 142, 247, 0.45) rgba(18, 20, 32, 0.85);
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: var(--bg-section);
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb {
  background-color: rgba(79, 142, 247, 0.45); /* accent tint */
  border-radius: 8px;
  border: 1px solid var(--border);
}

*::-webkit-scrollbar-thumb:hover {
  background-color: rgba(79, 142, 247, 0.65);
}

*::-webkit-scrollbar-corner {
  background: var(--bg-section);
}
