/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --sidebar-bg: #1a1d23;
  --sidebar-text: #c9cdd6;
  --sidebar-active: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --border: #e2e6ea;
  --text: #111827;
  --text-muted: #6b7280;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}

body { font-family: system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
input, select, textarea { font: inherit; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1d23 0%, #2d3748 100%);
}
.login-box {
  background: var(--surface); border-radius: 12px; padding: 40px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon { font-size: 36px; }
.login-logo h1 { font-size: 22px; font-weight: 700; margin-top: 8px; }
.login-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ── App layout ──────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--sidebar-bg);
  color: var(--sidebar-text); display: flex; flex-direction: column;
  padding: 0; overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px; padding: 20px 16px;
  font-size: 16px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo .logo-icon { font-size: 20px; }
.sidebar nav { padding: 8px 8px; }
.nav-item {
  display: block; padding: 8px 12px; border-radius: 6px; font-size: 13px;
  color: var(--sidebar-text); transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; font-weight: 600; }
.sidebar-logout { margin: auto 16px 16px; }
.sidebar-section { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-section + .sidebar-section { padding-top: 12px; }
.sidebar-project-name { font-weight: 600; color: #fff; font-size: 13px; margin-bottom: 10px; word-break: break-word; }
.sidebar-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.4); margin-bottom: 8px; }

/* Scene thumbnails in sidebar */
.scene-thumb {
  border-radius: 6px; overflow: hidden; cursor: pointer; margin-bottom: 6px;
  border: 2px solid transparent; transition: border-color 0.15s;
  position: relative;
}
.scene-thumb:hover { border-color: rgba(255,255,255,0.3); }
.scene-thumb.active { border-color: var(--primary); }
.scene-thumb img { width: 100%; height: 56px; object-fit: cover; display: block; }
.scene-thumb-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.65); padding: 3px 6px; font-size: 11px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge-default {
  background: var(--primary); color: #fff; font-size: 9px; padding: 1px 5px;
  border-radius: 4px; margin-right: 4px;
}

/* Upload progress */
.upload-label { text-align: center; }
.upload-progress { margin-top: 10px; }
.progress-bar { background: rgba(255,255,255,0.15); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.2s; }
.upload-progress span { font-size: 11px; color: rgba(255,255,255,0.6); display: block; margin-top: 4px; }

/* Content area */
.content { flex: 1; overflow-y: auto; padding: 24px; }
.content-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.content-header h2 { font-size: 20px; font-weight: 700; }

/* ── Project grid ─────────────────────────────────────────────────────────── */
.project-grid { display: flex; flex-direction: column; gap: 10px; }
.project-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; box-shadow: var(--shadow); transition: box-shadow 0.15s;
}
.project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.project-card-body h3 { font-size: 15px; font-weight: 600; }
.project-card-body p { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.project-card-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ── Editor page ──────────────────────────────────────────────────────────── */
.editor-page { overflow: hidden; }
.editor-main {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: #1a1d23;
}
.empty-state {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.5); text-align: center; line-height: 1.7; padding: 40px;
}
#editorArea { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Editor toolbar */
.editor-toolbar {
  background: #13161c; border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 10px 16px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; flex-shrink: 0;
}
.editor-scene-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.editor-scene-info span { color: rgba(255,255,255,0.9); font-weight: 600; font-size: 14px; margin-right: 4px; }
.editor-hotspot-tools { display: flex; align-items: center; gap: 10px; }
.add-mode-badge {
  background: rgba(37,99,235,0.3); border: 1px solid rgba(37,99,235,0.5);
  color: #93c5fd; padding: 4px 10px; border-radius: 20px; font-size: 12px;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

/* Pannellum viewer */
#panoramaViewer {
  flex: 1; min-height: 0;
  position: relative;
}
#panoramaViewer .pnlm-container { background: #111; }

