@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design tokens ──────────────────────────────────────────────── */
:root {
  --brand:        #6366f1;
  --brand-dark:   #4f46e5;
  --brand-light:  #eef2ff;
  --sidebar-bg:   #0f172a;
  --sidebar-hover:#1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #6366f1;
  --surface:      #ffffff;
  --bg:           #f1f5f9;
  --border:       #e2e8f0;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --danger:       #ef4444;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.06);
  --shadow-lg:    0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.05);
  --sidebar-w:    240px;
  --transition:   .15s ease;
}

/* ── Reset ──────────────────────────────────────────────────────── */
html { overflow: hidden; height: 100%; }

body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

div { margin: 0; padding: 0; }

/* ── Layout ─────────────────────────────────────────────────────── */
.container-fluid { padding: 0; height: 100vh; }
.main-row        { padding: 0; margin: 0; height: 100vh; display: flex; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-right: none;
  box-shadow: 2px 0 8px rgba(0,0,0,.25);
  z-index: 100;
}

/* Brand header */
.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--brand) 0%, #818cf8 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99,102,241,.4);
}

.brand-icon svg { display: block; }

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -.3px;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 10px;
  color: var(--sidebar-text);
  font-weight: 400;
  letter-spacing: .3px;
  text-transform: uppercase;
  line-height: 1.3;
  margin-top: 1px;
}

/* Nav */
.nav-sidebar {
  margin: 12px 0 0;
  padding: 0 8px;
  list-style: none;
}

.nav-sidebar > li > a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
}

.nav-sidebar > li > a .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
}

.nav-sidebar > li > a:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.nav-sidebar > li > a:hover .nav-icon { opacity: 1; }

.nav-sidebar > .active > a,
.nav-sidebar > .active > a:hover,
.nav-sidebar > .active > a:focus {
  color: #ffffff;
  background: rgba(99,102,241,.2);
  border-left: 2px solid var(--brand);
  padding-left: 10px;
}

.nav-sidebar > .active > a .nav-icon { opacity: 1; }

.nav-sidebar > li > a .pull-right { display: none; }

/* Sidebar divider */
.sidebar > hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,.06);
  margin: 8px 16px;
}

/* Sidebar context panels */
#context-menu,
#floorTexturesDiv,
#wallTextures {
  padding: 12px 12px;
}

#context-menu .lead {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
}

#context-menu .btn-danger {
  background: #ef4444;
  border-color: #ef4444;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  width: 100%;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--transition);
}

#context-menu .btn-danger:hover { background: #dc2626; }

/* Panels inside sidebar */
.sidebar .panel {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  margin-top: 10px;
}

.sidebar .panel-heading {
  font-size: 11px;
  font-weight: 600;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar .panel-body {
  padding: 10px 12px;
  color: #cbd5e1;
  font-size: 12px;
}

.sidebar .form-group { margin-bottom: 8px; }

.sidebar .control-label {
  color: var(--sidebar-text);
  font-size: 12px;
  font-weight: 500;
}

.sidebar .form-control {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  padding: 5px 8px;
  height: 30px;
}

.sidebar .form-control:focus {
  border-color: var(--brand);
  outline: none;
  background: rgba(99,102,241,.1);
}

.sidebar label {
  color: var(--sidebar-text);
  font-size: 12px;
}

.sidebar input[type=checkbox] { margin-right: 6px; }

.sidebar small { color: var(--sidebar-text); }

/* Texture thumbnails */
.thumbnail.texture-select-thumbnail {
  border: 2px solid rgba(255,255,255,.1);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition);
  padding: 2px;
  background: rgba(255,255,255,.04);
  margin-bottom: 6px;
}

.thumbnail.texture-select-thumbnail:hover {
  border-color: var(--brand);
}

/* ── Main content ────────────────────────────────────────────────── */
.main {
  flex: 1;
  padding: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* ── 3D Viewer ───────────────────────────────────────────────────── */
#viewer { display: none; position: relative; width: 100%; height: 100%; }

/* ── 2D Floorplanner ─────────────────────────────────────────────── */
#floorplanner { display: none; position: relative; width: 100%; height: 100%; }

#floorplanner canvas { display: block; }

/* ── Add Items ───────────────────────────────────────────────────── */
#add-items {
  display: none;
  padding: 24px;
  overflow-y: auto;
  background: var(--bg);
}

#add-items h4 {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Main controls (top-left overlay) ───────────────────────────── */
#main-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 0;
  display: flex;
  gap: 6px;
  z-index: 20;
}

#main-controls .btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
}

#main-controls .btn:hover {
  background: var(--bg);
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
  color: var(--text);
  text-decoration: none;
}

#main-controls .btn-success,
#import-image-btn {
  background: var(--brand) !important;
  border-color: var(--brand) !important;
  color: #ffffff !important;
}

