/* === Layout Editor === */
.layout-editor-container {
  display: flex;
  gap: 16px;
  height: calc(100vh - var(--topbar-height) - 48px);
}

.layout-canvas {
  flex: 1;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: auto;
  min-height: 400px;
}

.layout-canvas.drag-over {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.layout-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
  padding: 16px;
  min-height: 100%;
  max-width: 100%;
  overflow: hidden;
}

.layout-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  position: relative;
  cursor: grab;
  transition: border-color var(--transition), box-shadow var(--transition);
  overflow: hidden;
}

.layout-widget:hover {
  border-color: var(--primary);
}

.layout-widget.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.layout-widget.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.widget-drag-handle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  cursor: grab;
}

.widget-drag-handle .widget-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.widget-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.layout-widget:hover .widget-actions { opacity: 1; }

.widget-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.widget-action-btn:hover { background: var(--surface-3); color: var(--text); }
.widget-action-btn.delete:hover { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

.widget-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: se-resize;
  opacity: 0;
  transition: opacity var(--transition);
}

.layout-widget:hover .widget-resize-handle { opacity: 0.5; }

.widget-resize-handle::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
}

/* Sidebar panel in layout editor */
.layout-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.layout-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

.layout-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.widget-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: grab;
  transition: all var(--transition);
}

.widget-palette-item:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.widget-palette-icon { font-size: 20px; min-width: 28px; text-align: center; }
.widget-palette-info { flex: 1; }
.widget-palette-name { font-size: 13px; font-weight: 600; }
.widget-palette-desc { font-size: 11px; color: var(--text-dim); }

/* Widget config panel (appears when widget selected) */
.widget-config-panel {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.widget-config-panel h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-muted);
}

/* Size controls */
.size-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.size-control {
  flex: 1;
}

.size-control label {
  font-size: 11px;
  color: var(--text-dim);
}

.size-control input {
  width: 100%;
  padding: 6px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  text-align: center;
}

/* Layout toolbar */
.layout-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.layout-toolbar-left { display: flex; gap: 8px; align-items: center; }
.layout-toolbar-right { display: flex; gap: 8px; align-items: center; }

.layout-name-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  width: 200px;
}
