:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-canvas: #020617;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --sidebar-width: 280px;
  --header-height: 60px;
  --radius: 12px;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

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

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

::-webkit-scrollbar-thumb {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(to right, var(--primary), #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar {
  display: flex;
  gap: 12px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-icon:hover {
  background: var(--border);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  border: none;
  color: #000;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

/* Main Layout */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#sidebar-container {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#stencils {
  padding: 20px;
  overflow-y: auto;
  height: 100%;
}



.section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 700;
}

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

.stencil-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: grab;
  transition: all 0.2s;
  user-select: none;
}

.stencil-item:hover {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.05);
  transform: scale(1.02);
}

.stencil-item i {
  font-size: 1.25rem;
  color: var(--primary);
}

.stencil-item span {
  font-size: 0.7rem;
  font-weight: 600;
}

/* Canvas Area */
#canvas-container {
  flex: 1;
  background-color: var(--bg-canvas);
  position: relative;
  overflow: auto;
  padding: 40px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#canvas {
  width: 1200px;
  height: 800px;
  background-color: #0f172a;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.15) 0.5px, transparent 0.5px);
  background-size: 10px 10px;
  position: relative;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
  border: 1px solid var(--border);
  border-radius: 4px;
}

#canvas.hide-grid {
    background-image: none !important;
}

#canvas.hide-comments .dropped-element[data-type="comment"] {
    display: none !important;
}

/* Floating Properties Inspector */
.floating-props {
    position: fixed;
    z-index: 10000;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid #475569;
    border-radius: 12px;
    width: 240px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    display: none;
    overflow: hidden;
    animation: fadeInScale 0.15s ease-out;
}
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95) translateY(5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.floating-header {
    background: #334155;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #475569;
    cursor: move; /* Indicated draggable area */
    user-select: none;
}
.floating-body {
    padding: 10px;
}

/* Comment (Sticky Note) */
.dropped-element[data-type="comment"] {
    border-radius: 4px !important;
    padding: 10px !important;
    box-shadow: 3px 3px 6px rgba(0,0,0,0.15) !important;
}

/* Dropped Elements */
.dropped-element {
  position: absolute;
  cursor: move;
  padding: 4px;
  border: 1px solid transparent;
  transition: border 0.1s;
}

.multi-select-mode .dropped-element.selected {
  outline: 1px dashed var(--primary);
  outline-offset: 2px;
}

.dropped-element.selected {
  outline: 1px dashed #38bdf8 !important;
  outline-offset: 2px;
  z-index: 1000 !important;
}

.selection-rect {
    position: absolute;
    border: 1px dashed rgba(255, 255, 255, 0.5);
    background: none !important;
    pointer-events: none;
    z-index: 1000;
}

/* Delete handle removed */

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    background: transparent; /* No more white box */
    display: none;
    cursor: nwse-resize;
    z-index: 10;
}

/* Property Panel - Simplified for sidebar integration */
#prop-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prop-group {
  margin-bottom: 20px;
}

.prop-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.prop-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.prop-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  margin-top: 60px;
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Generic Stencil Styling */
.dropped-element button {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 500;
    pointer-events: none; /* Let the wrapper handle drag */
}

.dropped-element input, .dropped-element textarea, .dropped-element select {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 8px;
    pointer-events: none;
}

.dropped-element h1, .dropped-element h2, .dropped-element h3 {
    margin: 0;
    pointer-events: none;
}

.dropped-element p {
    margin: 0;
    pointer-events: none;
}

.dropped-element button, 
.dropped-element input, 
.dropped-element textarea, 
.dropped-element select,
.dropped-element div:not(.delete-handle) {
    width: 100%;
    height: 100%;
}