#main-controls .btn-success:hover,
#import-image-btn:hover {
  background: var(--brand-dark) !important;
  border-color: var(--brand-dark) !important;
  box-shadow: 0 4px 12px rgba(99,102,241,.35) !important;
}

/* ── Camera controls (bottom-right overlay) ─────────────────────── */
#camera-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  padding: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cam-group {
  display: flex;
  gap: 4px;
}

.cam-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.cam-dpad-row {
  display: flex;
  gap: 4px;
}

#camera-controls .btn {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.7);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 13px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  float: none;
}

#camera-controls .btn:hover {
  background: #fff;
  box-shadow: var(--shadow-lg);
  color: var(--brand);
  text-decoration: none;
}


/* ── Floorplanner toolbar ────────────────────────────────────────── */
#floorplanner-controls {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  z-index: 20;
}

#floorplanner-controls .btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition);
  cursor: pointer;
  box-shadow: var(--shadow);
}

#floorplanner-controls .btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: #cbd5e1;
}

#floorplanner-controls .btn.active,
#floorplanner-controls .btn:active {
  background: var(--brand-light);
  color: var(--brand);
  border-color: #c7d2fe;
}

#floorplanner-controls .btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  margin-left: auto;
}

#floorplanner-controls .btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

/* Curvature control */
#curvature-control {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
}

#curvature-control label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin: 0;
  white-space: nowrap;
}

#wall-curvature {
  width: 90px;
  accent-color: var(--brand);
  cursor: pointer;
}

#wall-curvature-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  min-width: 40px;
}

/* ── Draw walls hint ─────────────────────────────────────────────── */
#draw-walls-hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 20px;
  background: rgba(15,23,42,.8);
  backdrop-filter: blur(8px);
  color: #e2e8f0;
  padding: 8px 16px;
  border-radius: 20px;
  z-index: 10;
  display: none;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,.1);
  white-space: nowrap;
}

/* ── Loading modal ───────────────────────────────────────────────── */
#loading-modal {
  position: absolute;
  z-index: 10;
  left: 0; top: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15,23,42,.85);
  backdrop-filter: blur(4px);
}

#loading-modal h1 {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  text-align: center;
}

#loading-modal::before {
  content: '';
  display: block;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(99,102,241,.3);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: 16px;
}

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

/* ── File input helper ───────────────────────────────────────────── */
.btn-file {
  display: inline-block;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.btn-file input[type=file] {
  position: absolute;
  top: 0; right: 0;
  min-width: 100%; min-height: 100%;
  filter: alpha(opacity=0);
  opacity: 0;
  cursor: inherit;
  display: block;
}

.hidden-input { display: none; }

/* ── Add item cards ──────────────────────────────────────────────── */
.add-item {
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}

.add-item:hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
  transform: translateY(-1px);
}

/* ── Bootstrap modal overrides ───────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  overflow: hidden;
}

.modal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}

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

.modal-header .close {
  opacity: .4;
  font-size: 18px;
  margin-top: 1px;
}

.modal-header .close:hover { opacity: .7; }

.modal-body { padding: 20px; }

.modal-footer {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  background: var(--bg);
}

.modal-footer .btn {
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
}

.modal-footer .btn-default {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.modal-footer .btn-default:hover { background: var(--bg); }

.modal-footer .btn-success {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.modal-footer .btn-success:hover { background: var(--brand-dark); }

.modal-footer .btn-success:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* ── Import image modal internals ────────────────────────────────── */
#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  background: var(--bg);
}

#drop-zone:hover, #drop-zone.drag-over {
  background: var(--brand-light);
  border-color: var(--brand);
}

#drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

#drop-zone .glyphicon {
  font-size: 40px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 12px;
}

#drop-zone.drag-over .glyphicon { color: var(--brand); }

#drop-zone p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

#drop-zone p strong { color: var(--text); }

#import-image-preview-wrap {
  margin-top: 16px;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
}

#import-image-preview {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
}

#remove-image {
  position: absolute;
  top: 8px;
  right: 8px;
  cursor: pointer;
  background: rgba(0,0,0,.6);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  text-align: center;
  line-height: 24px;
  font-size: 14px;
  font-weight: bold;
  transition: background var(--transition);
}

#remove-image:hover { background: rgba(0,0,0,.85); }

#import-image-status {
  margin-top: 12px;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--bg);
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Scrollbar (webkit) ──────────────────────────────────────────── */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.12);
  border-radius: 4px;
}

/* ── Responsive fix ──────────────────────────────────────────────── */
.col-xs-3 { width: var(--sidebar-w) !important; padding: 0 !important; }
.col-xs-9 { width: calc(100% - var(--sidebar-w)) !important; padding: 0 !important; }