/* Hotspot list panel */
.hotspot-list {
  background: #13161c; border-top: 1px solid rgba(255,255,255,0.08);
  padding: 12px 16px; max-height: 160px; overflow-y: auto; flex-shrink: 0;
}
.hotspot-empty { color: rgba(255,255,255,0.4); font-size: 12px; }
.hotspot-items { display: flex; flex-direction: column; gap: 6px; }
.hotspot-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.05); border-radius: 6px; padding: 8px 12px;
}
.hotspot-item-icon { font-size: 18px; flex-shrink: 0; width: 24px; text-align: center; }
.hotspot-item-info { flex: 1; min-width: 0; }
.hotspot-item-info strong { display: block; color: #fff; font-size: 13px; }
.hotspot-item-info span { color: rgba(255,255,255,0.5); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.hotspot-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary.active { background: #1e40af; box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.btn-outline {
  background: transparent; color: var(--sidebar-text);
  border: 1px solid rgba(255,255,255,0.2);
}
.btn-outline:hover { background: rgba(255,255,255,0.08); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* In light context, outlines look different */
.content .btn-outline {
  color: var(--text); border-color: var(--border);
}
.content .btn-outline:hover { background: var(--bg); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; background: var(--surface); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-group label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; font-weight: normal; color: var(--text); text-transform: none; letter-spacing: normal; }
.radio-group input[type="radio"] { width: auto; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 12px; padding: 28px;
  width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.modal-actions .btn-outline { color: var(--text); border-color: var(--border); }
.modal-actions .btn-outline:hover { background: var(--bg); }

/* ── Error message ────────────────────────────────────────────────────────── */
.error-msg { color: #dc2626; font-size: 13px; padding: 8px 0; }

/* ── Logo client ─────────────────────────────────────────────────────────── */
.current-logo-preview {
  min-height: 48px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06); border-radius: 6px; padding: 8px;
}
.current-logo-preview img { max-height: 44px; max-width: 100%; object-fit: contain; }
.logo-placeholder { font-size: 11px; color: rgba(255,255,255,0.35); font-style: italic; }

.logo-library {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px; margin-bottom: 16px; max-height: 280px; overflow-y: auto;
}
.logo-thumb {
  border: 2px solid var(--border); border-radius: 8px; padding: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  height: 70px; background: #f9fafb; transition: border-color 0.15s;
}
.logo-thumb:hover { border-color: var(--primary); }
.logo-thumb.selected { border-color: var(--primary); background: rgba(37,99,235,0.06); }
.logo-thumb img { max-height: 50px; max-width: 100%; object-fit: contain; }
.logo-empty { color: var(--text-muted); font-size: 13px; grid-column: 1/-1; }
.logo-upload-section { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.logo-upload-section p { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.modal-wide { max-width: 520px; }

/* ── PDFs ─────────────────────────────────────────────────────────────────── */
.pdf-lib-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: rgba(255,255,255,0.05); border-radius: 6px; margin-bottom: 4px;
  font-size: 12px; color: rgba(255,255,255,0.8);
}
.pdf-lib-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pdf-pick-available { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.pdf-pick-available .pdf-pick-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
  font-size: 12px; background: var(--bg); transition: background 0.15s;
}
.pdf-pick-available .pdf-pick-item:hover { background: #e8edf3; }
.pdf-pick-available .pdf-pick-item.selected { background: rgba(37,99,235,0.08); border-color: var(--primary); }

.pdf-pick-selected { display: flex; flex-direction: column; gap: 4px; }
.pdf-pick-selected .pdf-sel-item {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  background: rgba(37,99,235,0.08); border: 1px solid rgba(37,99,235,0.3);
  border-radius: 6px;
}
.pdf-sel-item input { flex: 1; border: none; background: transparent; font-size: 12px; color: var(--text); padding: 2px 4px; }
.pdf-sel-item input:focus { outline: none; }
.pdf-sel-arrows { display: flex; flex-direction: column; gap: 1px; }
.pdf-sel-arrows button { border: none; background: none; cursor: pointer; padding: 0 3px; font-size: 10px; color: var(--text-muted); line-height: 1.2; }
.pdf-sel-arrows button:hover { color: var(--text); }

